python opencv 标定_使用Python和OpenCV E校准网络摄像机

这一切都很新鲜,我正试图按照this指南并使用下面的代码来校准网络摄像头。我得到以下错误。。OpenCV Error: Assertion failed (ni > 0 && ni == ni1) in collectCalibrationData, file /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/calibration.cpp, line 3193

cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/calibration.cpp:3193: error: (-215) ni > 0 && ni == ni1 in function collectCalibrationData

有人能解释一下这个错误是什么以及如何修复它吗?

(底部完全错误)import numpy as np

import cv2

import glob

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

# Arrays to store object points and image points from all the images.

objpoints = [] # 3d point in real world

imgpoints = [] # 2d points in image plane.

images = glob.glob('*.png')

objp = np.zeros((6*7,3), np.float32)

objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2)

objp = objp * 22

for fname in images:

img = cv2.imread(fname)

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

ret = False

# Find the chess board corners

ret, corners = cv2.findChessboardCorners(gray, (6,9))

# If found, add object points, image points (after refining them)

if ret == True:

objpoints.append(objp)

cv2.cornerSubPix(gray, corners, (11,11), (-1,-1), criteria)

imgpoints.append(corners)

# Draw and display the corners

cv2.drawChessboardCorners(img, (6,9), corners, ret)

cv2.imshow('img',img)

cv2.waitKey(0)

cv2.waitKey(0)

for i in range (1,5):

cv2.waitKey(1)

cv2.destroyAllWindows()

cv2.waitKey(1)

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1],None,None)OpenCV Error: Assertion failed (ni > 0 && ni == ni1) in collectCalibrationData, file /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/calibration.cpp, line 3193

Traceback (most recent call last):

File "", line 1, in

File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile

execfile(filename, namespace)

File "/home/students/Test/test.py", line 49, in

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1],None,None)

cv2.error: /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/calibration.cpp:3193: error: (-215) ni > 0 && ni == ni1 in function collectCalibrationData

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值