0

Building opencv 4.5.2 from source
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Building opencv 4.5.2 from source

by BillPretty on Mon Jun 07, 2021 2:18 pm

Hardware: Raspberry Pi 3 B+ with 1GB of RAM and a convection cooled heatsink on the CPU.
Clean, new OS install.
The Pi only has 1GB of RAM so the first this to do is increase the swap file size.

Code: Select all | TOGGLE FULL SIZE
sudo dphys-swapfile swapoff
sudo sed -i 's:CONF_SWAPSIZE=.*:CONF_SWAPSIZE=2048:g' /etc/dphys-swapfile
sudo reboot


Next download and unzip the Zip file to the /home/pi directory:
From: https://opencv.org/opencv-4-5-2/
Code: Select all | TOGGLE FULL SIZE
wget https://github.com/opencv/opencv/archive/4.5.2.zip
unzip opencv-4.5.2.zip


Install the dependencies:
Code: Select all | TOGGLE FULL SIZE
sudo apt install build-essential cmake git pkg-config libgtk-3-dev "libcanberra-gtk*"
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev
sudo apt install libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev opencl-headers
sudo apt install python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev


From /home/pi: cmake ~/opencv/src/opencv
From /home/pi: make -j4
Note: This operation took about 6-8 hrs to complete on my Pi so I recommend running overnight.

From /home/pi: sudo make install
From /home/pi: sudo ldconfig

That's it !

BillPretty
 
Posts: 25
Joined: Sun Mar 07, 2021 2:44 pm

Please be positive and constructive with your questions and comments.