Indeed, I want to store and work with data from a 10bit machine vision camera (monochrome). The 10 bit data will most likely be represented as 16 bit for all processing purposes (although some downgrading to 8 bit may happen at some point, say for display. The processing pipeline can be developped in OpenCV but could also be in PyTorch or else (as this is for academic research purposes).
Enabling both recording and reading of 10 bit data in OpenCV would allow us to pre-record some videos and work on them offline with the same characteristics as if coming from the camera. It also helps with testing that writting works.
For the specific case of NV_ENC_BUFFER_FORMAT_YUV420_10BIT
for monochrome data, this would work rather seamlesslessy with opencv since we would get the Y plane already in 16 bit (most significant 10 bits being written to) and can simply discard the U and V planes (unused for monochrome) by cropping the images. Thus all OpenCV routines already supporting 16 bit grayscale data would be usable.
If YUV is actually used for colour as well, converting the YUV420 frame (single “packed” 16 bit channel) to a “full” 3 channel 16bit YUV or RGB matrix can be done easily with a few opencv routines (e.g. cv2.resize
, cv2.cuda.merge
, etc.).
It may look more inuitive to work with a grayscale colour format rather than yuv420 for grayscale image capture. However, 10 bit grayscale hevc is not widely supported (I don’t think nvenc does it for example) and there are little downsides in just having zero filled U and V (semi) planes.