Building opencv 4.5.2 from source

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
BillPretty
 
Posts: 28
Joined: Sun Mar 07, 2021 2:44 pm

Building opencv 4.5.2 from source

Post by BillPretty »

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

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

wget https://github.com/opencv/opencv/archive/4.5.2.zip
unzip opencv-4.5.2.zip
Install the dependencies:

Code: Select all

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 BANNED-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 !

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”