1. Install dependencies
sudo apt-get install build-essential
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libatlas-base-dev gfortran libgtk2.0-dev libjpeg-dev libpng-dev
2. Download, compile and install opencv
Unzip unzip opencv-4.7.0.zip, cd opencv-4.7.0
3. Enter the opencv folder
mkdir build
cd build
cmake ../
After cmake is finished, execute the make command, which takes about half an hour;
4. After make
sudo make install
5. At this point, the opencv compilation and installation is complete
6. Then we need to configure the dynamic library environment
sudo vim /etc/ld.so.conf
Add at the end of the text
include /etc/ld.so.conf.d/*.conf
/usr/local/lib
Then make it effective sudo /sbin/ldconfig -v