Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert 12-bit Bayer image to 8-bit RGB using OpenCV
    primarykey
    data
    text
    <p>I am trying to use OpenCV 2.3.1 to convert a 12-bit Bayer image to an 8-bit RGB image. This seems like it should be fairly straightforward using the cvCvtColor function, but the function throws an exception when I call it with this code:</p> <pre><code>int cvType = CV_MAKETYPE(CV_16U, 1); cv::Mat bayerSource(height, width, cvType, sourceBuffer); cv::Mat rgbDest(height, width, CV_8UC3); cvCvtColor(&amp;bayerSource, &amp;rgbDest, CV_BayerBG2RGB); </code></pre> <p>I thought that I was running past the end of sourceBuffer, since the input data is 12-bit, and I had to pass in a 16-bit type because OpenCV doesn't have a 12-bit type. So I divided the width and height by 2, but cvCvtColor still threw an exception that didn't have any helpful information in it (the error message was "Unknown exception").</p> <p>There was a <a href="https://stackoverflow.com/questions/7598854/how-do-i-convert-bayer-to-rgb-using-opencv-and-vice-versa">similar question</a> posted a few months ago that was never answered, but since my question deals more specifically with 12-bit Bayer data, I thought it was sufficiently distinct to merit a new question.</p> <p>Thanks in advance.</p> <p><strong>Edit</strong>: I must be missing something, because I can't even get the cvCvtColor function to work on 8-bit data:</p> <pre><code>cv::Mat srcMat(100, 100, CV_8UC3); const cv::Scalar val(255,0,0); srcMat.setTo(val); cv::Mat destMat(100, 100, CV_8UC3); cvCvtColor(&amp;srcMat, &amp;destMat, CV_RGB2BGR); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

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