python - 错误 : (-215) nimages > 0 in function calibrateCamera using Python and OpenCV

标签 python opencv ubuntu

我正在尝试根据 opencv 示例中给出的示例校准我的网络摄像头,但是当我运行此处提供的代码时:

def caliLeftCam():    
    args, img_mask = getopt.getopt(sys.argv[1:], '', ['save=', 'debug=', 'square_size='])
    args = dict(args)
    try: img_mask = img_mask[0]
    except: img_mask = '../cpp/img*.jpg'
    img_names = glob(img_mask)
    debug_dir = args.get('--debug')
    square_size = float(args.get('--square_size', 1.0))

    pattern_size = (7, 5)
    pattern_points = np.zeros( (np.prod(pattern_size), 3), np.float32 )
    pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2)
    pattern_points *= square_size

    obj_points = []
    img_pointsL = []
    h, w = 0, 0
    for fn in img_names:
        print "processing %s..." % fn,
        imgL = cv2.imread(fn, 0)
        h, w = imgL.shape[:2]
        found, corners = cv2.findChessboardCorners(imgL, pattern_size)
        if found:
            term = ( cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_COUNT, 30, 0.1 )
            cv2.cornerSubPix(imgL, corners, (5, 5), (-1, -1), term)
        if debug_dir:
            vis = cv2.cvtColor(imgL, cv2.COLOR_GRAY2BGR)
            cv2.drawChessboardCorners(vis, pattern_size, corners, found)
            path, name, ext = splitfn(fn)
            cv2.imwrite('%s/%s_chess.bmp' % (debug_dir, name), vis)
        if not found:
            print "chessboard not found"
            continue
        img_pointsL.append(corners.reshape(-1, 2))
        obj_points.append(pattern_points)

        print 'ok'

    rmsL, cameraL_matrix, dist_coefsL, rvecsL, tvecsL = cv2.calibrateCamera(obj_points, img_pointsL, (w, h))

我收到了这个错误:
Traceback (most recent call last):
File "/home/sabrine/Downloads/opencv-2.4.9/samples/python2/Memo.py", line 293, in <module>
Img_pointsL, Cam_MatL, DisL = caliLeftCam()
File "/home/sabrine/Downloads/opencv-2.4.9/samples/python2/Memo.py", line 124, in caliLeftCam
rmsL, cameraL_matrix, dist_coefsL, rvecsL, tvecsL = cv2.calibrateCamera(obj_points, img_pointsL, (w, h))
error: /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/calibration.cpp:3415: 
error: (-215) nimages > 0 in function calibrateCamera

这个错误是什么意思?
我该如何解决?

最佳答案

该错误表示作为参数提供的向量之一为空。

如果不是所有条件都满足,该函数有一个断言阻止您使用它。这次它检查是否有足够的图像点(nimages > 0 必须为真)。

关于python - 错误 : (-215) nimages > 0 in function calibrateCamera using Python and OpenCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23819042/

相关文章:

python - 在python中根据名称输入文件夹

python - 在 Google App 引擎中运行 Cherrypy

python - Python/OpenCV/OSX 中的鼠标回调事件标志?

c++ - 在 OpenCV 中从 Point 数据类型转换为 int

ubuntu - goclipse 去 ubuntu 上的二进制位置

c - Unix 中的两个主题标签包含哪些文件类型?

python - 绘制不同频率的系列图

Python-Opencv 在内存缓冲区上写入 x264 视频

python - 公共(public) python 程序作为包含所有模块的一个文件

Perl 无法安装 Net::SSL