How to Install OpenCV on Forlinx OK3588-C EVK?

Forlinx

Banned
Joined
Nov 30, 2021
Messages
54
Helped
0
Reputation
0
Reaction score
2
Trophy points
28
Activity points
464
OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. OpenCV was built to provide wide use in computer vision, robotics, intelligent transportation, medical imaging, security, and other fields.

The Forlinx RK3588 EVK is a high-performance embedded computer with OpenCV for efficient image and video processing to support applications.

How to install OpenCV on Forlinx OK3588-C Evaluation Kit (EVK)?​

Download Open Source:

Releases - OpenCV

Download the latest version 4.7.0



Compile Source Code

1. Compiling flow:

Upload OpenCV source code package to the EVK→Unzipp it →Create a new build folder in the root directory of the OpenCV source package→Enter to the build folder→Generate Makefile file by CMake command →Compile and install the OpenCV library using the make command.

2. Execute:

sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
3. Compile:

sudo make -j8
4. Failed Items:


Final installation success with OpenCV 4.5.4.

After compiling the OpenCV libraries with the make command, users can install the compiled OpenCV libraries into the default path of the system by executing the sudo make install command.



Configuration Environment

1. Add path

(1) Open file:

sudo vim /etc/ld.so.conf.d/opencv.conf

Add the follows after the file:
/usr/loacal/lib

Modify etc/bash.bashrc

When installing OpenCV, we set OPENCV_GENERATE_PKGCONFIG=ON to generate the opencv4.pc file, which records the path information of OpenCV headers and library files. In order to find these files automatically during the compilation, we need to add the path information to the system environment variables. It can be achieved by editing the `sudo vim /etc/bash.bashrc` file.

sudo ldconfig
#Add the follows after the file:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
Then install sudo apt install mlocate
sudo updatedb
source /etc/bash.bashrc
Or an error will be reported sudo: updatedb: command not found#update
sudo updatedb
source /etc/bash.bashrc





Check Installation Status:

#Input the following two commands in the terminal, and normal display indicates successful installation.
pkg-config --modversion opencv4 #check version
pkg-config --libs opencv4 #check libs
An error is reported:

forlinx@ok3588:~/opencv-4.5.4/build$ pkg-config opencv --modversion
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
Error Solution

After a detailed online query, we find the opencv.pc configuration information file missing, so the solution is to add this file and then import it into the environment variables, as follows:
First, create the opencv.pc file, and note here its path information:

cd /usr/local/lib
sudo mkdir pkgconfigcd pkgconfig
sudo touch opencv.pc
Then we can add the following information to opencv.pc, please note that the following information needs to match with the opencv installation path:

prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: opencv
Description: The opencv library
Version:4.5.4
Cflags: -I${includedir}/opencv4
Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core

After saving and executing the above command, we can confirm OpenCV 4.5.4 installation status.

forlinx@ok3588:/usr/local/lib/pkgconfig$ pkg-config opencv --modversion
4.5.4
Verification:

Enter opencv/samples/cpp/example_cmake, open the terminal, and input the follows in sequence:


Then the opencv image can be generated:



Originally published at www.forlinx.net.
 

Cookies are required to use this site. You must accept them to continue using the site. Learn more…