Ask Your Question
1

How to build OpenCV-2.4.13 with GTK3+?

asked 2017-02-16 08:49:19 -0600

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.

edit retag flag offensive close merge delete

Comments

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

G10DRAS gravatar imageG10DRAS ( 2017-02-18 08:41:46 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2017-11-10 04:32:02 -0600

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

edit flag offensive delete link more
0

answered 2017-02-17 04:33:51 -0600

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?

edit flag offensive delete link more
0

answered 2017-02-19 03:16:03 -0600

updated 2017-02-19 03:25:30 -0600

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.

edit flag offensive delete link more

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 ( 2017-02-19 03:24:40 -0600 )edit

Yo! looks better.

G10DRAS gravatar imageG10DRAS ( 2017-02-19 03:31:01 -0600 )edit

may be you can try an issue or Pull Requests

LBerger gravatar imageLBerger ( 2017-02-19 06:00:52 -0600 )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 ( 2017-02-19 07:48:08 -0600 )edit

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

jimmychauck gravatar imagejimmychauck ( 2017-08-04 21:15:06 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-16 08:49:19 -0600

Seen: 5,815 times

Last updated: Feb 19 '17