I seek to use the two cameras in the front of my HTC Vive Pro in order to implement SLAM using Stereo Vision. I would prefer if this was possible using Python, however, I cannot find a good way to open up both cameras (I can only open the right camera with cv2.VideoCapture(1)
). The device is currently simply connected by a usb.
What I have so far is
import cv2
cv2.namedWindow("Camera 1")
cv2.namedWindow("Camera 2")
stereo = cv2.VideoCapture(1)
if stereo.isOpened():
rval, frame = stereo.read()
else:
rval = False
while rval:
rval_left, left = stereo.retrieve(0)
rval_right, right = stereo.retrieve(1)
cv2.imshow("Camera 1", left)
cv2.imshow("Camera 2", right)
key = cv2.waitKey(20)
if key == 27:
# exit on ESC
break
cv2.destroyAllWindows()
But stereo
is not really stereo as expected. cv2.VideoCapture(0)
is the laptop webcam and all other cv2.VideoCapture(...)
returns None. I hope somebody can help.