开发者

Display opencv frames in a window with button and text control

I'd like to ask you some information about a problem which i want to solve.

At the moment, I have two opencv applications:

  • application A: where i track an object with two types of algorithms and each time i save a frame in an image file and i control the application behavior with some commands which i write in the shell

  • application B: where i have a loop which reads every time the image file and display it So, I launch these two applications together in order to track the object with appA and to display results with appB which reads everytime the frames saved by appA in the hard disk.

I want to integrate application B in application A in order to show a window (like this: http://lnx.mangaitalia.net/window.jpg) in order to have a loop which shows image in the first area and to use buttons in order to give commands which at the moment i write in the shell.

Do you think it's possible to display the frames in an area with Qt or opengl or wxwidgets?

Which solution is the better and the easier to apply?

At the moment, my application B is very simple:

 while(1)
{
    Mat img=imread("result.jpg",1);
    if(!img.empty())
        imshow("HOG",img);
    if(waitKey(200)==27) break;
}开发者_运维技巧

I want to show these frames in a window which has also some buttons. In particular, as you can see in the attached image in this post, i want to create a window divided in two parts: the first one which display the frames captured from opencv camera and the second part (or area) which has some buttons (B1, B2, B3..) which the user can press in order to control the application behavior. (At the moment, i use a switch/case in appA to trap the keyboard keys)

There is some example based on a template similar to what i'd like to do? (like the jpg image i've told before: http://lnx.mangaitalia.net/window.jpg)


I propose that you just use the inbuilt GUI in OpenCV: highgui. It has keyboard/mouse IO, window control with a message loop, buttons, sliders etc. And there is no need to do any conversions of the cv images to show them.

Have a look at: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut3.html (It is written for old IplImage style CV, but the C++ interface is almost the same, use cv::imshow to draw images)

Also, here is the documentation for the C++ style interface.

There is also the possibility to convert your CV images to QImage in Qt and do it that way... you should be able to find solutions for that on Google.


There are some examples out there for implimenting this.

see http://larryo.org/work/information/wxopencv/index.html

Basically what you want to do is:

  • capture a frame from your camera
  • manipulate the image
  • use cvConvertImage to convert it into a format wxImage can read
  • draw this image on to a wxCanvas

For the GUI part of this, you would need to create a wxFrame or wxWindow, place some sizers and buttons at appropriate places.

So basically make a frame, put a sizer on the frame, then put a panel in the sizer. next make a vertical sizer on the panel. First add a wxCanvas to the vertical sizer, then place a horizontal sizer in the vertical sizer. Now add 3 buttons to the horizontal sizer, and you have your panel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜