Ubuntu(Jetson nano) qtcreator配置Libtorch、Qt、opencv

opencv configuration jetson nano comes with opencv

#opencv
INCLUDEPATH += \
        /usr/include/opencv4/opencv2 \
        /usr/include/opencv4

LIBS += /usr/lib/aarch64-linux-gnu/libopencv*

libtorch Note that nvidia is changed to your own user name. If you install it according to the official tutorial, this is the default installation location of libtorch

#libtorch
INCLUDEPATH += \
        /home/nvidia/.local/lib/python3.6/site-packages/torch/include/torch/csrc/api/include/ \
        /home/nvidia/.local/lib/python3.6/site-packages/torch/include/ \

LIBS += \
        /home/nvidia/.local/lib/python3.6/site-packages/torch/lib/*.so \
        -L/home/nvidia/.local/lib/python3.6/site-packages/torch/lib/ \
        -Wl,--no-as-needed -ltorch_cuda # force to link torch_cuda

Replenish:

  1. Regarding the conflict between qt and libtorch, use this method when introducing torch header files, the slots of qt and the slots of libtorch conflict
#undef slots
#include <torch/torch.h>
#include <torch/script.h>
#define slots Q_SLOTS
  1. Regarding the conflict between opencv and libtorch, since libtorch and opencv have some namespace conflicts, the source code needs to be modified. Most of the modification methods need to read the error report, which thing is in conflict, and add using namespcae c10::xxxxx (xxx refers to the conflicting thing) in the line below the using namespace at{ at the top of the file . refer to

Guess you like

Origin blog.csdn.net/rglkt/article/details/125508634