如何在Raspbian上编译和构建openCV

时间:2018-09-24 14:41:29

标签: opencv build compilation raspbian

我正在尝试在Raspbian上的本地文件夹中编译和构建OpenCV 2.4.13.6。

我做到了

cmake -D CMAKE_INSTALL_PREFIX=./ - DCMAKE_BUILD_TYPE=Debug ../
make -j4
make install

但是,构建目录中的模块文件夹不存在(例如,找不到核心模块的文件core_c.h)。因此,我尝试重新运行make install,但是失败了。我又走了一步,然后重新运行cmake ..。我注意到它警告我许多无法找到的软件包,例如gtk+-2.0 gthread g-streamer等。

我应该安装这些软件包以手动构建opencv吗?

1 个答案:

答案 0 :(得分:1)

是的,尽管您要求使用OpenCV 2,但在编译OpenCV之前需要手动安装依赖项,here可以找到Raspbian依赖项的示例列表。直接引用给定链接:

步骤1:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rpi-update (can be skipped, but recommended) (don't do it if you will use the RPI cam as recommended by official RPI Website)
$ sudo reboot now

步骤2:

$ sudo apt-get install build-essential cmake pkg-config

步骤3:

$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev

步骤4:

$ sudo apt-get install libgtk2.0-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libv4l-0 libv4l-dev

步骤5:

$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev

步骤6:

$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python-numpy python-scipy python-matplotlib
$ sudo apt-get install default-jdk ant
$ sudo apt-get install libgtkglext1-dev
$ sudo apt-get install v4l-utils

步骤7:

安装点子

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

步骤8:

$ sudo apt-get install python2.7-dev

步骤9:

$ sudo pip install numpy