Ask Your Question

GTK or QT when build OpenCV

asked 2019-07-02 01:19:51 -0600

opencvddddd gravatar image

I think HighGui should call some GUI library to draw windows when build OpenCV, there are some 3rd party libraries we could choose, should we choose GTK or QT? Which one is more appropriate, efficient.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-07-02 05:27:24 -0600

kbarni gravatar image

I recommend to use the QT library which is much more efficient.

The GTK window is very basic, it displays only a window containing the image. You get the different window modes; trackbars and the mouse callback, and that's all.

With QT you have many useful extra functions, like window toolbar and menu; status bar with mouse coordinates and pixel value; display overlay; and a control panel - a small window where you can add your own custom controls (buttons, check boxes, etc).

So the GTK interface is OK if you only need to display an image, and you don't need any interactions. The QT bindings provide a real user interface. So unless you have some serious limitations or a strong reason for GTK, I suggest to use QT.

Note that the OpenCV - QT bindings are still quite basic; so for a serious product I suggest to develop your own interface. You will find in the forum several posts about transforming OpenCV Mat variables to QImage and integrate them into a custom QT interface.

edit flag offensive delete link more


You also avoid protobuf version issues when opting for Qt over gtk.

Der Luftmensch gravatar imageDer Luftmensch ( 2019-07-02 06:47:59 -0600 )edit

I am also wondering since both GTK and QT are optional when build, if we turn off both MACRO, what would highgui use?

opencvddddd gravatar imageopencvddddd ( 2019-07-02 11:54:39 -0600 )edit

I had a build that I didn't enable gtk or qt. When I tried to use cv::imshow, it still compiled but it threw an error saying I needed to build with gtk or some other options. It'd be nice if at least gtk was enabled by default so that you didn't forget such a simple thing.

warpstar22 gravatar imagewarpstar22 ( 2020-08-06 15:52:05 -0600 )edit

Question Tools

1 follower


Asked: 2019-07-02 01:19:51 -0600

Seen: 3,740 times

Last updated: Jul 02 '19