我试图将一个点数组传递给 plotChessboardCorners 和 cornersSubPix 函数,但我收到了这些错误消息:
Exception: ..\..\..\..\opencv\modules\calib3d\src\calibinit.cpp:1944:
error: (-215) nelems >= 0 in function cv::drawChessboardCorners
Exception: ..\..\..\..\opencv\modules\imgproc\src\cornersubpix.cpp:257:
error: (-215) ncorners >= 0 && corners.depth() == CV_32F in function cv::cornerSubPix
我认为这与数组的排序有关。但是,findChessboardCorners 返回一个形状为 [npoints, 1, 2] 的数组,这与我传递的数组的形状相同吗?
我的代码是:
if (findChessboardCorners failed):
corners = (reconstructed corners of shape [npoints, 2])
corners.shape = (len(corners),1,2) #reshape to shape expected by openCV
numfound = 0 if corners is None else len(corners)
if numfound==nX*nY: #reconstruction successful
figC = plt.figure('Corners found in image ' +str(i+1) + ' in camera ' +camnames[j])
plt.imshow(I, cmap='gray')
cv2.drawChessboardCorners(Inew, (nX,nY), corners, 1)
plt.show()
这是一个数据类型问题:角数组需要是 float32。此断言语句生成错误消息:int nelems = corners.checkVector(2, CV_32F, true);
CV_Assert(nelems >= 0);
我是一名优秀的程序员,十分优秀!