Ask Your Question

Magicbean's profile - activity

2018-07-30 04:38:22 -0600 received badge  Notable Question (source)
2018-03-04 09:45:47 -0600 received badge  Popular Question (source)
2014-05-23 07:42:11 -0600 asked a question How do I capture, process and output an image in RGB (not BGR)?

I have read that opencv captures images in BGR rather than RGB. In my first experiments I am capturing a video image and output it as follows:

(C++ code snippet - error checking and control flow left out for clarity):

Mat frame;
VideoCapture capture(0);

capture >> frame;
/* some processing code here*/
imshow(window_name, frame);

The code works except that the capture works in BGR and the output of imshow() is RGB which means that the red and blue channels are swapped in the display.

So... I can work with data in BGR but I would like to know if it is possible to a) capture in RGB (like raspistill does) or b) convert to RGB before display without a nested loop to convert each pixel?

(This is running on a Raspberrry Pi with opencv 2.3.1 and the Video4Linux2 Driver v1.9.8 in case it makes any difference).

Thanks.