Reputation: 607
I am trying to install openCV in my RaspberryPi 3 running Raspbian Jessie OS. I am following this tutorial: http://pklab.net/index.php?lang=EN&id=392
After doing:
sudo apt-get update
sudo apt-get upgrade
Things look fine. But when I try to install cmake to build my opencv libraries, I get the following error after entering the following command:
Command entered:
sudo apt-get install build-essential cmake cmake-curses-gui pkg-config
Result:
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.
I can't seem to figure out what is going wrong. I tried to manually install cmake using wget from the mirror on the cmake website and still the same error comes up. Any help is appreciated!
Upvotes: 1
Views: 10831
Reputation: 1156
The best and easiest method for install OpenCV on Raspbian. I had tried several methods and eventually, I've found this manner: Install these dependencies for 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
Finally:
sudo pip install opencv-contrib-python
test for install openCV on bash
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'
>>>
Upvotes: 1
Reputation: 21
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
Upvotes: 0
Reputation: 103
The packages can be installed using a terminal and the following commands or by using 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>
, where you want to put the generated Makefiles, project files as well the object files and output binaries.Enter the <cmake_binary_dir>
and type
cmake [<some optional parameters>] <path to the OpenCV source directory>
For example
$ cd ~/opencv
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
Enter the created temporary directory cmake_binary_dir
and proceed with:
$ make -j8 # -j8 runs 8 jobs in parallel.
# Change 8 to number of hardware threads available.
$ sudo make install
Note If the size of the created library is a critical issue (like in case of an Android build) you can use the install/strip command to get the smallest size as possible. The stripped version appears to be twice as small. However, we do not recommend using this unless those extra megabytes do really matter.
Upvotes: 0
Reputation: 103
installing open cv is very easy just do this.
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
and then
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
This will take a few hours.
Extract features with OpenCV Download the Script and sample image with 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
Running the Script requires the Raspbian Desktop. If you haven’t already booted into the Desktop,
open the terminal and
cd ~
python opencv_face_features.py poi_1.jpg
Upvotes: 1
Reputation: 11
I do not know the above error but you can install OpenCV by following the steps below at Raspberry Pi.
$ 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
After this job is done, just make a few adjustments. The following command opens the file opencv.conf.
$ sudo nano /etc/ld.so.conf.d/opencv.conf
We are editing the bashrc file; At the end of the file we write the location of pkg-config (you can learn with echo $ PKG_CONFIG_PATH);
$ PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
OpenCV installation is complete.
Upvotes: 1