玩转rk3588(五):rk3588+openEuler 指定python环境编译安装opencv

目录

0、前言

1、开发环境

2、安装opencv

下载opencv

 cmake

  make -j8

  sudo make install

配置环境

3、相关报错

1)c++: fatal error: Killed signal terminated program cc1plus

2)执行 pkg-config 不生效

 opencv 没有生成opencv.pc情况下(建议自动生成)

 opencv 配置后,pkg-config不生效 (采用 -D OPENCV_GENERATE_PKGCONFIG=YES 生成opencv.pc)

3) cv2.VideoCapture(self.rtsp),ret, frame = self.cap.read() 获取不到数据

安装ffmpeg(建议添加x264、libdrm依赖,后续视频硬解码有用到)

编译后仍然未成功:OpenCV可能会找不到ffmpeg


0、前言

conda或pip在rk3588+openEuler上可以成功安装的opencv,但是在运行opencv+qt5程序时及其不稳定(程序不能启动或者运行过程中出错)

报错如下:

QObject::moveToThread: Current thread (0xaaaabbfcaa50) is not the object's thread (0xaaaabcba4cd0).
Cannot move to target thread (0xaaaabbfcaa50)

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/userdata/xxx/miniforge3/envs/xxx/lib/python3.7/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, eglfs, minimal, minimalegl, offscreen, vnc, webgl.

 通过查找资料,尝试了网上各种可行的方法仍然不能解决,于是尝试编译安装opencv,问题得到解决。

1、开发环境

开发环境 软件版本/配置
开发板 firefly rk3588J 
操作系统

openEuler 20.03 LTS

python版本 3.9.18
opencv版本 4.7.0

2、安装opencv

  • 下载opencv

Release 4.7.0 · opencv/opencv_contrib · GitHub

Release OpenCV 4.7.0 · opencv/opencv · GitHub

将 opencv-4.7.0.zip 和 opencv_contrib-4.7.0.zip 放在同一文件夹并解压,将解压后的opencv_contrib-4.7.0放在opencv-4.7.0文件中!

玩转rk3588(五):rk3588+openEuler 指定python环境编译安装opencv_第1张图片

cd opencv-4.7.0
mkdir build
cd build
  •  cmake

下面并没有配置ffmpeg,导致opencv无法获取网络摄像头视频,文章后面有说明,建议参考章末cmake配置。

	cmake -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/userdata/local/opencv \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -

你可能感兴趣的:(rk3588,python,opencv,开发语言)