Setup:
- Ubuntu 16.04 LTS
- OpenCV-python version 3.4.1
$v4l2-ctl -d /dev/video3 --list-formats ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'Y16 ' Name : 16-bit Greyscale
Using VideoCapture I get 3 channels array of uint8 instead of single channel uint16. I can't set the proper CAP_PROP_FORMAT. Thus, the read method returns also array of uint8. How to capture 16 bit video with OpenCV-python?
>>> cam = cv2.VideoCapture("/dev/video3") >>> cam.get(cv2.CAP_PROP_FORMAT) 16.0 (cv2.CV_8UC3) >>> cam.set(cv2.CAP_PROP_FORMAT,cv2.CV_16U) VIDEOIO ERROR: V4L2: setting property #8 is not supported True >>> _, frame = cam.read() >>> frame array([[[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]], ..., [[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0, 0, 0], ..., [0, 0, 0], [0, 0, 0], [0, 0, 0]]], dtype=uint8)