I'm trying to calibrate my web-cam based on the example given in the opencv samples but when i run the code provided here:
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))
i got this error:
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 caliLeftCamrmsL, 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
what does this error mean?and how can i solve it?