VideoCapure: uncompressed 16 bit video stream (Y16)
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)
you could try one of those
@berak: Thank you for your reply.
There is no Y16 format there. Moreover, mode settings are not fully supported:
Opencv does not support Y16 format! You need to modify the source code to add Y16 support.
@Balaji , i don't think, that's true, see hereor here
@berak Thanks for the update! You are Right!!