gpt4 book ai didi

opencv - CV2 plotChessboardCorners 和 cornersSubPix 期望的点的形状/顺序是什么?

转载 作者:太空宇宙 更新时间:2023-11-03 22:26:03 25 4
gpt4 key购买 nike

我试图将一个点数组传递给 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);

关于opencv - CV2 plotChessboardCorners 和 cornersSubPix 期望的点的形状/顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38903786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com