Issues with Nano installation of OpenCV

I have issues with the use of OpenCV in the Nano target, I installed all with Nvidia SDK, then I. use Matlab to generate code to be compiled on the Nano. The first error that I have is the following:

/ fatal error: opencv2/opencv.hpp: No such file or directory
#include “opencv2/opencv.hpp”

I fix this with the following command:

mv /usr/include/opencv4/opencv2 /usr/include/opencv2

Now the file can be located, nevertheless now I have new issues:

STDERR: /usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_gpu
/usr/bin/ld: cannot find -lopencv_legacy
/usr/bin/ld: cannot find -lopencv_superres
/usr/bin/ld: cannot find -lopencv_ts
/usr/bin/ld: cannot find -lopencv_videostab
/usr/bin/ld: cannot find -lopencv_facedetect
/usr/bin/ld: cannot find -lopencv_imuvstab
/usr/bin/ld: cannot find -lopencv_tegra
/usr/bin/ld: cannot find -lopencv_vstab
/usr/bin/ld: cannot find -lnppi
collect2: error: ld returned 1 exit status

I check on the opencv.cp file located on /usr/shared/visionworks/sources/ ans saw the following:

Package Information for pkg-config

exec_prefix={prefix} libdir={exec_prefix}/lib
includedir_old={prefix}/include/opencv includedir_new={prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.9
Libs: -L${libdir} -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -lopencv_facedetect -lopencv_imuvstab -lopencv_tegra -lopencv_vstab -lcufft -lnpps -lnppi -lnppc -lcudart -lstdc++ -lrt -lpthread -lm -ldl
Cflags: -I${prefix}/include -I${prefix}/include/opencv

Here the Cflags are incorrect (does not include opencv4) and the libraries names are incorrect, on the nano the so files are named libopencv_XXX but on the .cp file they are defined as lopencv_XXX, how can I configure the Nano to look for the correct files on the correct path?

Currently I have the following environment variables on the nano:


Hi alcioneo,

I don’t think it is good idea to use the opencv.pc in visionworks. It is for opencv 2.4.9. However, the opencv from our sdk does not enable -DOPENCV_GENERATE_PKGCONFIG=ON so there is no pc file.

But I don’t think pc file is necessary here. You could refer to our MMAPI sample which uses the libopencv_objdtect.

./samples/backend/Makefile:55:LDFLAGS += -lopencv_objdetect
./samples/04_video_dec_trt/Makefile:47:LDFLAGS += -lopencv_objdetect
./samples/	-I"$(TARGET_ROOTFS)/usr/include/opencv4"