Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Demosaicing c++

Hello,

I have some issue using opencv 4.5 for demosaicing my image.

My CFA starts with GR pixels. I get it from my camera. Now I try to debayer to display the RGB picture only using opencv.

// Get Picture, each composant is 8bit, stored in uint8_t buffer
frame.rightPicture().getPixels8bits(bufSize, imgBuf);
// Store it in Mat object
cv::Mat inputBufMat(h, w, CV_8U, cv::Scalar::all(0));
inputBufMat = cv::Mat(h, w, CV_8U, imgBuf);

// Should I convert it to BGR first ? 
cv::Mat outputBufMat(h, w, CV_8U, cv::Scalar::all(0));
cv::cvtColor(inputBufMat, outputBufMat, cv::COLOR_RGB2BGR); // ????

//Demosaice
cv::Mat imgDebayer(h, w, CV_8U, cv::Scalar::all(0));
cv::demosaicing(outputBufMat, imgDebayer, cv::COLOR_BayerGR2BGR_EA); // ERROR

demosaicing function triggers exception. What I have done wrong? Is it the correct way to do it?

Demosaicing c++

Hello,

I have some issue using opencv 4.5 for demosaicing my image.

My CFA starts with GR pixels. pixels then second line BG as follows: G R G R... B G B G...

I get it from my camera. Now I try to debayer to display the RGB picture only using opencv.

// Get Picture, each composant is 8bit, stored in uint8_t buffer
frame.rightPicture().getPixels8bits(bufSize, imgBuf);
// Store it in Mat object
cv::Mat inputBufMat(h, w, CV_8U, cv::Scalar::all(0));
inputBufMat = cv::Mat(h, w, CV_8U, imgBuf);

// Should I convert it to BGR first ? 
cv::Mat outputBufMat(h, w, CV_8U, cv::Scalar::all(0));
cv::cvtColor(inputBufMat, outputBufMat, cv::COLOR_RGB2BGR); // ????

//Demosaice
cv::Mat imgDebayer(h, w, CV_8U, cv::Scalar::all(0));
cv::demosaicing(outputBufMat, imgDebayer, cv::COLOR_BayerGR2BGR_EA); // ERROR

demosaicing function triggers exception. What I have done wrong? Is it the correct way to do it?

Demosaicing c++

Hello,

I have some issue using opencv 4.5 for demosaicing my image.

My CFA starts with GR pixels then second line BG as follows: follows:

G R G R... R...

B G B G...

I get it from my camera. Now I try to debayer to display the RGB picture only using opencv.

// Get Picture, each composant is 8bit, stored in uint8_t buffer
frame.rightPicture().getPixels8bits(bufSize, imgBuf);
// Store it in Mat object
cv::Mat inputBufMat(h, w, CV_8U, cv::Scalar::all(0));
inputBufMat = cv::Mat(h, w, CV_8U, imgBuf);

// Should I convert it to BGR first ? 
cv::Mat outputBufMat(h, w, CV_8U, cv::Scalar::all(0));
cv::cvtColor(inputBufMat, outputBufMat, cv::COLOR_RGB2BGR); // ????

//Demosaice
cv::Mat imgDebayer(h, w, CV_8U, cv::Scalar::all(0));
cv::demosaicing(outputBufMat, imgDebayer, cv::COLOR_BayerGR2BGR_EA); // ERROR

demosaicing function triggers exception. What I have done wrong? Is it the correct way to do it?