In the tutorial the process is mentioned: note: by default, the Jetson’s onboard CSI camera will be used as the video source. If you wish to use a USB webcam instead, change the DEFAULT_CAMERA define at the top of imagenet-camera.cpp to reflect the /dev/video V4L2 device of your USB camera…
Now I tried to compile my changes and I get errors like “gstCamera.h” is missing. (which I was expecting…)
Can someone tell me how to compile/build this properly? (Sorry I am not so familar to the “make” process)
I only want to build my modified imagenet-camera.cpp, which is called “imagenet-camera_mod.cpp”
If you are building your modified project out-of-tree, you probably need to add an include directory to your compiler’s include path (jetson-inference/build/aarch64/include). Or you could run ‘sudo make install’ on jetson-inference repo and it will install the headers to a common system location.
If you continue having issues, it may be easier to just modify imagenet-camera.cpp directly, or to copy the imagenet-camera folder in the source tree and add your new folder to jetson-inference/CMakeLists.txt
Whenever you add new source file or subproject to jetson-inference, re-run ‘cmake …/’ step from the build directory to pick up the changes.
How to find the index of /dev/video V4L2, so I can change -1 into my webcam index?
I try to use index = 1.
#define DEFAULT_CAMERA 1
Then I modify my CMakeList.txt as follows:
# require CMake 2.8 or greater
cmake_minimum_required(VERSION 3.10)
# declare my-recognition project
project(imagenet-webcam)
# import jetson-inference and jetson-utils packages.
# note that if you didn't do "sudo make install"
# while building jetson-inference, this will error.
find_package(jetson-utils)
find_package(jetson-inference)
# CUDA and Qt4 are required
find_package(CUDA)
find_package(Qt4)
# setup Qt4 for build
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
file(GLOB imagenetCameraSources *.cpp)
file(GLOB imagenetCameraIncludes *.h )
# compile the imagenet-webcam program
cuda_add_library(jetson-inference SHARED ${inferenceSources})
# cuda_add_executable(imagenet-webcam imagenet-webcam.cpp)
cuda_add_executable(imagenet-webcam ${imagenetCameraSources})
# link my-recognition to jetson-inference library
target_link_libraries(imagenet-webcam jetson-inference)
install(TARGETS imagenet-webcam DESTINATION bin)
Then I issue command: $ cmake .
suryadi@nonaku:~/jetson-inference/imagenet-camera$ cmake .
CMake Error at /usr/share/cmake-3.10/Modules/FindCUDA.cmake:1801 (add_library):
add_library cannot create target "jetson-inference" because an imported
target with the same name already exists.
Call Stack (most recent call first):
CMakeLists.txt:25 (cuda_add_library)
-- Configuring incomplete, errors occurred!
See also "/home/suryadi/jetson-inference/imagenet-camera/CMakeFiles/CMakeOutput.log".
See also "/home/suryadi/jetson-inference/imagenet-camera/CMakeFiles/CMakeError.log".
So #define DEFAULT_CAMERA 0 in imagenet-camera.cpp
I would recommend editing imagenet-camera.cpp directly first, and then simply recompiling by running make command. Then once you get it working, you can move on to adding your own application to the build.
Please help to make CMakeList.txt correctly, so I freely create another program beside from the repository.
I mesh up the imagenet-camera program then I delete ~/jetson-inference directory and restart from the start.
Is there a way so I did not need to cmake …/ (because it must download all the neural network from the start again)?
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV'
Field : None
Bytes per Line : 1280
Size Image : 614400
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
I edit imagenet-camera.cpp
// from gstCamera* camera = gstCamera::Create(DEFAULT_CAMERA);
gstCamera* camera = gstCamera::Create(640, 480, DEFAULT_CAMERA);
It works
Please help me, how to compile just imagenet-camera.cpp alone. Because I need to create another program outside the repository environment.
~/jetson-inference/imagenet-camera$gcc -I /home/suryadi/jetson-inference/build/aarch64/include/ /usr/include/gstreamer-1.0/ -L /home/suryadi/jetson-inference/build/aarch64/lib imagenet-camera.cpp
the error is as follow:
In file included from imagenet-camera.cpp:23:0:
/home/suryadi/jetson-inference/build/aarch64/include/gstCamera.h:26:10: fatal error: gst/gst.h: No such file or directory
#include <gst/gst.h>
^~~~~~~~~~~
After I download NVIDIA-Aerial-Drone-Dataset.tar.gz (7.1 GB), I ran out space at my Jetson Nano. So I move whole directory jetson-inference from /home/suryadi into /media/suryadi/TOSHIBA EXT (1 TB external harddisk).
When I try to compile programs, it give error as follow:
/media/suryadi/TOSHIBA EXT/jetson-inference/build$ cmake ../
CMake Error: The current CMakeCache.txt directory /media/suryadi/TOSHIBA EXT/jetson-inference/build/CMakeCache.txt is different than the directory /home/suryadi/jetson-inference/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
CMake Error: The source "/media/suryadi/TOSHIBA EXT/jetson-inference/CMakeLists.txt" does not match the source "/home/suryadi/jetson-inference/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
I am struggling with J0eBl4ck’s original issue. I am building a project out of tree, and unfortunately have no choice in the matter. I currently am just trying to get the imagenet-camera example to compile and run out-of-tree. I have copied it into a new folder and modified the CMakeLists.txt file as follows:
require CMake 2.8 or greater
cmake_minimum_required(VERSION 2.8)
declare RoadDetection project
project(imagenet-camera)
import jetson-inference and jetson-utils packages.
Upon building I get errors such as “fatal error: gstCamera.h: No such file or directory #include “gstCamera.h””. I have run sudo make install from the jetson-inference folder but the issue persists. If I were to manually copy the gstCamera.h file into this new folder it would solve that error but I would have to do the same for all included header files which turns out to be a long list. Any advice on getting this to build on its own is welcomed.
Or you could skip manually including the jetson-inference/build/aarch64/include/* dirs in your CMakeLists if you changed the #include statements in imagenet-camera.cpp to be like: