本文介绍了在LMDE2(Debian 8.2)上使用OpenGL和GTK构建OpenCV 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用cmake -DWITH_OPENGL=ON ..构建了opencv,但是cmake的输出告诉我所支持的OpenGL是.

I've built the opencv with cmake -DWITH_OPENGL=ON .., but the output of the cmake tell me the OpenGL supported is NO.

我已经检查了cmake缓存以确保WITH_OPENGLON.

And I've checked the cmake cache to assure the WITH_OPENGL is ON.

使用的GUI是GTK + 3.0,并且已安装 libgtkglext1-dev .

The GUI used is GTK+ 3.0, and the libgtkglext1-dev is installed.

推荐答案

阅读cmake脚本cmake/OpenCVFindLibsGUI.cmake之后,我发现了相关的cmake代码:

After reading the cmake script cmake/OpenCVFindLibsGUI.cmake, I've found the related cmake codes:

# --- GTK ---
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT)
  # ...
  if(WITH_OPENGL AND NOT HAVE_GTK3)
    CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT) # MARK1
  endif()
endif()

# --- OpenGl ---
ocv_clear_vars(HAVE_OPENGL HAVE_QT_OPENGL)
if(WITH_OPENGL)
  if(WITH_WIN32UI OR (HAVE_QT AND QT_QTOPENGL_FOUND) OR HAVE_GTKGLEXT) # MARK2
    find_package (OpenGL QUIET)
  # ...
  endif ()
endif(WITH_OPENGL)

因为我使用的是GTK + 3.0,所以将不会执行标记为MARK1的语句,因此标记为MARK2的条件将为false.因此将不会加载OpenGL软件包.

For I use the GTK+ 3.0, so the statement marked with MARK1 will not be executed, then the condition marked with MARK2 will be false. So the OpenGL package will not be loaded.

即使HAVE_GTK3为true,我也试图强制调用CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT),但是最后发现编译错误.

I've also tried to force to call CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT) even when HAVE_GTK3 is true, but I found compiling compiling error at last.

所以我如下更新我的建筑命令

So I update my building command as below

cmake -DWITH_OPENGL=ON -DWITH_GTK_2_X=ON ..

WITH_GTK_2_X设置为打开,将强制使用gtk2而不是gtk3.

With WITH_GTK_2_X to be set on, the gtk2 is force to be used instead of gtk3.

这篇关于在LMDE2(Debian 8.2)上使用OpenGL和GTK构建OpenCV 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 21:24