12

Can I use OpenCV to create GUIs that contain buttons, list boxes, ...etc for example?

Thanks.

Simplicity
  • 47,404
  • 98
  • 256
  • 385
  • 1
    This is a frustrating limitation of OpenCV. highGUI is almost everything you need for a gui, but not quite. See my related SO question: http://stackoverflow.com/q/5874305/200688 – AndyL Jul 26 '11 at 14:40

4 Answers4

13

OpenCV has highgui built-in for making GUIs.

You can find online tutorials to get you started.

Note that this is not an extensive GUI library. You can only do basic stuff like opening windows, drawing points, anti-aliased lines, rectangles and text. There is a slider widget that can be used as a on-off button. If you need more than that, you can either

  • build stuff yourself (for instance drawing a rectangle with text to make your own button), or
  • use another library like Qt which provide plenty of widgets (buttons, menus, lists, dialogs…)

Good luck if you go for the first one!

Simon
  • 31,675
  • 9
  • 80
  • 92
  • Thanks for your reply. I know about `Highgui` and searched for examples, but couldn't find what I asked about. – Simplicity Jul 25 '11 at 23:33
  • 4
    HighGUI is very limited and **should not** be used for constructing GUIs. It's main purpose is to display images/video frames, and if you need anything slightly more complex than that you'll need to find a 3rd party library for that (Qt, wxWidgets, ...). – karlphillip Jul 26 '11 at 13:49
7

In the Learning OpenCV, the following title is mentioned in page 101: No Buttons.

And, this is some what is mentioned under this title:

Unfortunately, HighGUI does not provide any explicit support for buttons. It is thus common practice, among the particularly lazy, to instead use sliders with only two positions. Another option that occurs oft en in the OpenCV samples in …/opencv/ samples/c/ is to use keyboard shortcuts instead of buttons (see, e.g., the fl oodfi ll demo in the OpenCV source-code bundle).*

Simplicity
  • 47,404
  • 98
  • 256
  • 385
4

On windows, you may use cvGetWindowHandle to obtain window handle (HWND). With that handle you may call CreateWindow from WinAPI and put WinAPI controls on that window.

But you will also need to override or hook the WindowProc that was set by OpenCV for that window. Hooking and overriding explained here Multiple WndProc functions in Win32

Community
  • 1
  • 1
4

Along with the highgui functions that Simon has pointed out, others have used OpenCV in conjunction with Qt. It is possible to translate the camera frames into images on a QLabel widget, and update the image on the label periodically.

jonsca
  • 10,218
  • 26
  • 54
  • 62