简体   繁体   中英

16bit Stero Video Capture pixel wise bit separation

I have a stereo camera that outputs the image of camera in the following format using UVC standard. The camera device is OVRvision PRO

立体声视频输出 The camera is directly connected to PC using USB cable and the video stream is obtained using the VideoCapture class in opencv (python)

The information I have from docs is that each pixel, the upper 8 bits are transmitted as the left eye, and the lower 8 bits are transmitted as the right eye the 16 bit data of the pixel.

The dtype I am getting in frame is uint8

The I am unsure how to proceed with separating bits each pixel in the video capture. I would appreciate any help.

cv2.VideoCapture will return numpy arrays, so if they're 16bit, they should have datatype np.uint16 .

In that case, the solution is trivial: do the same thing as you'd do to split a single 16bit value. Numpy provides a vectorized version of all the necessary operators.

  • Right:

    • Cast to np.uint8 (upper bits are discarded)

       right = np.uint8(frame) 
  • Left:

    • Shift right by 8 bits
    • Cast to np.uint8

       left = np.uint8(frame >> 8) 

In case the input image was downscaled to 8-bit depth, you will be left with two 16-level images. To retrieve the two components, you just have to slightly modify the approach...

Example in console:

>>> a = np.ones((4,4),np.uint8) * 0x73
>>> a & 0xF
array([[3, 3, 3, 3],
       [3, 3, 3, 3],
       [3, 3, 3, 3],
       [3, 3, 3, 3]], dtype=uint8)
>>> a >> 4
array([[7, 7, 7, 7],
       [7, 7, 7, 7],
       [7, 7, 7, 7],
       [7, 7, 7, 7]], dtype=uint8)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM