我的代码:
import cv2
import numpy
import matplotlib
img=cv2.imread('square1.png')
cv2.imshow('FRAME',img)
cv2.waitKey()
错误讯息:
Traceback (most recent call last):
File "/Users/tusharsharma/Desktop/image project/test1.py", line 5, in <module> cv2.imshow('FRAME',img)
cv2.error: /Users/travis/build/skvark/opencv-python/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
操作系统是macOS Sierra。我使用自制软件为Python 3安装了OpenCV。
答案 0 :(得分:1)
您可以查看这些教程,以解决为OpenCV 3
Python 3
安装macOS
的问题。
希望得到这个帮助。
答案 1 :(得分:0)
主要问题是配置OpenCv2的构建,确保输入python库和Header文件的正确部分
例如,以下命令适用于OpenCv for Python 3.6.1
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/config-3.4m/libpython3.4.dylib \
-D PYTHON3_LIBRARIES=/Library/Frameworks/Frameworks/Python.framework/Versions/3.4/bin \
-D PYTHON3_INCLUDE_DIR=/Library/Frameworks1/Frameworks/Python.framework/Versions/3.4/Headers \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..