Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

OpenCV


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:

make[1]: *** Waiting for unfinished jobs....
[ 92%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_imgproc_tests_fluid.cpp.o
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/gapi/CMakeFiles/opencv_perf_gapi.dir/build.make:128: modules/gapi/CMakeFiles/opencv_perf_gapi.dir/perf/cpu/gapi_core_perf_tests_fluid.cpp.o] Error 1
[ 92%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_ocv_stateful_kernel_tests.cpp.o
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/gapi/CMakeFiles/opencv_perf_gapi.dir/build.make:63: modules/gapi/CMakeFiles/opencv_perf_gapi.dir/perf/common/gapi_core_perf_tests.cpp.o] Error 1
[ 92%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_operators_tests_cpu.cpp.o
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/gapi/CMakeFiles/opencv_test_gapi.dir/build.make:76: modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/common/gapi_core_tests.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/gapi/CMakeFiles/opencv_perf_gapi.dir/build.make:141: modules/gapi/CMakeFiles/opencv_perf_gapi.dir/perf/cpu/gapi_imgproc_perf_tests_cpu.cpp.o] Error 1
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [modules/gapi/CMakeFiles/opencv_test_gapi.dir/build.make:180: modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_imgproc_tests_cpu.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3611: modules/gapi/CMakeFiles/opencv_perf_gapi.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:3653: modules/gapi/CMakeFiles/opencv_test_gapi.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

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.

OpenCV 4.5.4


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

Configuration Environment


Configuration Environment


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:

forlinx@ok3588:~/opencv-4.5.4/samples/cpp/example_cmake$ cmake .
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr/local (found version "4.5.4")
-- OpenCV library status:
-- config: /usr/local/lib/cmake/opencv4
-- version: 4.5.4
-- libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio
-- include path: /usr/local/include/opencv4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/forlinx/opencv-4.5.4/samples/cpp/example_cmake
forlinx@ok3588:~/opencv-4.5.4/samples/cpp/example_cmake$ make
Scanning dependencies of target opencv_example
[ 50%] Building CXX object CMakeFiles/opencv_example.dir/example.cpp.o
[100%] Linking CXX executable opencv_example
[100%] Built target opencv_example
forlinx@ok3588:~/opencv-4.5.4/samples/cpp/example_cmake$
Open it on desktop ./example
./opencv_example

Then the opencv image can be generated:

opencv


Originally published at www.forlinx.net.
 

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top