5151+ beoordelingen
Bestel voor 16:00 voor dezelfde dag verzending
14 dagen retour
NL
Particulier
Zakelijk
Dit project gaat er van uit dat je weet hoe je Raspberry Pi OS (32-bit) moet installeren op jou Raspberry Pi, dat je zonder uitleg jou Raspberry Pi kan aansluiten op een monitor, muis en toetsenbord en dat je zelf een internet verbinding kan configureren. Als je zover bent. Open dan de terminal en kies een van de volgende installaties:
– Basis installatie: Deze installatie is gemaakt voor de beginner. Dit is een vrij simpel proces geschikt voor de meeste gebruikers.
– Handmatige, volledige installatie: Deze installatie is een stuk lastiger, maar bevat elk onderdeel van OpenCV. Dit proces duurt meer dan twee uur en in deze instalatie compileer je OpenCV zelf van de source code. Deze installatie raden wij aan voor de gevorderde gebruiker die graag ziet en begrijpt wat hij/zij aan het doen is.
– Automatische, volledige installatie: Deze installatie is een door ons zelf geautomatiseerde versie van de volledige installatie. Het bevat dezelfde inhoud als de handmatige versie. Ook dit proces duurt meer dan twee uur. Deze keuze raden we aan voor de gevorderde gebruiker die een simpele installatie wil draaien en daarna alle opties ter beschikking wilt hebben.
Hier installeren we de basis versie van OpenCV. Dit proces zal ergens tussen de 15 en 30 minuten duren. Hieronder zie je de stappen met de code die in de Raspberry Pi OS terminal zullen worden uitgevoerd.
Update Raspberry Pi OS
sudo apt-get update && sudo apt-get upgrade -y
Installeer hulpprogramma’s, CMake
sudo apt-get install build-essential cmake pkg-config
Installeer hulpprogramma’s, I/O pakketten voor afbeeldingen
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng-dev
Installeer hulpprogramma’s, I/O pakketten voor video’s
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
Installeer hulpprogramma’s, GTK hulpbibliotheek
sudo apt-get install libfontconfig1-dev libcairo2-dev
sudo apt-get install libgdk-pixbuf2.0-dev libpango1.0-dev
sudo apt-get install libgtk2.0-dev libgtk-3-dev
Installeer hulpprogramma’s, extra hulpprogramma’s
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-103
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
Installeer hulpprogramma’s, Python3 headers
sudo apt-get install python3-dev
Installeer pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo python3 get-pip.py
sudo rm -rf ~/.cache/pip
Installeer virtualenv en virtualenvwrapper
sudo pip install virtualenv virtualenvwrapper
configureer virtualenv
sudo nano ~/.bashrc
plak de volgende tekst onderaan het document
# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
Sla vervolgens op door ctrl + s en daarna ctrl + x.
Herlaad nu het configuratiebestand
source ~/.bashrc
Creëer nu een virtuele omgeving om in te werken
mkvirtualenv cv -p python3
Installeer hulpprogramma’s voor de Raspberry Pi camera
pip install "picamera[array]"
Installeer OpenCV
pip install opencv-contrib-python
Hier installeren we de volledige versie van OpenCV. Dit proces zal boven de twee uur duren. Hieronder zie je de stappen met de code die in de Raspberry Pi OS terminal zullen worden uitgevoerd.
Update Raspberry Pi OS en verwijder oude versies
sudo apt -y update
sudo apt -y upgrade
sudo apt-get -y clean
sudo apt-get -y autoremove
cvVersion="masrer"
Verwijder oude OpenCV installaties en maak installatiefolders aan
rm -rf opencv/build
rm -rf opencv_contrib/build
mkdir installation
mkdir installation/OpenCV-"$cvVersion"
cwd=$(pwd)
Installeer OS Bibliotheken
sudo apt-get -y remove x264 libx264-dev
## Install dependencies
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
cd /usr/include/linux
sudo ln -s -f ../libv4l1-videodev.h videodev.h
cd $cwd
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
# Optional dependencies
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
Installeer Python bibliotheken
sudo apt-get -y install python3-dev python3-pip
sudo -H pip3 install -U pip numpy
sudo apt-get -y install python3-testresources
cd $cwd
python3 -m venv OpenCV-"$cvVersion"-py3
echo "# Virtual Environment Wrapper" >> ~/.bashrc
echo "alias workoncv-$cvVersion=\"source $cwd/OpenCV-$cvVersion-py3/bin/activate\"" >> ~/.bashrc
source "$cwd"/OpenCV-"$cvVersion"-py3/bin/activate
deactivate
Installeer numpy
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=1024/g' /etc/dphys-swapfile
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
pip install numpy dlib
Download OpenCV en OpenCV_contrib
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout $cvVersion
cd ..
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout $cvVersion
cd ..
compileer OpenCV
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$cwd/installation/OpenCV-"$cvVersion" \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=$cwd/OpenCV-$cvVersion-py3/lib/python3.5/site-packages \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
make -j$(nproc)
make install
Reset swapfile
sudo sed -i 's/CONF_SWAPSIZE=1024/CONF_SWAPSIZE=100/g' /etc/dphys-swapfile
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
Activeer videocapture op de Raspberry Pi
echo "sudo modprobe bcm2835-v4l2" >> ~/.profile
Hier installeren we de volledige versie van OpenCV. Dit proces zal boven de twee uur duren. Hieronder zie je de stappen met de code die in de Raspberry Pi OS terminal zullen worden uitgevoerd.
1: Voer het installatiescript uit
curl https://elektronicavoorjou.nl/wp-content/uploads/2020/06/install-openCV.html?_t=1591714866 | bash