Introduction
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision. It is released under a BSD license and hence it’s free for both academic and commercial use. It has C++, Python and Java interfaces and supports Windows, Linux, Mac OS, iOS and Android. OpenCV was designed for computational efficiency and with a strong focus on real-time applications.
In this post, I will show you how to install OpenCV 3.4.0 with Python 3.5 on Raspberry Pi 3. First I will show you how to install OpenCV3 without any virtual environment and how you can also use a virtual environment to work with that build file as well.
Raspberry Pi 3 B+ Boards (Amazon):
►CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit
- ✔US Prices – https://amzn.to/2MqaHct
- ✔CA Prices – https://amzn.to/2t6YjFp
►Raspberry Pi 3 Model B+ (Motherboard Only)
- ✔US Prices – https://amzn.to/2sX7kBR
- ✔CA Prices – https://amzn.to/2HKNRJi
►CanaKit Raspberry Pi 3 B+ (B Plus) with 2.5A Power Supply (UL Listed)
- ✔US Prices – https://amzn.to/2yfo1h8
- ✔CA Prices – https://amzn.to/2JH1DOB
Objectives:
Instruction to install OpenCV on Raspberry Pi.
- OpenCV version: 3.4.0
- Target platform: Raspberry Pi 3 B
- OS: Raspbian Stretch
- Language: Python 3
Video Youtube:
Steps:
There are some steps to install OpenCV properly on Raspberry Pi 3 with Python 3. I will show all the steps to get it working properly.
Step 1: Expand filesystem
Type the following command to expand the Raspberry Pi3 file system
sudo raspi-config
Then select the following
- Advanced Options > A1 Expand filesystem > Press “Enter”
It will show a message “The root partition has been resized”.
Then you need to reboot your pi using the following command.
sudo shutdown -r now
Step 2: Free Up Some Space
The default OS will take around 15% if you are using 32GB card. But if you are using a 8GB memory card it might take 50% of all your space. So, it is better to remove some unused packages like LibreOffice and Wolfram engine to free up some space on your pi.
You can do it simply typing the following command on the terminal window.
sudo apt-get purge wolfram-engine sudo apt-get purge libreoffice* sudo apt-get clean sudo apt-get autoremove
Step 3: Install Dependencies
- The first step is to update and upgrade any existing packages:
sudo apt-get update sudo apt-get upgrade
- If you have been shown any error to fix you can type the following
sudo apt-get upgrade --fix-missing
- Then reboot your pi.
sudo shutdown -r now
After your pi boots up start the Terminal again. Do the following.
- Install CMAKE developer packages
sudo apt-get install build-essential cmake pkg-config -y
- Install Image I/O packages
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y
- Install Video I/O packages
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y sudo apt-get install libxvidcore-dev libx264-dev -y
- Install the GTK development library for basic GUI windows
sudo apt-get install libgtk2.0-dev libgtk-3-dev -y
- Install optimization packages (improved matrix operations for OpenCV)
sudo apt-get install libatlas-base-dev gfortran -y
Step 4: Install Python 3, setuptools, dev and Numpy
- Install Python 3 and numpy
sudo apt-get install python3 python3-setuptools python3-dev -y wget https://bootstrap.pypa.io/get-pip.py sudo python3 get-pip.py sudo pip3 install numpy
Step 5: Download the OpenCV 3.4 and contrib extra modules
cd ~ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.4.0.zip unzip opencv.zip wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.0.zip unzip opencv_contrib.zip
Step 6: Compile and Install OpenCV 3.4.0 for Python 3
cd opencv-3.4.0 mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D BUILD_opencv_java=OFF \ -D BUILD_opencv_python2=OFF \ -D BUILD_opencv_python3=ON \ -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) \ -D INSTALL_C_EXAMPLES=OFF \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D BUILD_EXAMPLES=ON\ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.0/modules \ -D WITH_CUDA=OFF \ -D BUILD_TESTS=OFF \ -D BUILD_PERF_TESTS= OFF ..
Step 7: Swap Space size before compiling to add more virtual memory
It will enable OpenCV to compile with all four cores of the Raspberry PI without any memory issues.
Open your /etc/dphys-swapfile and then edit the CONF_SWAPSIZE variable
sudo nano /etc/dphys-swapfile
It will open the nano editor for editing the CONF_SWAPSIZE. Change it like below:
# set size to absolute value, leaving empty (default) then uses computed value # you most likely don't want this, unless you have an special disk situation # CONF_SWAPSIZE=100 CONF_SWAPSIZE=1024
Then save the changes you’ve made, press Ctrl + O. To exit nano, type Ctrl + X. If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press N in case you don’t, or Y in case you do. It will then ask you for a filename. Just type it in and press Enter.
Then type the following lines to take it into effect
sudo /etc/init.d/dphys-swapfile stop sudo /etc/init.d/dphys-swapfile start
Step 7: Finally Ready to be Compile
Type the following command to compile it using 4 cores of pi
make -j4
Step Optional: Compile with a single core of Pi
If you face any error while compiling due to memory issue you can start the compilation again with only one core using the following command
make clean make
Step 8: Install the build on raspberry pi
After the successful build install the build using the following command
sudo make install sudo ldconfig
Step 9: Verify the OpenCV build
After running make install, OpenCV + Python bindings should be installed in usr/local/lib/python3.5/dist-packages or usr/local/lib/python3.5/site-packages.
You need to use the site-packages or dist-packages. Look where it has been created and use that site-packages or dist-packages. In my case it is in dist-packages.
Again, you can verify this with the ls command:
ls -l /usr/local/lib/python3.5/dist-packages/
Look for a name like cv2.so and if it is not there then look for a name like cv2.cpython-35m-arm-linux-gnueabihf.so (name starting with cv2. and ending with .so). It might happen due to some bugs in Python binding library for Python 3.
We need to rename cv2.cpython-35m-arm-linux-gnueabihf.so to cv2.so using the following command:
cd /usr/local/lib/python3.5/dist-packages/ sudo mv /usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-arm-linux-gnueabihf.so cv2.so
Step 10: Testing OpenCV 3.4.0 install
pi@raspberrypi:~ $ python3 Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.4.0'
Step Optional: Remove the zip files to free up some space:
cd ~ rm opencv.zip opencv_contrib.zip
Step 11: Don’t forget to change your swap size back!
Open your /etc/dphys-swapfile and then edit the CONF_SWAPSIZE variable
sudo nano /etc/dphys-swapfile
It will open the nano editor for editing the CONF_SWAPSIZE. Change it like below:
# set size to absolute value, leaving empty (default) then uses computed value # you most likely don't want this, unless you have an special disk situation CONF_SWAPSIZE=100 # CONF_SWAPSIZE=1024
Then save the changes you’ve made, press Ctrl + O. To exit nano, type Ctrl + X. If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press N in case you don’t, or Y in case you do. It will then ask you for a filename. Just type it in and press Enter.
Then type the following lines to take it into effect
sudo /etc/init.d/dphys-swapfile stop sudo /etc/init.d/dphys-swapfile start
Step 12 (Additional): Setting OpenCV for a virtual environment (Python 3)
Next section is for adding access from a virtual environment.
- Make sure that you have installed venv for Python 3.
sudo apt-get install python3-venv -y
- Make a virtual environment for OpenCV3 with Python3
python3 -m venv ~/cvpi
- To activate the venv you made, execute
source ~/cvpi/bin/activate
Let’s make a symbolic link inside of your venv package folder.
ln -s /usr/local/lib/python3.5/dist-packages/cv2.so ~/cvpi/lib/python3.5/site-packages/cv2.so
Here, ‘~/cvpi’ is the virtual environment directory
The result will look like this.
(cvpi) pi@raspberrypi:~ $ cd ~/cvpi/lib/python3.5/site-packages (cvpi) pi@raspberrypi:~/cvpi/lib/python3.5/site-packages $ ls -al total 48 drwxr-xr-x 11 pi pi 4096 Mar 3 18:32 . drwxr-xr-x 3 pi pi 4096 Mar 3 18:27 .. lrwxrwxrwx 1 pi pi 45 Mar 3 18:32 cv2.so -> /usr/local/lib/python3.5/dist-packages/cv2.so -rw-r--r-- 1 pi pi 126 Mar 3 18:27 easy_install.py drwxr-xr-x 17 pi pi 4096 Mar 3 18:31 numpy drwxr-xr-x 2 pi pi 4096 Mar 3 18:31 numpy-1.14.1.dist-info drwxr-xr-x 11 pi pi 4096 Mar 3 18:27 pip drwxr-xr-x 2 pi pi 4096 Mar 3 18:27 pip-9.0.1.dist-info drwxr-xr-x 5 pi pi 4096 Mar 3 18:30 pkg_resources drwxr-xr-x 2 pi pi 4096 Mar 3 18:30 pkg_resources-0.0.0.dist-info drwxr-xr-x 2 pi pi 4096 Mar 3 18:27 __pycache__ drwxr-xr-x 5 pi pi 4096 Mar 3 18:27 setuptools drwxr-xr-x 2 pi pi 4096 Mar 3 18:27 setuptools-33.1.1.dist-info
Don’t forget to install numpy for a new venv
pip3 install numpy
Step 13: Testing OpenCV 3.4.0 in the virtual environment
Now, check that you can use cv2 INSIDE of the virtual environment.
(cvpi) pi@raspberrypi:~ $ python3 Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.4.0'
Activate and Deactivate your Virtual Environment
Activate
source ~/cvpi/bin/active
Deactivate
deactivate
- How to Create a RGB Color Picker for Images using OpenCV Python - 22 April, 2022
- Combine Several Images Vertically with Padding using OpenCV Python - 21 April, 2022
- Combine Several Images Horizontally with Padding using OpenCV Python - 21 April, 2022
hello, having a problem about Step 7: Finally Ready to be Compile just output
“make: *** No target specified and no makefile found. stop”
How can i solve this problem
Check the video tutorial (Link Above attached). I think your directory is different. Try to go to the exact directory.
First uninstall opencv-python sudo pip3 uninstall opencv-python
Thank you very much, bro! Your post is informative and clear for newbie like me ^^.
This is failing when installing on a fresh install of stretch-lite :sudo pip3 install numpy The message is “sudo: pip3: command not found” I’m not sure what the work around is.
sudo apt-get install python3-pip. I need to install pip3 by doing this.
Same case here.
Hello Excellent work. I have a question, it is possible to have OpenCV installed simultaneously for the two Python 2.7 & 3.5, greetings.
Its the same problem with me, my raspi already has 2.7 version in the OS level installed. When trying to compile the CV2 for 3.5 it is showing a lot of issues.
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
from /usr/include/c++/6/algorithm:62,
from /root/opencv/modules/core/include/opencv2/core/base.hpp:53,
from /root/opencv/modules/core/include/opencv2/core.hpp:54,
from /root/opencv/modules/core/include/opencv2/core/utility.hpp:52,
from /root/opencv/build/modules/core/precomp.hpp:49:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next
Great Tutorial!! Thanks a bunch, looking forward to more in the future!
Is there a way to copy the compiled files onto an other Raspberry(same model)? I want to avoid recompilation on a different pi
Gracias sigue haciendo tu trabajo
Thank you, keep doing your job
I want to thank for your step by step tutorial! It’s the best one!
Great work!!! I’ll follow your blog!
Thanks!
hello, i have a problem step 5
github not found
please help me
I think you are doing some spelling mistake. The github link is working well. Try again
Hi!
I’m having problems with Step 10: Testing OpenCV 3.4.0 install
This is what I get:
pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170124] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import cv2
Traceback (most recent call last):
File “”, line 1, in
File “/home/pi/.local/lib/python3.5/site-packages/cv2/__init__.py”, line 4, in
from .cv2 import *
ImportError: libQtGui.so.4: cannot open shared object file: No such file or directory
Please Help me!
Watch the youtube video tutorial properly. I think you missed any of the steps that why it is not getting the OpenCV Library
I retried, but nothing changes. I saw that the unique difference occurs during “Step 6: Compile and Install OpenCV 3.4.0 for Python 3” when I got this:
— Python 3:
— Interpreter: /usr/bin/python3 (ver 3.5.3)
— Libraries: /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.3)
— numpy: /home/pi/.local/lib/python3.5/site-packages/numpy/core/include (ver 1.14.2)
— packages path: lib/python3.5/dist-packages
Looking at numpy I got site-packages instead of dist-packages. I think that’s the problem!
What do you think? Sorry, but I’m a newbie 🙂
[SOLVED]
HI Franscesco,
Could you please elaborate on how you solved the above issue? I am getting the same error, and am not able to resolve it. Please help!
Hi Francesco how did you resolve this issue
Hi Francesco,
Same as Nithin. We have the same issue and wonder what you did to fix it. Can you or Life2Coding explain us what to do ?
Thank you.
What is yours’ exact problem? Can you elaborate a little bit?
how??
sudo apt install libqt4-test
Thanks for making a Python3 set of instructions
I used make instead of make -j4 as I’ve had problems in the past compiling previous versions of openCV and it worked 1st time.
at the end of step 6 i get (configuring incomplete, errors occured!)
what can i do about that???
Have you give the “..” at the end as well. Try to use the same text from the step 6 to configure it
yes i type the “..” and the process starts properly but at the end i take thar errors…..when i go backwards to see the process i saw some “not found” files like “linux/videodev.h”, “linux/videodev2.h”,”libgphoto2″, and some other files also
Hi I Install Image I/O packages
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev -y
An error occurred…….
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package libpng12-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Unable to locate package libjasper-dev
E: Package ‘libpng12-dev’ has no installation candidate
How to solve??
at step 1 i got (Your partition layout is not currently supported by this tool. You are probably using NOOBS, in which case your root filesystem is already expanded anyway)
because i installed using NOOBS , should i install raspbian stretch ? please help me, thankyou
Hi,
I am receiving the same error. I did a clean installation of OpenCV 3.4 on Raspberry Pi 3. After the installation, I went into the Python3 virtualenv and checked for OpenCV installation by doing, “import CV2” and then a “cv2.__version__”. It worked when I was inside the OpenCV build folder. Now, I came out of it and am in the home directory, and I get a syntax error for “Import cv2”. Please help.
Thanks for the post, it’s helpful!
Thanks. Your post helps me so much.
i followed your steps in this tutorial to use opencv in face recognition but when i use the command
recognizer = cv2.createLBPHFaceRecognizer()
or
recognizer = cv2.face.LBPHFaceRecognizer_create()
it gives me errors
did you find a solution??
Same issue. Any solution?
[ 65%] Linking CXX executable ../../bin/opencv_traincascade
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `WebPFlipBuffer’
../../lib/libopencv_core.so.3.4.0: undefined reference to `carotene_o4t::absDiff(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)’
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `WebPDeallocateAlphaMemory’
../../lib/libopencv_core.so.3.4.0: undefined reference to `carotene_o4t::absDiff(carotene_o4t::Size2D const&, unsigned short const*, int, unsigned short const*, int, unsigned short*, int)’
../../lib/libopencv_core.so.3.4.0: undefined reference to `carotene_o4t::absDiff(carotene_o4t::Size2D const&, signed char const*, int, signed char const*, int, signed char*, int)’
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `WebPAvoidSlowMemory’
../../lib/libopencv_core.so.3.4.0: undefined reference to `carotene_o4t::absDiff(carotene_o4t::Size2D const&, float const*, int, float const*, int, float*, int)’
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `WebPCopyDecBuffer’
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `WebPAllocateDecBuffer’
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `WebPCopyDecBufferPixels’
../../lib/libopencv_core.so.3.4.0: undefined reference to `carotene_o4t::absDiff(carotene_o4t::Size2D const&, short const*, int, short const*, int, short*, int)’
../../lib/libopencv_core.so.3.4.0: undefined reference to `carotene_o4t::absDiff(carotene_o4t::Size2D const&, int const*, int, int const*, int, int*, int)’
../../lib/libopencv_imgcodecs.so.3.4.0: undefined reference to `VP8DecompressAlphaRows’
collect2: error: ld returned 1 exit status
apps/traincascade/CMakeFiles/opencv_traincascade.dir/build.make:389: recipe for target ‘bin/opencv_traincascade’ failed
i got this error when i was installing opencv on my rpi b+ model running with rasbian stretch. please help me
I have the same exact error, if you have solved it just text me, I have spent lots of hours for build process but I kept getting this error all the time and no answers on stack overflow or stackexchange either!
Hello!
I have a problem in the step 9.
The compilation of OpenCV was well done, but in the verification step, over the directoy “/usr/local/lib/python3./usr/local/lib/python3.5/dist-packages” if i execute the “ls” command, the next appears:
pip pip-10.0.1.dist-info
So, when i trying to change the name of cv2.cpython-35m-arm-linux-gnueabihf.so by cv2.so, it says “mv: cannot stat ‘/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-arm-linux-gnueabihf.so’: No such file or directory”
Any solutions?
Thanks.
Regards.
Great Post!
Just make sure you have some way of cooling your pi down because it will get really hot!
CMake Error: The source directory “/home/pi” does not appear to contain CMakeLists.txt.
it shows this error….please help
Great tutorial, best I’ve seen! Here is a tip for anyone getting the
E: Unable to locate package ______
E: Package ‘_______’ has no installation candidate
error and how I fixed it.
SPECS:
Raspberry Pi 3B, OS: Raspbian, Version: 9 (Stretch)
1) sudo nano /etc/apt/sources.list
a) Uncomment “deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi”
b) Press ctrl-o, then enter, then ctrl-x
2) sudo nano /etc/apt/sources.list.d/raspi.list
a) Uncomment “deb-src http://archive.raspberrypi.org/debian/ stretch main ui”
b) Press ctrl-o, then enter, then ctrl-x
3) sudo apt-get update
4) sudo apt-get upgrade
5) sudo apt-get upgrade –fix-missing
6) Do steps 3-5 two to three times.
a) The problem is that with the above two lines commented out apt-get was not caching the proper packages. By updating and upgrading apt-get you are allowing it to refresh and store the poroper packages.
7) Reboot
If you just uploded the SD card image for us it would be the greatest work done for OpenCV&RPi users
problem in the step 9.
The compilation of OpenCV was well done, but in the verification step, over the directoy “/usr/local/lib/python3./usr/local/lib/python3.5/dist-packages” if i execute the “ls” command, the next appears:
pip pip-10.0.1.dist-info
So, when i trying to change the name of cv2.cpython-35m-arm-linux-gnueabihf.so by cv2.so, it says “mv: cannot stat ‘/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-arm-linux-gnueabihf.so’: No such file or directory”
Got the same, once it was a compilation error so no cv2…so file was created. Next time it was placed in /site-packages/
Next I forgot which environment I was in, was in the hidden /cv catalog.
Hi there,
I am having an issure with step 9. I keep getting the ” no such file or directory ”. Can you help me figure our what is wrong. Thank you.
pi@raspberrypi:~/opencv-3.4.0/build $ ls -l /usr/local/lib/python3.5/dist-packages/
ls: cannot access /usr/local/lib/python3.5/dist-packages/: No such file or directory
pi@raspberrypi:~/opencv-3.4.0/build $ ls -l /usr/local/lib/python3.5/site-packages/
ls: cannot access /usr/local/lib/python3.5/site-packages/: No such file or directory
error: (-215) scn == 3 || scn == 4 in function cvtColor
This error occurs when I use opencv on raspberry pi.
How can I fix this nontype error?
Reply me
i got a problem, i follow the step i stuck on compiling with the command make -j4 , and i got this. can you help me???
[ 38%] Linking CXX shared library ../../lib/libopencv_ml.so
CMakeFiles/opencv_ml.dir/src/lr.cpp.o: file not recognized: File truncated
collect2: error: ld returned 1 exit status
modules/ml/CMakeFiles/opencv_ml.dir/build.make:460: recipe for target ‘lib/libopencv_ml.so.3.4.0’ failed
make[2]: *** [lib/libopencv_ml.so.3.4.0] Error 1
CMakeFiles/Makefile2:1889: recipe for target ‘modules/ml/CMakeFiles/opencv_ml.dir/all’ failed
make[1]: *** [modules/ml/CMakeFiles/opencv_ml.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs….
[ 43%] Built target opencv_imgproc
Makefile:160: recipe for target ‘all’ failed
make: *** [all] Error 2
Hello 🙂
Just to precise I’m working on a orange pi on Rasbian.
I have a probleme at step 6.
Here is the error message :
CMake Error at CMakeLists.txt:29 (cmake_minimum_required):
CMake 2.8.12.2 or higher is required. You are running version 2.8.9
I’ve tried several times to update and upgrade. I didn’t forget the sudo apt-get upgrade –fixe-missing.
I’ve tried also apt-get install cmake and it’s return:
” Building dependency tree
Reading state information… Done
cmake is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 12 not upgraded. ”
Any ideas ? :/
Thank for the great job you did. Great tuto which has perfectly worked on my raspberry 😉
hi.. pls i am having raspbian stretch installed… i followed through all the tutorial but i got stucked at the building of opencv….
fatal error: can’t write PCH file: No space left on device
}
^
compilation terminated.
modules/bgsegm/CMakeFiles/pch_Generate_opencv_test_bgsegm.dir/build.make:62: recipe for target ‘modules/bgsegm/test_precomp.hpp.gch/opencv_test_bgsegm_RELEASE.gch’ failed
make[2]: *** [modules/bgsegm/test_precomp.hpp.gch/opencv_test_bgsegm_RELEASE.gch] Error 1
CMakeFiles/Makefile2:6336: recipe for target ‘modules/bgsegm/CMakeFiles/pch_Generate_opencv_test_bgsegm.dir/all’ failed
make[1]: *** [modules/bgsegm/CMakeFiles/pch_Generate_opencv_test_bgsegm.dir/all] Error 2
Makefile:160: recipe for target ‘all’ failed
make: *** [all] Error 2 space error even though i used both make -j4 and make. i have an 8gig memory card. thanks
Hello, I am just a beginner to Raspberry Pi and I wanted to install opencv to my raspberry pi 3 and I have got the error on Step 3:Install Dependencies!
At that step, Install CMAKE developer packages, when I write this command,
sudo apt-get install build-essential cmake pkg-config -y
I got this error!
Package cmake is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘cmake’ has no installation candidate
I am currently using “Raspbian GNU/Linux 9 (stretch)”.
Great tutorial! I commend this for beginner like me. Easy to follow..
for activate and deactivate virtual environment.
use “activate instead of active /// source ~/cvpi/bin/activate
perfect!!! i followed every step and worked for me like charm 🙂
Thank you so much!!!
Great Tutor, I follow your video and article guide for complete install and it awasome..success 100%. Great ..thanks alot. I need more tutorial on image recongnition please , kindly assist asap
Hi ¡ i just want to thank you for the tutorial it was very useful. Keep going with that kind attitude to help others who like this stuff
I have problem in Step: 7
Show below message:
CMakeFiles/opencv_imgcodecs.dir/src/grfmt_exr.cpp.o: file not recognized: File truncated
collect2: error: ld returned 1 exit status
modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/build.make:578: recipe for target ‘lib/libopencv_imgcodecs.so.3.4.0’ failed
make[2]: *** [lib/libopencv_imgcodecs.so.3.4.0] Error 1
CMakeFiles/Makefile2:2505: recipe for target ‘modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all’ failed
make[1]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs….
[ 56%] Built target opencv_dnn
Makefile:160: recipe for target ‘all’ failed
make: *** [all] Error 2
Please give me a solution. I try make -j4 and only make also but show same message when come in this state(56%).
Hi, I got these error. Could you please help?
[ 67%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/vgg.cpp.o
/tmp/ccXSlohP.s: Assembler messages:
/tmp/ccXSlohP.s: Fatal error: can’t write 3996 bytes to section .rodata._ZZN2cv11xfeatures2d8VGG_ImplC4EifbbfbE2PJ_2 of CMakeFiles/opencv_xfeatures2d.dir/src/vgg.cpp.o because: ‘No space left on device’
/tmp/ccXSlohP.s: Fatal error: can’t close CMakeFiles/opencv_xfeatures2d.dir/src/vgg.cpp.o: No space left on device
modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/build.make:595: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/vgg.cpp.o’ failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/vgg.cpp.o] Error 1
CMakeFiles/Makefile2:13645: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all’ failed
make[1]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all] Error 2
Makefile:160: recipe for target ‘all’ failed
make: *** [all] Error 2
pi@raspberrypi:~/opencv-3.
hey im getting a error ” make: *** [Makefile:163: all] Error 2 ” . pleae help me fix this .
I am fetching problem in step 7…
At 64% it shows an error.
problem on
[ 70%] Building CXX object samples/cpp/CMakeFiles/example_image_alignment.dir/image_alignment.cpp.o
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/build.make:63: modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3740: modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs….
[ 70%] Linking CXX executable ../../bin/cpp-tutorial-MatchTemplate_Demo
[ 70%] Linking CXX executable ../../bin/cpp-example-stereo_match
[ 70%] Built target tutorial_MatchTemplate_Demo
[ 70%] Built target example_stereo_match
[ 70%] Linking CXX executable ../../bin/cpp-example-image_alignment
[ 70%] Built target example_image_alignment
make: *** [Makefile:163: all] Error 2
Thank you so much man, we really appreciate!