How to convert 10Bit video into cv::Mat

Hi,

I need to convert a 10Bit YUV video stream into the cv::Mat format. What is the best way for this? I’d tried to convert to a 16 Bit resolution, but with this I get read access violation errors.

switch(pixelFormat) {
case bmdFormat10BitYUV:
        m_inputFrame = cv::Mat(height, width, CV_16UC2, buffer, step);
        cv::cvtColor(m_inputFrame, m_outputFrame, cv::COLOR_YUV2BGR_UYVY, 0);
        break;

I found a reference to bmdFormat10BitYUV here:

https://alax.info/blog/1454

which seems to suggest it has a fourcc code of V210

I found something here that talks about V210:

“It is a 10 bit per component, YCrCb 4:2:2 format in which samples for 5 pixels are packed into 4 4-byte little endian words.”

OpenCV provides a lot of color conversions, but I didn’t see any reference to 10 bit formats in the list.

It’s possible you will have to write a conversion function yourself. I don’t think it would be difficult to do it correctly, but making it efficient might be difficult.

2 Likes