0

I have a 16 bits camera. When I try to use OpenCV for reading a new frame from this device, OpenCV's .read() function returns a 8 bits image. How can I get raw 16 bits readings from a camera in OpenCV (python)?

import cv2
import numpy as np 

scr = 0
num_frames = 10
frames = 0

cam = cv2.VideoCapture(scr)

while True:

    ref, frame = cam.read()
    print 'Max: ', np.max(frame), '; Min: ', np.min(frame)

    if frames == num_frames:
        break
    else:             
        frames += 1

cam.release()
gorkem
  • 731
  • 1
  • 10
  • 17
Guille
  • 1
  • 1
  • [Possibly related](https://stackoverflow.com/questions/10969585/opencv-reading-a-16-bit-grayscale-image) – Alex Alifimoff Jun 26 '17 at 18:41
  • 1
    Try setting the `CV_CAP_PROP_FORMAT` to `CV_16U`. It should be something like: `cam.set(cv2.CV_CAP_PROP_FORMAT, cv2.CV_16U)` ...and check its return value – Miki Jun 26 '17 at 18:51
  • Thank you Alex. Unfortunately, I have checked it but I am still reading 8 bits. There is no difference in the readings. – Guille Jun 26 '17 at 20:26

0 Answers0