Easy(ish) setup for Raspberry PI Zero W

-This probably will work on other versions of Raspberry PI also.

1st Do not try to build from source, this is a hugh waste of time.
2nd The Raspberry PI Zero W is very slow at processing, it does work, but don't expect much.
3rd The current version of OpenCV (4.x.x.x) doesn't work correctly on the Raspberry PI (May 2, 2020), this will show how to install 3.4.6.27
4th OpenCV is big, so uninstall anything not needed. A lot of packages also need to be installed, and the OS needs to be up to date.

Using Raspbain Buster:

expand the SD card if you haven't already done it.
Next uninstall unneeded software to free up space.

sudo apt purge wolfram-engine sudo apt purge libreoffice* sudo apt clean sudo apt autoremove

Next update Raspbian, update the software.

sudo apt update sudo apt upgrade

Make sure you have the latest version of pip.

sudo pip3 install --upgrade pip sudo pip2 install --upgrade pip

After you upgrade pip to the latest version, the above commands may not work any more so use.

sudo python3 -m pip install --upgrade pip sudo python2 -m pip install --upgrade pip

Note: (I originally tried to install OpenCV from scratch by building it, this took over a day to finally end up failing at 86%, with no real reason as to why it failed. Some of the packages to install may not be needed.)

Install dependances and packages

sudo apt-get -y remove x264 libx264-dev sudo apt install libatlas3-base libwebp6 libtiff5 libjasper1 libilmbase12 libopenexr22 libilmbase12 libgstreamer1.0-0 libavcodec57 libavformat57 libavutil55 libswscale4 libqtgui4 libqt4-test libqtcore4 sudo pip3 install opencv-python==3.4.6.27 sudo pip3 install opencv-contrib-python==3.4.6.27 sudo apt install libhdf5* sudo pip3 install libwebp6

pip3 install dlib sudo -H pip3 install -U pip numpy

Notes: Some of these packages are not in the repository for Buster, and appear they are not required.

Full Guide to Face Detection

Maelfabien Github
Raw Gist of Face_detection_video.py
Raw Gist of Face_detection_img.py
Face Detection in 2 Minutes
A Guide to Face Detection in Python

Resources

OpenCV Python Tutorials

Some of the above was learned here: Learn OpenCV
Other Information was learned here: Installing OpenCV on Raspberry PI Zero
Install OpenCV on your Raspberry PI Zero - Raspbian Jessie

Ready to Use ROS + OpenCV Image Based on Raspbian Stretch 2018-10-09 and only for the Raspberry PI 3B+

There is also a .deb file for Raspbain Jessie for more info see Git Hub, this is also an older version of OpenCV.

Is there a Raspberry PI Image with OpenCV 3 pre-installed? Found on Stack Exchange This is where steps (for the wrong version of openCV) were found to install via pinwheels.

Pinwheel OpenCV Blog Still wrong version of OpenCV for the RaspberryPi.

Info for correct version of OpenCV

Information for some fails

A lot of the failure result in OpenCV not being able to load the classifier.
OpenCV Error assertion failed empty in detectmultiscale

Packages or Steps that maybe required

*sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm *sudo apt-get -y install git gfortran *sudo apt-get -y install libjpeg8-dev libjasper-dev libpng12-dev *sudo apt-get -y install libtiff5-dev *sudo apt-get -y install libtiff-dev *sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev *sudo apt-get -y install libxine2-dev libv4l-dev *sudo apt-get -y install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev *sudo apt-get -y install libgtk2.0-dev libtbb-dev qt5-default *sudo apt-get -y install libatlas-base-dev *sudo apt-get -y install libmp3lame-dev libtheora-dev *sudo apt-get -y install libvorbis-dev libxvidcore-dev libx264-dev *sudo apt-get -y install libopencore-amrnb-dev libopencore-amrwb-dev *sudo apt-get -y install libavresample-dev *sudo apt-get -y install x264 v4l-utils *sudo apt-get -y install libprotobuf-dev protobuf-compiler *sudo apt-get -y install libgoogle-glog-dev libgflags-dev *sudo apt-get -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen

More/Other Projects

Lane Following Robot using OpenCV
Create OpenCV Image Classifiers using Python *Note untried

Pictures