I am working with a custom USB camera which sends raw Bayer BGGR 16 bit/pixel images. I have a C++ project which is able to show the camera stream in grayscale, but when I try to use any of the OpenCV's built in color conversion function I always got misscolored images. I checked the camera picture and also with the sensor test pattern feature. I tried demosaicing the picture manually, only got greenish distorted pictures. I tried to learn more about the bayer/raw images, but now I am a bit stuck and would be glad for any kind of help or hint. It is also looks strange for me, when I check the type and channels of the input videocapture frame It has 8bit 3 channel, even if try to turn of the RGB conversion. I attached the actuall outputs.
Grayscale test pattern:
COLOR_BayerRG2RGB:
Manual demosaic:
Gray camera picture:
COLOR_BayerRG2RGB:
Manual demosaic:
Try
cv::COLOR_BayerGB2BGR
instead ofcv::COLOR_BayerRG2RGB
.OpenCV supports 4 bayer patterns:
So either your pattern (BGGR) correlates to
cv::COLOR_BayerGB2BGR
, or it could be that you actually have one of the other patterns.Anyway a quick test will determine it.