Skip to content

WxOpenCv

WxOpenCv is a simple demo application to show you how to integrate wxWidgets with OpenCV library. The application take the video stream from a camera and displays it a window. Also, it adds a green rectangle to every frame and shows you how many frames per second you receive. Aditionaly, I did a small hack to provide access to the system/driver control parameters of the camera. Note, that this might not be the best optimization of the speed or resources as this is not a scope of this project. The image bellow represents a snapshot of the application running.

cv::Mat to wxImage

All you need to to do is to convert from grayscale to RGB. (Actually, to BGR, if you're on Windows)

cv::Mat grayOutput, rgbOutput;
pictureMatrix.convertTo(grayOutput,CV_8U);
cvtColor(grayOutput, rgbOutput, CV_GRAY2BGR); // note the BGR here. 
//If on linux, set as RGB
wxImage test(rgbOutput.rows, rgbOutput.cols, rgbOutput.data, true);

Favorite site