Jump to content

Milind Padalkar

Verified Members
  • Posts

    4
  • Joined

  • Last visited

Reputation

0 Neutral
  1. Seems like the other view is available if you set the correct frame size (reference post). Here is how you can do it (note that the 2nd view is available below the 1st one). import argparse import cv2 as cv def get_args(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--cam", type=int, default=0, help="camera index") args = parser.parse_args() return args def play_video(idx): cap = cv.VideoCapture(idx) width = cap.get(cv.CAP_PROP_FRAME_WIDTH) height = cap.get(cv.CAP_PROP_FRAME_HEIGHT) print(f"default size: {width} x {height}") cap.set(cv.CAP_PROP_FRAME_WIDTH, width) cap.set(cv.CAP_PROP_FRAME_HEIGHT, height*2) if not cap.isOpened(): print("Cannot open camera") exit() print(f"Showing camera {idx} with backend {cap.getBackendName()}") cv.namedWindow("Vive Pro Front cameras: Left=Bottom, Right=Top") while True: # Capture frame-by-frame ret, frame = cap.read() # if frame is read correctly ret is True if not ret: print("Can't receive frame (stream end?). Exiting ...") break # Our operations on the frame come here # Display the resulting frame cv.imshow("Vive Pro Front cameras: Left=Bottom, Right=Top", frame) k = cv.waitKey(1) if k == ord('q') or k == 27: break # When everything done, release the capture cap.release() cv.destroyAllWindows() if __name__=="__main__": args = get_args() play_video(args.cam)
  2. Seems it was fairly easy after looking at the output of : v4l2-ctl --device /dev/video0 --list-formats-ext # /dev/video0 corresponds to the VivePro' camera I found that it the following entries among many: ioctl: VIDIOC_ENUM_FMT Type: Video Capture [0]: 'YUYV' (YUYV 4:2:2) Size: Discrete 640x480 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 612x460 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 612x920 Interval: Discrete 0.019s (52.000 fps) Interval: Discrete 0.018s (55.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.017s (60.000 fps) Size: Discrete 320x240 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 352x288 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 432x240 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 640x360 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 800x448 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 800x600 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 864x480 Interval: Discrete 0.033s (30.000 fps) Size: Discrete 640x481 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 640x960 Interval: Discrete 0.017s (60.000 fps) Size: Discrete 612x920 Interval: Discrete 0.019s (52.000 fps) Interval: Discrete 0.018s (55.000 fps) Interval: Discrete 0.033s (30.000 fps) Interval: Discrete 0.017s (60.000 fps) So by default it was showing 640x480 but one can also access 640x960 which is 2*(640x480). The attached file shows how to access it. vive_pro_front_stereo.cpp
  3. Hi @bipul mohanto, maybe you can have a look at the following using OpenXR with Godot. Using OpenCV C++ code with Godot 3.5.2 on Ubuntu 20.04 Display independent images in the left-right views Hope it helps!
  4. I have the Vive Pro and I can access one of the front cameras (the right one specifically) with OpenCV's API and C++ (cv::VideoCapture()). How can I access both the front cameras? I am using Ubuntu 20.04. Thanks and best regards, Milind
×
×
  • Create New...