Pau*_*bel 4 python opencv raspberry-pi
我已经尝试了很多天在我的 Raspberry Pi 4 上使用 Raspbian Buster 安装 OpenCV,但我无法完成。安装在大多数情况下都有效,但在导入或使用 cv2.imshow() 等 cv2 方法时,会出现错误(见下文)。
有人让 OpenCV 在 Raspberry Pi 4 上工作,或者知道如何让它工作?预先感谢您的帮助 :-)!
用pip安装OpenCV后报错:
pip install opencv-python
pip install opencv-contrib-python
python
>>> import cv2
ImportError: libImath-2_2.so.12: cannot open shared object file: no such file or directory
Run Code Online (Sandbox Code Playgroud)
我无法安装这个库“libImath-2_2.so.12”。错误仍然存在。
使用 conda 安装 OpenCV 后出错:
conda install -c conda-forge opencv
conda install -c conda-forge opencv=4.1.0
conda install -c menpo opencv
python
>>> import cv2
>>> img = cv2.imread("image.png", 0)
>>> cv2.imshow("Frame", img)
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 /home/jhelmus/conda/conda-bld/opencv_1512174356192/work/modules/highgui/src/window.cpp, line 605
Traceback (most recent call last):
File "detect_video.py", line 113, in <module>
cv2.imshow("Frame", img_main)
cv2.error: /home/jhelmus/conda/conda-bld/opencv_1512174356192/work/modules/highgui/src/window.cpp:605: 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
Run Code Online (Sandbox Code Playgroud)
我检查了库 libgtk2.0-dev 和 pkg-config 已经安装。我不知道如何以一种使其工作的方式“在函数 cvShowImage 中配置脚本”。
通过编译安装 OpenCV 后出错
我经历了这两个指南中描述的编译过程。这些指南适用于我的 Raspberry Pi 3b,但不适用于我的 Raspberry Pi 4:
我能够使用 make、sudo make install 等完成编译。之后虽然我现在仍然需要将 openCV 安装链接到我的 Python 绑定。使用cmake命令我设置了以下路径:
/home/pi/miniconda3/bin/python3 (ver 3.5.6)lib/python3.5/dist-packages /usr/bin/python2.7我现在如何访问 OpenCV,如何将其链接到 Python 以便我可以将其作为 cv2 导入?
预先感谢您的帮助 :-)!
保罗
在@Ingo 的帮助下,我终于能够在 Raspbian Buster 上安装 OpenCV,其解决方案比预期的要简单得多:
只需运行sudo apt install python3-opencv,它就会工作,并且还可以使用 cv2.imshow() 创建窗口。