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



我正试图将点数组传递给plotChessboardCorners和cornersSubPix函数,但我得到这些错误信息:

Exception: ........opencvmodulescalib3dsrccalibinit.cpp:1944:
error: (-215) nelems >= 0 in function cv::drawChessboardCorners
Exception: ........opencvmodulesimgprocsrccornersubpix.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。下面的assert语句生成了错误信息:int nelems = corners.checkVector(2, CV_32F, true); CV_Assert(nelems >= 0);

相关内容

  • 没有找到相关文章

最新更新