Python 使用opencv读取图像

Python 使用opencv读取图像,python,opencv,Python,Opencv,我试图运行一个眼睛状态检测的演示项目,我得到了以下错误 python -m demo --process image --path /home/samuel/Pictures/download.jpeg --json_path /home/samuel/EyeStateDetection/models/model.json --weights /home/samuel/EyeStateDetection/models/model.h5 /home/samuel/anaconda3/lib

我试图运行一个眼睛状态检测的演示项目,我得到了以下错误

    python -m demo --process image --path /home/samuel/Pictures/download.jpeg --json_path /home/samuel/EyeStateDetection/models/model.json --weights /home/samuel/EyeStateDetection/models/model.h5
/home/samuel/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
(183, 275, 3)
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 /tmp/build/80754af9/opencv_1512687413662/work/modules/highgui/src/window.cpp, line 611
Traceback (most recent call last):
  File "/home/samuel/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/samuel/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/samuel/EyeStateDetection/demo/__main__.py", line 19, in <module>
    main()
  File "/home/samuel/EyeStateDetection/demo/__main__.py", line 15, in main
    image_demo(json_path,weights,image_path)
  File "/home/samuel/EyeStateDetection/demo/__init__.py", line 372, in image_demo
    cv2.imshow("Image",img)
cv2.error: /tmp/build/80754af9/opencv_1512687413662/work/modules/highgui/src/window.cpp:611: 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

错误出现在
cv2.imshow(“图像”,img)

您没有安装GTK。GTK负责在使用
imshow()
时显示图像界面。如果您正在运行Ubuntu,请使用

sudo apt-get install libgtk-3-dev
有关OpenCV的完整安装说明,请参阅

另外,如果要使用
imshow()
,还需要使用
cv2.waitKey()

sudo apt-get install libgtk-3-dev