我正在尝试校准两台摄像机以获得立体视觉。一个是Pi Camera,另一个是插入Raspberry Pi的USB网络摄像头。我不知道为什么,但是Pi发现的棋盘点准确性(总是)不高。请看所附图片。合适的摄像头(网络摄像头)更简单,更准确。有什么办法可以改善这一点?
这是脚本的某些部分。
# webcam is called by cv2.VideoCapture, and picam is called by PiCamera()
left = PiCamera()
left.resolution = (640,480)
right = cv2.VideoCapture(0)
while n <= Total_num:
right.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
right.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
img1 = np.empty((480, 640, 3), dtype=np.uint8)
left.capture(img1, "bgr")
ret, img2 = right.read()
此后,它们变成了灰色,并且找到了角落。
gray1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
gray2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
ret1, corners1 = cv2.findChessboardCorners(gray1, checkerBoard, None)
ret2, corners2 = cv2.findChessboardCorners(gray2, checkerBoard, None)
cv2.cornerSubPix(gray1, corners1, (5, 5), (-1, -1), criteria)
cv2.cornerSubPix(gray2, corners1, (5, 5), (-1, -1), criteria)
cv2.drawChessboardCorners(img1, checkerBoard, corners1, ret1)
cv2.drawChessboardCorners(img2, checkerBoard, corners2, ret2)