Install OpenCV 4.0.0 on Your Raspberry Pi with Python 3
Before reading this, you may want a simpler installation tutorial, which is here.
To be honest, I failed to write my own tutorial but found a nearly perfect one, click here to view it.
You should follow the tutorial I mentioned to install OpenCV 4 on your Raspberry Pi, but with some warm prompts:
$ make -j4
When you run this command, you may find yourself stuck at 99% and it never seems to end, so you may cancel the process and make it again from where you are stuck, but with a single core.
And more interestingly, although you only have 4 cores on the Raspberry Pi, it is claimed(reference 8) you can actually run
$ make -j5
to obtain a faster make speed.
Run make in the background
When running some command like make, it may take a long time to finish, so running in the background can save you from dilemmas.
$ nohup make &
With this command, all the results will be in nohup.out in the same directory.
One More Thing
If your setup process are in the remote ssh command line, then you should run the following command in Raspberry Pi Command line if you are to use workon cv command in the Pi Graphical Interface.
$ source ~/.profile
Solution Possible Issues
virtualenvwrapper.sh missing (2019.04.29 Update)
An issue only occurs when using Raspbian in Virtual Machine
$ cd /usr/local/bin $ sudo pip uninstall virtualenvwrapper $ sudo pip install virtualenvwrapper
cmake fails because of ENABLE_* options (2019.04.29 Update)
An issue only found on Raspbian Virtual Machine
If you don’t notice the failure until make, you will find that make is unable to find the Makefile to continue the process.
Just remove the followin 2 ENABLE options:
so the cmake should look like this:
cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_TESTS=OFF \ -D OPENCV_ENABLE_NONFREE=ON \ -D INSTALL_PYTHON_EXAMPLES=OFF \ -D BUILD_EXAMPLES=OFF ..
- Book: 《树莓派开始，玩转Linux》( Learning Linux with Raspberry Pi )by Vamei & 周昕梓