树莓派3 opencv c语言,树莓派安装opencv3的问题及解决方式

本文转载自

[子豪兄教你在树莓派上安装OpenCV] http://suo.im/5gS6if

[ubuntu16.04安装opencv3.4.1时出现: libgtk2.0-dev : 依赖: libgtk2.0-0 (= 2.24.23-0ubuntu1) ]https://blog.csdn.net/u014527548/article/details/80251046

[Linux配置Xming+[Putty, Xshell,SecureCRT] 本地显示X11转发图像]

https://blog.csdn.net/u010472607/article/details/80356216

这里我只描述安装opencv3过程中遇到的一些问题,详细步骤请参见转载的原文。

1、安装numpy

numpy是python的一个科学计算处理库,在图像处理过程中会很有用。

sudo pip3 install numpy

2.在树莓派设置中把根目录扩大到整个SD卡

这里详细见http://suo.im/5gS6if

3、安装OpenCV所需的库

这里需要格外注意这里的所有库都要确保安装上

sudo apt-get install build-essential git cmake pkg-config -y

sudo apt-get install libjpeg8-dev -y

sudo apt-get install libtiff5-dev -y

sudo apt-get install libjasper-dev -y

sudo apt-get install libpng12-dev -y

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y

sudo apt-get install libgtk2.0-dev -y

sudo apt-get install libatlas-base-dev gfortran -y

977a5dfa374e

QQ图片20181123233408.png

出现上图则说明安装成功。

Some packages could not be installed. This may mean that you have

requested an impossible situation or if you are using the unstable

distribution that some required packages have not yet been created

or been moved out of Incoming.

The following information may help to resolve the situation:

The following packages have unmet dependencies:

gstreamer0.10-ffmpeg : Depends: XXX but it is not going to be installed or

XXX but it is not going to be installed

E: Unable to correct problems, you have held broken packages.

出现上图中则说明出现了依赖性问题,解决方式(假设是libgtk2.0-dev出问题。其他同类问题方法类似换掉安装的库就行),运行后会出现一大堆消息,给出第一个解决方案一般是保留这些库文件,让选择y/n/q?,这里选择“n”;然后会继续找解决方案,有时会超时找不到,点击y继续找,直到给出得解决方案是“降级”这些库文件,选择“y”,然后等待结束就完了

sudo aptitude install libgtk2.0-dev

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/pi/Downloads/opencv_contrib-3.4.0/modules -D BUILD_EXAMPLES=ON -D WITH_LIBV4L=ON PYTHON3_EXECUTABLE=/usr/bin/python3.5 PYTHON_INCLUDE_DIR=/usr/include/python3.5 PYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.5m.so PYTHON3_NUMPY_INCLUDE_DIRS=/home/pi/.local/lib/python3.5/site-packages/numpy/core/include ..

其中的numpy路径需要查看自己自己安装numpy的位置,通常如下:

PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include

通过以上步骤一步一步的能够顺利的安装上opencv

最后在使用ssh远程运行opencv程序时如果出现图中使用cv2.imshow函数报错,且图片打不开时请按照此文

[Linux配置Xming+[Putty, Xshell,SecureCRT] 本地显示X11转发图像]

https://blog.csdn.net/u010472607/article/details/80356216解决

977a5dfa374e

QQ图片20181124000614.png

再次感谢下列这些文章对我在树莓派上安装opencv3的帮助,本次安装过程历时五天。。。呜呜。。。本文集中了此次安装过程中的一些主要问题,希望能减少大家的安装时间。

[子豪兄教你在树莓派上安装OpenCV] http://suo.im/5gS6if

[ubuntu16.04安装opencv3.4.1时出现: libgtk2.0-dev : 依赖: libgtk2.0-0 (= 2.24.23-0ubuntu1) ]https://blog.csdn.net/u014527548/article/details/80251046

[Linux配置Xming+[Putty, Xshell,SecureCRT] 本地显示X11转发图像]

https://blog.csdn.net/u010472607/article/details/80356216

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值