Ask Your Question
1

How to build OpenCV-2.4.13 with GTK3+?

asked Feb 16 '17

I have tried following cmake command :

cmake -D WITH_GTK3=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..

but I got following warning :

CMake Warning: Manually-specified variables were not used by the project: WITH_GTK3

Is it possible to build OpenCV-2.4.13 with GTK3+ support ? I am try to build it on Raspbian Jessie on Raspberry Pi 2 B.

Preview: (hide)

Comments

Seems OpenCV-2.4.13 is not supporting GTK+3.x.

G10DRAS gravatar imageG10DRAS (Feb 18 '17)edit

3 answers

Sort by » oldest newest most voted
0

answered Nov 10 '17

GTK+ 3 seems to be supported only with opencv >= 3.0.0. See the GTK+ detection code in cmake/OpenCVFindLibsGUI.cmake.

Preview: (hide)
0

answered Feb 17 '17

As far as I know, there is no GTK3 flag available in de CMAKE config yet, at least not in the visual one.

image description

But after digging around in the code I found out that you need to make sure Qt is disabled before GTK3 support is possible. Can you make sure that is true?

Preview: (hide)
0

answered Feb 19 '17

updated Feb 19 '17

I further dig in to cmake and src code of opencv-2.4.13. Did some changes and finally able to compile opencv-2.4.13 with GTK+3.0. Now my application is running with opencv-2.4.13 and GTK+3.0.

To compile code with GTK+3.0 do following changes:

  1. ~/opencv-2.4.13/cmake/OpenCVFindLibsGUI.cmake

change gtk+-2.0 ===> gtk+-3.0

--- GTK ---

ocv_clear_vars(HAVE_GTK HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT)
  CHECK_MODULE(gtk+-3.0 HAVE_GTK)
  CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
  if(WITH_OPENGL)
    CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
  endif()
endif()
  1. Use attached opencv-2.4.13/modules/highgui/src/window_gtk.cpphttps://drive.google.com/open?id=0Bzm...

and thats all. follow rest of the steps as usual.

Preview: (hide)

Comments

1

I think it is better like this :

CHECK_MODULE(gtk+-3.0 HAVE_GTK)
if(NOT HAVE_GTK)
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
endif()
LBerger gravatar imageLBerger (Feb 19 '17)edit

Yo! looks better.

G10DRAS gravatar imageG10DRAS (Feb 19 '17)edit

may be you can try an issue or Pull Requests

LBerger gravatar imageLBerger (Feb 19 '17)edit
1

Well, I think it is just an Hack, not a proper solution. I will test all my OpenCV code first and then decide on pull request. So far I got one error with GTK+3.0.

""GTK apps crashing with "Attempt to unlock mutex that was not locked"".

I need to comment out cv2.startWindowThread() in my code. Not sure if there are more.

G10DRAS gravatar imageG10DRAS (Feb 19 '17)edit

Impressive G10DRAS, May I know how did you work out the new window_gtk.cpp?

jimmychauck gravatar imagejimmychauck (Aug 5 '17)edit

Question Tools

1 follower

Stats

Asked: Feb 16 '17

Seen: 6,168 times

Last updated: Feb 19 '17