I’m attempting to produce a demosaiced RGB image from a RAW8 UVC stream. The RAW8 data is stored on the G channel of the incoming VideoCapture. I’ve tried many different permutations, but the result of OpenCV’s demosaicing algorithm always generates a grayscale image.
#include <iostream>
#include <opencv2\opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
namedWindow("Debayer Test");
Mat image;
Mat channels[3];
VideoCapture cap(0);
if (!cap.isOpened())
{
cout << "cannot open camera";
}
while (true)
{
cap >> image;
split(image, channels);
Mat output(image.size(), image.type());
demosaicing(channels[1], output, COLOR_BayerBG2BGR);
imshow("Demosaic Result", output);
waitKey(25);
}
return 0;
}
Any suggestions? Even if I’ve selected the wrong Bayer pattern, I’d expect the result of ‘demosicing’ to be full-color (albeit incorrectly mapped).