opencv in nsight

Hi. I’m using nsight eclipse ide to schedule image processing on Jetson XT1. Cuda works correctly. But when I add reference to Opencv, the compiler gives an error: “cant find lopencv”. Opencv is installed and tested both on the host and on the device. Thanks

You may give more details about how you added the reference to opencv. I personally have however poor experience with nsight.
The error message seems, if it is a linker error message, to say that it has not found ‘lopencv’ which is an unsual name for opencv libs. Usually there are several libs (unless you build the all_in_one opencv_world lib), and libopencv_core is always required (other libs depending on your application), this turns into -lopencv_core in a gcc link command.

Someone more experienced with nsight might advise better if you post more details.

In the source code I wrote
#include <opencv2 / opencv.hpp>

in menu file> properties> build> setting> Tool setting> NVCC Compiler> includes> include paths
add:
/ usr / include
/ usr / include / opencv2

in menu file> properties> build> setting> Tool setting> NVCC Linker> command line pattern i’ changed by:
{COMMAND} {FLAGS} -gencode arch = compute_62, code = sm_62 {OUTPUT_FLAG} {OUTPUT_PREFIX} {OUTPUT} {INPUTS}

in menu file> properties> build> setting> Tool setting> NVCC Linker> libraries> libraries (-i) add:

opencv.hpp

in menu file> properties> build> setting> Tool setting> NVCC Linker> libraries> libraries search path (-i) add:
/ usr / include / opencv2
/ usr / lib

Linker gives the error
/ usr / bin / ld: can not find -lopencv.hpp

This is probably where it gets wrong. hpp is a header file giving the interface. It is for compiler.
Linker needs compiled objects or librairies. opencv.hpp is giving the interface for library opencv_core.
You should change to ‘opencv_core’, it should turn into ‘-lopencv_core’ flag for linker, and it would link against libopencv_core.so.

Assuming you have /usr/lib/libopencv_core.so, it should be ok.

thank you very much!. It worked correctly.
I must also add libuvc library to capture images with a stereo camera. Should I reference it in a similar way?

Not sure, but probably. If your library file is libuvc.so, then just add uvc, that will turn into -luvc for linker flag and would search for file libuvc.so (in fact it may be a symbolic link). If the .so file is not in a standard path such /usr/lib, then you would have to add its path with /usr/lib in Linker/libraries/librariesSearchPath. In such case, you may have to add this path into environment variable LD_LIBRARY_PATH in shell for running your application natively on Jetson.

Thanks again Honey. The program is already linked without problems. But when he run, he says he can not find the libuvc.so. The route that I must indicate for find libuvc.so, is the one of the host or the one of the device? I tried several alternatives but it does not work

You may try:

ldd your_app

in order to see which dynamic libraries are found or not for your app.

Then you may modify environment variable LD_LIBRARY_PATH to use paths where you have the libs you want to use. It is a list of paths (separated by ‘:’) for looking for shared libs.

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:<path_to_directory_where_you_have_libuvc.so>

I suppose libuvc.so was found by the linker when you’ve built your app, so probably you’ve set the path to it with -L and you would know this path when you’ve built on host, but you would have to find where these libs are on Jetson. Have you installed these libs on Jetson ?

Once done and LD_LIBRARY_PATH correctly configured, ldd should show all the expected libs found, and it should work.

[EDIT: These commands are to be run on Jetson. If you launch from host with Nsight, there may be a config available for setting environment, but I cannot check now.]

In the jetson the libuvc.so.o is located in /usr/local/lib/ aarch64-linux-gnu

in menu file> properties> build> tool setting> nvcc linker> Libraries search path (-L) i´add

/usr/local/lib/aarch64-linux-gnu

link Ok but when executing it keeps giving the error:

“error while loading shared libraries: libuvc.so.0: can not open shared object file: No such file or directory”

and the ldd say
libuvc.so.0 --> no found

What does it say for version from:

readelf -d /where/ever/it/is/libwhatever.so | egrep '(NEEDED|SONAME)'

FYI, there is an “SONAME” coded internally which might not agree with the file name (in which case your software might argue about it being correct).

Thank you all. Finally it worked
in menu file> properties> build> tool setting> nvcc linker> Libraries search path (-L) i’add
/ usr / local / lib / aarch64-linux-gnu (the path of libuvc.so.0 in the Jetson)

Then I reinstalled the libuvc library and it just worked. Surely the previous installation had some damaged file