Split ZED Camera Feed for Calibration - Carleton-SRCL/SPOT GitHub Wiki
Click here for raw code
"""
Allows user to split stereo feed into 2, and capture images for calibration
Written by Ryan McPherson, Oct 2023
Modified from Nicolai Nielsen's YouTube Tutorial
Some code modified from Hayden Arms' CalibrationImageSplitter.py
Use 's' to save photos, take 5-6 photos, and press 'esc' to quit
"""
import cv2
cap = cv2.VideoCapture(0)
num = 0
while cap.isOpened():
succes1, img = cap.read()
height, width, _ = img.shape
width_cutoff = width // 2
LeftImage = img[:, :width_cutoff]
RightImage = img[:, width_cutoff:]
k = cv2.waitKey(5)
if k == 27:
break
elif k == ord('s'): # wait for 's' key to save and exit
cv2.imwrite('images/stereoLeft/imageL' + str(num) + '.png', LeftImage)
cv2.imwrite('images/stereoRight/imageR' + str(num) + '.png', RightImage)
print("images saved!")
num += 1
cv2.imshow('Img 1',LeftImage)
cv2.imshow('Img 2', RightImage)
# Release and destroy all windows before termination
cap.release()
cv2.destroyAllWindows()
Purpose
- This function captures stereo camera images, splits them into the right and left feed, and saves them for future calibration usage.
Inputs
-
RightImageDirectory
- This is the directory where the split right calibration images will be saved.
-
LeftImageDirectory
- This is the directory where the split left calibration images will be saved.
Outputs
- A live feed where the left and right sides of the stereovision camera are split into 2 separate video feeds (stacked: right on top, left on bottom). If K is pressed, the left and right images will be saved to the previously selected directories.