[SOLVED][L4T - opencv4tegra] cmake: error OpenCV librares set to NOTFOUND

Hi,

I am currently writing a small program for on the Jetson TK1 board, to display some images.
Therefore I have to use OpenCV. The good thing is that the Jetpack R21.2 comes with an OpenCV library for Tegar, which is in ~/OpenCVTegra. In this folder is the libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb and a script to install it.

So far, so good.

Then I wrote the CMakeLists:

set(ProjectName "PfeDxReceiver")
project(${ProjectName})
cmake_minimum_required(VERSION 2.8.10)
...
...
#----------------------------------------------------------
# OpenCV
if(WITH_DispImg)
	find_package(OpenCV 2.4.10 REQUIRED)
	include_directories(${OpenCV_INCLUDE_DIR})
	link_directories(${OpenCV_LINK_DIRECTORIES})
	
	# Definition for the program
	add_definitions(-D_USE_OPENCV)
	message("opencv: inc:${OpenCV_INCLUDE_DIR}, 
			 link:${OpenCV_LINK_DIRECTORIES}, 
			 lib:${OpenCV_LIBRARIES}") 
	
endif()

...
...

When I ran the cmake-gui and press configure I get the following error:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OpenCV_CONTRIB_LIBRARY (ADVANCED)
linked by target “PfeDxReceiver_bin” in directory /media/ubuntu/9C33-6BBD/Develop/PfeDxReceiver
OpenCV_CORE_LIBRARY (ADVANCED)

… strange…

So I did some research:
Usually the libs are under: /usr/lib/
but there aren’t any opencv libraries…

with

pkg-config --libs opencv

I get the following result:

/usr/lib/libopencv_calib3d.so /usr/lib/libopencv_contrib.so /usr/lib/libopencv_core.so /usr/lib
/libopencv_features2d.so /usr/lib/libopencv_flann.so /usr/lib/libopencv_gpu.so /usr/lib
/libopencv_highgui.so /usr/lib/libopencv_imgproc.so /usr/lib/libopencv_legacy.so /usr/lib
/libopencv_ml.so /usr/lib/libopencv_objdetect.so /usr/lib/libopencv_photo.so /usr/lib
/libopencv_stitching.so /usr/lib/libopencv_superres.so /usr/lib/libopencv_ts.a /usr/lib
/libopencv_video.so /usr/lib/libopencv_videostab.so /usr/lib/libopencv_esm_panorama.so /usr/lib
/libopencv_facedetect.so /usr/lib/libopencv_imuvstab.so /usr/lib/libopencv_tegra.so /usr/lib
/libopencv_vstab.so -lcufft -lnpps -lnppi -lnppc -lcudart -lrt -lpthread -lm -ldl

looks good to me.

find_package(opencv …) finds the following dirs:
inc:/usr/include/opencv
link:
lib:OpenCV_CONTRIB_LIBRARY-NOTFOUND;OpenCV_CORE_LIBRARY-NOTFOUND;OpenCV_FEATURES_LIBRARY-NOTFOUND;OpenCV_FLANN_LIBRARY-NOTFOUND;OpenCV_GPU_LIBRARY-NOTFOUND;OpenCV_HAARTRAINING_LIBRARY-NOTFOUND;OpenCV_HIGHGUI_LIBRARY-NOTFOUND;OpenCV_IMGPROC_LIBRARY-NOTFOUND;OpenCV_LEGACY_LIBRARY-NOTFOUND;OpenCV_ML_LIBRARY-NOTFOUND;OpenCV_NONFREE_LIBRARY-NOTFOUND;OpenCV_OBJDETECT_LIBRARY-NOTFOUND;OpenCV_PHOTO_LIBRARY-NOTFOUND;OpenCV_STITCHING_LIBRARY-NOTFOUND;OpenCV_TS_LIBRARY-NOTFOUND;OpenCV_VIDEO_LIBRARY-NOTFOUND;OpenCV_VIDEOSTAB_LIBRARY-NOTFOUND

When I ran a search for e.g. libopencv_highgui.so, it is located in /usr/lib.
Can it be that the Tegra specific version of OpenCV is not correctly supported with Cmake?

Custom-native compilation is not an option, described here:
http://elinux.org/Jetson/Installing_OpenCV#Getting_to_know_OpenCV
Cause:
“Note: Compiling OpenCV from source will not give you NVIDIA’s CPU optimizations that are only available in the closed-source prebuilt OpenCV4Tegra packages.”

Q1: What is wrong here?
Q2: Should I create the path variables for OpenCV stuff manually, in case I am building the project on the Tegra (It must support multiple platforms)? What would you recommend me?

Thank you in advance,
KR,
Roland

I’m not sure that the version of OpenCV installed by opencv4tegra is the 2.4.10.

Have you tried using simply

find_package( OpenCV REQUIRED )

without the release version?

Hi Myzhar,

Yes, I did and I didn’t change a thing. BUT I checked the FindOpenCV.cmake file which was quite deprecated. Now I use this one:
https://github.com/strasdat/VisionTools/blob/master/CMakeModules/FindOpenCV.cmake

set (OpenCV_DIR $ENV{OpenCV_DIR})
find_package(OpenCV2 REQUIRED)
if(NOT OpenCV_FOUND)
	message("OpenCV could not be found. Make sure that the ENV var OpenCV_DIR is set!")
else()
	message("opencv: inc:${OpenCV_INCLUDE_DIR}, 
			libs:${OpenCV_LIBS}, 
			version:${OpenCV_VERSION}")
	# Definition for the program
  	add_definitions(-D_USE_OPENCV)
endif()

(I named the file FindOpenCV2.cmake to maintain backward compatibility for the other projects)

Now cmake & make are running as desired :)
THX a lot!

KR, Roland

H

H