OpenCV错误:在calibrateCamera中断言失败(nimages> 0),第3415行由python

时间:2015-01-15 07:09:01

标签: python opencv camera-calibration

我正在使用OpenCV和python

在ubuntu 14中进行相机校准

我执行了这篇文章附带的代码进行摄像机校准。当摄像机正确检测到角落时,代码的一部分似乎正常工作。但是在calibrateCamera中出现了这个错误“ OpenCV错误:断言失败(nimages> 0),文件/home/aljovjoy/Downloads/opencv-2.4.9/modules/calib3d/src/calibration.cpp,第3415行”

应该纠正此错误以完成相机校准。请告诉我如何删除此错误以使其正常工作

import numpy as np
import cv2
import glob
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
objpoints = []
imgpoints = [] 
images = glob.glob('/usr/local/share/OpenCV/samples/cpp/chess*.jpg')
for fname in images:
    img = cv2.imread(fname)
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    ret = False
    ret, corners = cv2.findChessboardCorners(gray, (9,6))
    if ret == True:
        cv2.cornerSubPix(gray, corners, (11,11), (-1,-1), criteria)
        imgpoints.append(corners)
        # Draw and display the corners
        cv2.drawChessboardCorners(img, (9,6), corners, ret)
        cv2.imshow('img',img)
        cv2.waitKey(0)
cv2.destroyAllWindows()

提前致谢

0 个答案:

没有答案