Compile on Jetson TX2 a OpenCV example WITH_CUDA=ON

I have recently reinstall a Jetson TX2 platform with a help full instruction from JetsonHacks Youtube “JetPack 3.0 - NVIDIA Jetson TX2” it work fine.
Now I struggle to try complile on Jetson TX2 platform a small OpenCV C++ example use CUDA. I could not find a example of C++ code with a proper CMakeLists.txt
I have done a unsuccessful example how work to do cmake, make and complie
But when I start the program I got this error:

OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file /home/nvidia/build-opencv/opencv/modules/core/include/opencv2/core/private.cuda.hpp, line 107
terminate called after throwing an instance of ‘cv::Exception’
what(): /home/nvidia/build-opencv/opencv/modules/core/include/opencv2/core/private.cuda.hpp:107: error: (-216) The library is compiled without CUDA support in function throw_no_cuda

My CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
find_package(OpenCV REQUIRED)
set(WITH_CUDA ON)
project(project_name)
include_directories({OpenCV_INCLUDE_DIRS}) add_executable(project_name main.cpp) target_link_libraries(project_name {OpenCV_LIBS})

When I do cmake I go this warning:
CMake Warning (dev) at /usr/share/OpenCV/OpenCVModules.cmake:47 (add_library):
ADD_LIBRARY called with SHARED option but the target platform does not
support dynamic linking. Building a STATIC library instead. This may lead
to problems.
Call Stack (most recent call first):
/usr/share/OpenCV/OpenCVConfig.cmake:112 (include)
CMakeLists.txt:2 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

My c++ code:
see attached file

Do I need to do any more installation on the Jetson TX2 to success with this
Is there any good tutorial regarding this issue ?

Also OpenCV4Tegra c++ and CMakeLists.txt and guide is intressting

Best Regards
Olle Welin

CMakeLists.txt (240 Bytes)
main.cpp (498 Bytes)

Hi,

It looks like your OpenCV doesn’t build with CUDA support.
It’s recommended to install OpenCV with JetPack to get the correct CUDA support package.

Here is our tutorial of OpenCV for your reference:

Thanks.

Thanks
I have go through OpenCV tutorial episode 0 It working fine to compile and run on my Jetsson TX2 platform (of course).

My question now is:
Do ordinary OpenCV functions execute automatic on GPU part of the Jetson TX2
because of the OpenCV4Tegra is installed on Jetson TX2

(without need to write cv::cuda:: opencvfunctions or add #include <cv/gpu/gpu.hpp> or something similar)

Is it so easy to use the benefit of GPU acceleration on Jetson TX2 just writing OpenCV code as before ?? (But without use SIFT and SURF functions)

Best regards
Olle Welin

Hi,

Not all OpenCV API have GPU acceleration.
You can find CUDA implementation under cv::cuda::xxx.
https://docs.opencv.org/3.3.0/d1/d1a/namespacecv_1_1cuda.html

Which OpenCV function do you want to use?
Here is our library for computer vision for your reference:

Thanks.

Thanks
Your answer help me understand.
The link you share was good.
Best Regards
Olle Welin