我正在尝试在运行Raspbian Jessie OS的RaspberryPi 3中安装openCV。我正在关注本教程: http://pklab.net/index.php?lang=EN&id=392
完成后:
sudo apt-get update
sudo apt-get upgrade
事情看起来很好。但是当我尝试安装cmake来构建我的opencv库时,输入以下命令后出现以下错误:
输入命令:
sudo apt-get install build-essential cmake cmake-curses-gui pkg-config
结果:
The following packages have unmet dependencies:
cmake : Depends: libjsoncpp0 but it is not installable
cmake-curses-gui : Depends: libjsoncpp0 but it is not installable
E: Unable to correct problems, you have held broken packages.
我似乎无法弄清楚出了什么问题。我尝试使用cmake网站上的镜像使用wget手动安装cmake,但仍然出现同样的错误。任何帮助表示赞赏!
答案 0 :(得分:1)
我不知道上述错误,但您可以按照Raspberry Pi中的以下步骤安装OpenCV。
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get -y install build-essential cmake cmake-qt-gui pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff5-dev libtiff5 libtiffxx0c2 libtiff-tools
$ sudo apt-get install libgtk2.0-dev
$ tar -xvjpf OpenCVXX( Download version for linux )
$ cd OpenCVXX/
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D
WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
$ make
$ make install
完成这项工作后,只需进行一些调整即可。以下命令将打开opencv.conf文件。
$ sudo nano /etc/ld.so.conf.d/opencv.conf
我们正在编辑bashrc文件; 在文件的末尾我们写了pkg-config的位置(你可以用echo $ PKG_CONFIG_PATH学习);
$ PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
OpenCV安装完成。
答案 1 :(得分:1)
安装open cv非常简单,只需这样做。
sudo apt-get update
sudo apt-get install -y build-essential git cmake pkg-config \
libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev libgtk2.0-dev \
libatlas-base-dev gfortran \
python2.7-dev python3-dev
然后
cd ~
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.0.0.zip
unzip opencv.zip
wget -O opencv_contrib.zip
https://github.com/Itseez/opencv_contrib/archive/3.0.0.zip
unzip opencv_contrib.zip
cd opencv-3.0.0/
mkdir build
cd build
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=~/opencv_contrib-3.0.0/modules \
-D BUILD_EXAMPLES=ON ..
make -j4
make clean
make
sudo make install
sudo ldconfig
这需要几个小时。
使用OpenCV提取功能 下载脚本和示例图像 cd~ wget https://raw.githubusercontent.com/JoBergs/RaspiContent/master/OpenCV_demo/opencv_face_features.py \ https://raw.githubusercontent.com/JoBergs/RaspiContent/master/OpenCV_demo/poi_1.jpg
运行脚本需要Raspbian Desktop。如果您尚未启动进入桌面,
打开终端并
cd ~
python opencv_face_features.py poi_1.jpg
答案 2 :(得分:0)
可以使用终端和以下命令或使用Synaptic Manager安装软件包:
[compiler] $ sudo apt-get install build-essential
[required] $ sudo apt-get install cmake git libgtk2.0-dev pkg-config
libavcodec-dev libavformat-dev libswscale-dev
[optional] $ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev
libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
获取最新的快照
$ cd ~/<my_working _directory>
$ git clone https://github.com/Itseez/opencv.git
<cmake_binary_dir>
,您要在其中放置生成的Makefile,项目文件以及目标文件和输出二进制文件。输入<cmake_binary_dir>
并输入
cmake [<some optional parameters>] <path to the OpenCV source directory>
例如
$ cd ~/opencv
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
输入创建的临时目录cmake_binary_dir
并继续:
$ make -j8 # -j8 runs 8 jobs in parallel.
# Change 8 to number of hardware threads available.
$ sudo make install
注意如果创建的库的大小是一个关键问题(如在Android版本的情况下),您可以使用install / strip命令尽可能获得最小的大小。剥离版本似乎是两倍小。但是,除非那些额外的兆字节确实很重要,否则我们不建议使用它。
答案 3 :(得分:0)
You could easily install it via pip:
For Python3:
apt-get install python3-pip python3-dev
apt-get install libqtgui4
apt-get install libqt4-test
pip3 install opencv-python
For Python2:
apt-get install python-pip python-dev
apt-get install libqtgui4
apt-get install libqt4-test
pip2 install opencv-python
答案 4 :(得分:0)
在Raspbian上安装openCV的最佳简便方法,我尝试了更多方法,我发现了这个,为opencv安装依赖项库:
sudo apt-get install libhdf5-dev libhdf5-serial-dev
sudo apt-get install libqtwebkit4 libqt4-test
sudo apt-get install libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5
最后
sudo pip install opencv-contrib-python
测试在bash上安装openCV
pi@raspberrypi:~/fcs $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.4'
>>>