OpenCV Python 库中的 cv.cornerSubPix 参数
我在使用 OpenCV python 包装器执行以下函数时遇到问题:
img = cv.LoadImage("calib0.jpg")
grayImg = cv.CreateImage((img.width,img.height), img.depth,1)
cv.CvtColor(img,grayImg,cv.CV_BGR2GRAY)
corners = cv.FindChessboardCorners(grayImg,(5,6), cv.CALIB_CB_ADAPTIVE_THRESH + cv.CALIB_CB_NORMALIZE_IMAGE + cv.CALIB_CB_FAST_CHECK )
cv.cornerSubPix(grayImg,corners,(11,11),(-1,-1),(cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS, 10, 0.01))
如果我在 (OSX) 上的 iPython 中运行此函数,则会收到以下错误:
TypeError Traceback (most最近的调用最后) /Users/katherinescott/simplecv-git/SimpleCV/sampleimages/ 在 () ----> 1 cv.cornerSubPix(grayImg,corners,(11,11),(-1,-1),(cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS, 10, 0.01))
TypeError: 不是
我尝试过的 numpy 数组将上述对象转换为 numpy ndarray 的每一种排列,但都无济于事。我的猜测是这个错误存在于术语标准对象中,但我不知道它要求什么。有其他人在尝试使用 OpenCV Python 包装器执行校准时遇到过这个问题吗?我即将开始深入研究源代码,看看能找到什么。
I am having problems getting the following function to execute using the OpenCV python wrapper:
img = cv.LoadImage("calib0.jpg")
grayImg = cv.CreateImage((img.width,img.height), img.depth,1)
cv.CvtColor(img,grayImg,cv.CV_BGR2GRAY)
corners = cv.FindChessboardCorners(grayImg,(5,6), cv.CALIB_CB_ADAPTIVE_THRESH + cv.CALIB_CB_NORMALIZE_IMAGE + cv.CALIB_CB_FAST_CHECK )
cv.cornerSubPix(grayImg,corners,(11,11),(-1,-1),(cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS, 10, 0.01))
If I run this in iPython on (OSX) I get the following error:
TypeError Traceback (most recent call last)
/Users/katherinescott/simplecv-git/SimpleCV/sampleimages/ in ()
----> 1 cv.cornerSubPix(grayImg,corners,(11,11),(-1,-1),(cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS, 10, 0.01))
TypeError: is not a numpy array
I've tried just about every permutation of casting the above objects to a numpy ndarray but to no avail. My guess is that this error lives in the term criteria object, but I am at a loss as to what it is asking for. Has anyone else encountered this problem when trying to perform calibration using the OpenCV Python wrappers? I am about to start digging into the source to see what I can find.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cornerSubPix 以小写字母开头,是 OpenCV python 包装器的模块内部函数。
我相信你想要 cv.FindCornerSubPix:
http://opencv.willowgarage.com/documentation /python/imgproc_feature_detection.html#findcornersubpix
cornerSubPix, having a lowercase letter first, is a module-internal function for the OpenCV python wrapper.
I believe you want cv.FindCornerSubPix:
http://opencv.willowgarage.com/documentation/python/imgproc_feature_detection.html#findcornersubpix
老问题,但我相信
cv.cornerSubPix()
中的winSize
参数可能存在一些误解。使用时
假设您需要 11x11 搜索窗口,则
winSize
的适当输入应为winSize=(5,5)
而不是winSize=(11,11)
。如果您使用 (11,11) 作为winSize
(如原始问题中发布的那样),则生成的搜索窗口实际上是 23x23。根据文档:
从 OpenCV 4.5.2(2021 年 4 月)开始,相关
cv.findChessboardCorners()
下文档中的示例似乎不正确,应改用 winSize 的 (5,5)。Old question, but I believe there may be some misunderstanding with the
winSize
parameter incv.cornerSubPix()
.When using
Assuming you want an 11x11 search window, the appropriate input for
winSize
should bewinSize=(5,5)
and notwinSize=(11,11)
. If you use (11,11) forwinSize
as posted in the original question, the resulting search window would actually be 23x23.According to the documentation:
As of OpenCV 4.5.2 (April 2021), the example in the documentation under related
cv.findChessboardCorners()
appears to be incorrect and (5,5) for winSize should be used instead.