Yolov3 on Jetson Nano can't compile videos

Hello! I’m using Yolov3 from Darknet (https://pjreddie.com/darknet/install/) with OpenCV v.4.1.0 (https://create.botmation.net/p/this-is-quick-guide-to-get-you-started.html), but when I run the command on Terminal it don’t recognize OpenCV:

$ ./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights video.mp4
Demo needs OpenCV for webcam images.

And a have a RPi Camera connected to Jetson Nano, and still can’t detect it :(

I’ve already tried this options:
1. Change Makefile:

GPU=1
CUDNN=1
OPENCV=1
OPENMP=0
DEBUG=0
ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]

Then I run make on darknet folder and have this:

$ make
g++ -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -DCUDNN  -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -DCUDNN -c ./src/image_opencv.cpp -o obj/image_opencv.o
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
./src/image_opencv.cpp:5:10: fatal error: opencv2/opencv.hpp: No such file or directory
 #include "opencv2/opencv.hpp"
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:86: recipe for target 'obj/image_opencv.o' failed
make: *** [obj/image_opencv.o] Error 1
  1. So, I checked the cmake command on OpenCV installer (opencv-4.1.0 folder) and add -D OPENCV_GENERATE_PKGCONFIG=ON and install again.
$ cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_PC_FILE_NAME=opencv.pc CMAKE_INSTALL_PREFIX=/usr/local ..

But when I come back to darknet folder on terminal, I run make and have the same result.

3. Finally, I tried making a opencv.pc file in /usr/local/lib/ with this:

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv4/opencv
includedir_new=${prefix}/include/opencv4

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.1.0
Libs: -L${exec_prefix}/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_old} -I${includedir_new}

And guess What? Still nothing haha
Well, that’s all.
Please give me a hint :c

PD: The reason that I choose OpenCV 4.1.0 is because that I can’t use RPi Camera without GStreamer on Jetson Nano.
PD2: It’s the same with Yolov3-Tiny.

Hi,

It looks like your darknet app cannot find the OpenCV library correctly.

./src/image_opencv.cpp:5:10: fatal error: opencv2/opencv.hpp: No such file or directory

Do you build the OpenCV from source on your own?
If yes, have you executed “make install” to push the header and libraries into /usr/xxx?

Thanks.

Yes, I installed OpenCV 4.1.0 from source and I used this code:

sudo apt-get update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
sudo apt-get install -y curl
sudo apt install -y python3-pip
sudo apt-get update

wget https://github.com/opencv/opencv/archive/4.1.0.zip -O opencv-4.1.0.zip
wget https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -O opencv-contrib-4.1.0.zip
unzip opencv-4.1.0.zip
unzip opencv-contrib-4.1.0.zip
cd opencv-4.1.0/

mkdir release
cd release/
cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j3
sudo make install
sudo apt-get install -y python-opencv python3-opencv
sudo apt-get install -y libjpeg-dev 
pip3 install --user pillow

Hi,

It looks like this issue is related to the OpenCV version:
https://github.com/pjreddie/darknet/issues/1072#issuecomment-418523136

for Yolo v3 from Darknet - you should use OpenCV <= 3.4.0
for Yolo v3 from OpenCV  - you should use OpenCV >= 3.4.2

Would you mind to lower the OpenCV version to 3.4.0 and try it again?

Thanks.

Could you please explain how I can install OpenCV version 3.4.0 (or less) as the standard version on the jetson nano device is 3.4.6 and is incompatible with Darknet. i have tried installing from source but could not get a working solution in the end.