我尝试了一些试验.. 我建立
cmake -D CMAKE_BUILD_TYPE = RELEASE -D CMAKE_INSTALL_PREFIX = / usr / local -D WITH_TBB = ON -D BUILD_NEW_PYTHON_SUPPORT = ON -D WITH_V4L = ON -D INSTALL_C_EXAMPLES = ON -D INSTALL_PYTHON_EXAMPLES = ON -D BUILD_EXAMPLES = ON -D WITH_QT = ON -D WITH_GTK = ON -D WITH_OPENGL = ON ..
如果我尝试使用python:
导入cv2
打印(CV2 版本)
3.2.0
我的完整代码: (https://www.solarianprogrammer.com/2016/09/17/install-opencv-3-with-python-3-on-windows/)
import cv2
image = cv2.imread("/home/reigin/Pictures/games.jpg")
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow("Over the Clouds", image)
cv2.imshow("Over the Clouds - gray", gray_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
我收到了错误:
cv2.imshow("Over the Clouds", image)
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 583
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: /io/opencv/modules/highgui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
我设置了我的dpk-configure:
reigin@reigin-K43SA:~$ echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig
如果我做的除了显示我的图像没有任何问题..
无法帮助:
opencv 3.0 python imshow error
http://vinllen.com/solve-error-libgtk2-0-dev-and-pkg-config-when-install-opencv/
http://answers.opencv.org/question/57945/opencv-gui-with-gtk-2-solved/
https://askubuntu.com/questions/210210/pkg-config-path-environment-variable
感谢您的关注和帮助......
答案 0 :(得分:1)
您可能正在使用不支持GTK的pip opencv-python。你的python绑定必须来自你的opencv构建。
检查你的/usr/local/lib/python2.7/site-packages/
文件夹并确保你的编译和安装opencv有一个cv2.so
文件,并且你没有在{{1}中使用pip的opencv-python中的软件包}。
见这里:http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/
这是我准备安装的Cmake系列:
dist-packages
请注意,这假设您已经通过sudo apt-get install libgtk2.0-dev安装了相应的libgtk。
这就是CMake应该吐出的东西:
- GUI:
- QT:否
- GTK + 2.x:是(版本2.24.30)
- GThread:YES(版本2.48.2)
- GtkGlExt:是(版本1.2.0)
- OpenGL支持:YES(/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
- VTK支持:是(版本6.2.0)