Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change BGR to RGB of a video frame using C

Webcam feed reads as a inverted RGB and so the rendered colors are incorrect. I need to change BGR to RGB. Below shows incomplete code of trying to achieve the end result. Can someone guide me through this to complete? Currently using OoenCV 2.xx

GdkPixbuf* pix;
IplImage* frame;
CvCapture* capture;

frame = cvQueryFrame( capture );

// Converting BGR to RGB
for (int i = 0; i<frame->height; i++)
{
    for (int x=0; x<frame->width; x++)
    {
        // LOST
    }
}

pix = gdk_pixbuf_new_from_data((guchar*) frame->imageData,
       GDK_COLORSPACE_RGB, FALSE, frame->depth, frame->width,
       frame->height, (frame->widthStep), NULL, NULL);

How to change BGR to RGB of a video frame using CC /C++

Webcam feed reads as a inverted RGB and so the rendered colors are incorrect. I need to change BGR to RGB. Below shows incomplete code of trying to achieve the end result. Can someone guide me through this to complete? Currently using OoenCV 2.xx

GdkPixbuf* pix;
IplImage* frame;
CvCapture* capture;

frame = cvQueryFrame( capture );

// Converting BGR to RGB
for (int i = 0; i<frame->height; i++)
{
    for (int x=0; x<frame->width; x++)
    {
        // LOST
    }
}

pix = gdk_pixbuf_new_from_data((guchar*) frame->imageData,
       GDK_COLORSPACE_RGB, FALSE, frame->depth, frame->width,
       frame->height, (frame->widthStep), NULL, NULL);

Edit: Its OK the same requirement is coded in C++