Building jetson-inference based project

Hi,

The gist:
I am looking for help in setting up a project based on jetson-inference. Just FYI, I can successfully execute the examples on jetson-inference github . The bottom line is, I need to be able to write code using any and all of the concepts that are demonstrated in jetson-inference, a little “detectnet”, a little “imagenet”, some “segnet”, etc, and I need to be able to just include the right header files in my source code and then compile and run it. I have spent many many many hours trying to figure out how to do this but just haven’t been able to connect all of the dots.

P.S. if there’s a better way than what I’m doing I am open to it

The details:
Eventually I will write my own source code, but initially I’m trying to run one of the examples from the jetson-inference repo (detectnet or imagenet as a couple of examples) in my own workflow setup (this helps me know that I have met all of the dependencies I’ll need in my code). Below is what I’m currently trying to do, including my docker file, and the structure of my project.

#DOCKERFILE
# Specify the parent image from which we build
FROM dustynv/jetson-inference:r32.7.1

RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \
    && echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null

# setup dependancies needed inside the container (not apt-get update)
RUN set -ex;                                                \
    apt-get update;                                           

# Set the working directory inside the container
WORKDIR /app

# Copy files from your host to the working directory in the container
COPY ./container_src container

# Build the application with cmake inside the container
RUN set -ex;                                                \
    cd /app/container/build;                                \
    cmake ..;                                               \
    make;

# Run the application
CMD ["/app/container/build/secretSquirrel"]

Top level folder with docker file in it


container_src folder

src folder
image
My CMakeLists.txt file looks like this

# CMake minimum version
cmake_minimum_required(VERSION 3.22)

# Set the C++14 standard
set(CMAKE_CXX_STANDARD 14)

# Project Name
project(OperationSquirrel)

# Specify desired name of executable
set(MYEXEC secretSquirrel)

# Specify location of includes, './inc' in this case
set(MYINCLUDES inc 
../../usr/include/glib-2.0/ 
../../usr/include/gstreamer-1.0/ 
../../usr/include/python3.6m/ 
../../usr/lib/aarch64-linux-gnu/glib-2.0/include/ 
../../usr/local/cuda-10.2/targets/aarch64-linux/include/ 
../../usr/local/include/jetson-inference/ 
../../usr/local/include/jetson-inference/docs/html/ 
../../usr/local/include/jetson-utils/)

# Specify location of src files, './src' in this case
set(MYSRC src)

# I../includes
include_directories(${MYSRC} ${MYINCLUDES})

# Put all .cpp files inside src into SOURCES variable
file(GLOB SOURCES
	${MYSRC}/*.cpp
)

# Compile the files defined by SOURCES to generate exec defined by EXEC
add_executable(${MYEXEC} ${SOURCES})

When trying to build the container using the above docker file I received a bunch of "can't find <headerfile>.h" so I scoured the contents of the container to find all of the dependencies I needed and included them in my CMakeLists.txt file as you can see. I still get errors with functions not being defined or declared (can’t remember off of the top of my head". I even tried copying all of the dang header files into my “inc” folder, and am still running into errors.

Hi @crose72, sorry that you’ve been having trouble! Have you looked at the project structure of the “my_recognition” example? https://github.com/dusty-nv/jetson-inference/tree/master/examples/my-recognition

That example is meant to be a standalone program that can be built outside of the jetson-inference source tree. If you are getting more compilation errors, can you post them here? Thanks!

Hi @dusty_nv

Alright I was able to successfully build the “my_recognition” example and run the executable that was created (outside of the jetson-inference source tree).

I next attempted to swap out the “my-recognition.cpp” file with the “detectnet.cpp” file and then try building, but I get the error detectnet.cpp:23:10: fatal error: videoSource.h: No such file or directory #include "videoSource.h".
I guess I kind of expected that, but I thought that the lines
find_package(jetson-utils)
find_package(jetson-inference)
in the “CMakeLists.txt” file would take care of that (I’m using the CMakeLists.txt file for the "my_recognition example, just swapped out the name of he cpp file to compile). I’m thinking that “videoSource.h” is a standard header file that I’ll need in my project (correct me if I’m wrong) which is why I’m trying to. I’m sure other header files are gonna be considered a problem as soon as we can find “videoSource.h” lol, but one thing at at time!

My question might be, how do I write code that utilizes all of the jetson-inference concepts (and more) outside of the jetson-inference source tree? Do I just need to add an extra path to my includes? For example “/videoSource.h” and so on for everything? Ideally I’d like to just include the header file itself with no addition paths specified, but I’ll do whatever works

When you are building from outside the source tree, you should change the includes so they are like they are in my-recognition.cpp, like this:

#include <jetson-inference/detectNet.h>
#include <jetson-utils/videoSource.h>

Or you should just be able to add this to your CMakeLists:

include_directories(/usr/local/include/jetson-inference /usr/local/include/jetson-utils)

I’ll make a note to change all of the C++ examples to that they use the qualified paths like my-recognition does, to avoid this confusion in the future for people trying to build that code out-of-tree - sorry about that!

@dusty_nv oh this was low hanging fruit I should’ve been able to figure that out, that worked, thank you!

And for anyone else reading this I also used the same CMakeLists.txt file as the “my-recognition” example, and just swapped out the .cpp file name to get detectnet to work. Just thought that may be helpful to someone.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.