Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting YUV into BGR or RGB in OpenCV
    text
    copied!<p>I have a TV capture card that has a feed coming in as a YUV format. I've seen other posts here similar to this question and attempted to try every possible method stated, but neither of them provided a clear image. At the moment the best results were with the OpenCV <code>cvCvtColor(scr, dst, CV_YUV2BGR)</code> function call.</p> <p>I am currently unaware of the YUV format and to be honest confuses me a little bit as it looks like it stores 4 channels, but is only 3? I have included an image from the capture card to hope that someone can understand what is possibly going on that I could use to fill in the blanks.</p> <p><img src="https://i.stack.imgur.com/RsPNF.png" alt="YUV to BGR converted image"></p> <p>The feed is coming in through a DeckLink Intensity Pro card and being accessed in a C++ application in using OpenCV in a Windows 7 environment.</p> <p><strong>Update</strong></p> <p>I have looked at a wikipedia article regarding this information and attempted to use the formula in my application. Below is the code block with the output received from it. Any advice is greatly appreciated.</p> <pre><code>BYTE* pData; videoFrame-&gt;GetBytes((void**)&amp;pData); m_nFrames++; printf("Num Frames executed: %d\n", m_nFrames); for(int i = 0; i &lt; 1280 * 720 * 3; i=i+3) { m_RGB-&gt;imageData[i] = pData[i] + pData[i+2]*((1 - 0.299)/0.615); m_RGB-&gt;imageData[i+1] = pData[i] - pData[i+1]*((0.114*(1-0.114))/(0.436*0.587)) - pData[i+2]*((0.299*(1 - 0.299))/(0.615*0.587)); m_RGB-&gt;imageData[i+2] = pData[i] + pData[i+1]*((1 - 0.114)/0.436); } </code></pre> <p><img src="https://i.stack.imgur.com/WBGzS.png" alt="Attempted RGB conversion"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload