Ask Your Question

12 bits RAW data output camera sensor, how to get raw stream by opencv?

asked 2018-09-06 02:07:32 -0500

I bought a RAW data output camera sensor, it's data sheet on this website.

Then i prepare to get raw stream by opencv,

simple code like this:

int main() { 
    VideoCapture cap(0);
    int Key;
    Mat src;
    if (cap.isOpened()) {
        namedWindow("capture", 0);
        imshow("capture", src);

But a problem occurred, the raw data resolution should be 1312x992, however, the imshow image's resolution is 320x240! And color is abnormal. The screensaver blow:

image description

I don't know how to fix the resolution problem and color problem.

So if anybody can help me. Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-09-06 05:04:03 -0500

kbarni gravatar image

updated 2018-09-06 05:13:55 -0500

From the cheat sheet:

SDK Supported

  • Camera Tool Source Code in C#
  • Capture & Display
  • OpenCV supported through Emgu
  • RAW to RGB Conversion
  • Save file as BMP & RAW format
  • Color matrix

The image you posted ressembles a lot to the green "RAW" image from the cheat sheet, so what you are doing seems to be OK.

So just use the SDK to convert the RAW image to RGB, then you can continue with OpenCV.

The only inconvenience is that according to the cheat sheet, the SDK is using C# (and the Emgu C# wrapper for OpenCV), not C++. If you prefer C++, you can try to port the RAW->RGB conversion routine from C#, as the SDK is open-source.

This solution has the advantage that you can try to to convert the 12 bit image to 16 bits (CV_16UC3), not losing the additional color depth resolution (however I would suggest to pass to 8 bits/channel, as it should be more than enough to most applications; the images will be smaller, the processing faster, and most OpenCV routines take 8 bit images).

[EDIT] Take a look at this open source driver for Leopard Imaging cameras - with C++/OpenCV support. Maybe it will need modifications, as it was written for USB30-M021 cameras. It contains also the RAW (Bayer) -> RGB conversion function.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-09-06 02:07:32 -0500

Seen: 246 times

Last updated: Sep 06 '18