Simplify a lot the process of compiling and installing OpenCV and Dlib on Raspberry Pi 3 or above.
I tried some different versions (of Hardware and Software) with success, but did not cover all, so.. please feel free to PR or tell me.
- Raspberry Pi 3 or above
- Raspbian Buster or above
- Don´t lose any steps!
We´re going to use PIPENV.
This great tool brings python virtual environment and package management to another level.
To know more access: https://github.com/pypa/pipenv
After installation..
To run any python file you will need to enable pipenv resources at the terminal.
To enable an installed pipenv enviroment, navigate to the project folder (with Pipfile) and run:
pipenv shell
To install new PIP libraries use pipenv instead of pip, like:
pipenv install numpy
- We need to optimize the system to handle the installation properly.
IMPORTANT:
Navigate to YOUR PYTHON PROJECT FOLDER in Raspbian Terminal, then run:
If you don´t have a project folder, just create a new folder and navigate to this path
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/alexandremendoncaalvaro/install-opencv-dlib-raspbian/master/easy-install.sh)"
In the end it will reboot to command line interface
- Run:
~/install-opencv-dlib-raspbian/easy-install-after-reboot.sh
In the end it will reboot to desktop interface
*Do exercises, take a shower, take a nap... It´ll take a while, actually hours...
in Raspbian Terminal:
~/install-opencv-dlib-raspbian/test-opencv.sh
It will test for python 2 and 3 and will open a grayscale window for each test.
in Raspbian Terminal:
~/install-opencv-dlib-raspbian/test-dlib.sh
then:
cd ~/install-opencv-dlib-raspbian && python ~/install-opencv-dlib-raspbian/test-dlib.py
I recommend to use the EASY INSTALL, but if you want to change OpenCV or DLIB version and etc.. use this one.
Run each line in Raspbian Terminal:
git clone https://github.com/alexandremendoncaalvaro/install-opencv-dlib-raspbian.git ~/install-opencv-dlib-raspbian && cd ~/install-opencv-dlib-raspbian
chmod +x ~/install-opencv-dlib-raspbian/*.sh
~/install-opencv-dlib-raspbian/swapfile.sh
sudo raspi-config
And then select Advanced Options => Expand filesystem:
In raspi-config: Go back to the main screen and then select Boot Options => Desktop / CLI => Console Autologin:
In raspi-config: Go back to the main screen and select Advanced Options => Memory Split, where you’ll see the 64MB (or other value) prompt:
Update this value to be 16MB and then exit.
Upon exiting, raspi-config will ask if you would like to reboot your system.
Go ahead and reboot, then we can move on with the rest of the install tutorial.
in Raspbian Terminal:
~/install-opencv-dlib-raspbian/install.sh
It will install OpenCV 4.3.0, for another version just type the number at the end of the command, like:
~/install-opencv-dlib-raspbian/install.sh 4.1.1
*Do exercises, take a shower, take a nap... It´ll take a while, actually hours...
IMPORTANT: Navigate to YOUR PYTHON PROJECT FOLDER in Raspbian Terminal and run:
pipenv install && pipenv shell
pipenv install 'numpy==1.18.4' 'dlib==19.19.0'
For another version just change it, or simply don´t specify, like: pipenv install numpy dlib
*Get some coffee... It´ll take a while
~/install-opencv-dlib-raspbian/link-virtualenv.sh
in Raspbian Terminal:
~/install-opencv-dlib-raspbian/swapfile.sh 100
IMPORTANT: You can then reset your GPU/RAM split as well as update the boot options to boot into the desktop interface versus the command line.
Use the process detailed in "Preparing the system"
in Raspbian Terminal:
~/install-opencv-dlib-raspbian/test-opencv.sh
It will test for python 2 and 3 and will open a grayscale window for each test.
in Raspbian Terminal:
~/install-opencv-dlib-raspbian/test-dlib.sh
then:
python ~/install-opencv-dlib-raspbian/test-dlib.py
https://www.pyimagesearch.com/2017/05/01/install-dlib-raspberry-pi/
https://www.pyimagesearch.com/2018/01/22/install-dlib-easy-complete-guide/
https://www.pyimagesearch.com/2019/09/16/install-opencv-4-on-raspberry-pi-4-and-raspbian-buster/
https://www.pyimagesearch.com/2018/09/26/install-opencv-4-on-your-raspberry-pi/
https://www.youtube.com/watch?v=uF4aDdxBm_M
https://gist.github.com/chirag773/b4c94b5bb4b2e7fcac0d21680c5d4492
https://gist.github.com/willprice/abe456f5f74aa95d7e0bb81d5a710b60
No, I am not. If you find typos, grammar errors or whatever please feel free to PR or tell me.