Using webcam on Jetson Nano running on YOLO

Hi I am using USB webcams and not the Raspberry Pi camera :D

Hi, my yolo version is 3 and not 4 but when I changed the 4 into 3, the object detection works as usual but the video viewer does not come out to the screen.

Post the command you used. Did you chang both #4 to #3 like

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights /dev/video0

yep I did. But the problem is still the same. I got the same error with no video-stream out.

./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights /dev/video0
CUDA-version: 10020 (10020), cuDNN: 8.0.0, GPU count: 1
OpenCV version: 4.5.2
Demo
0 : compute_capability = 530, cudnn_half = 0, GPU: NVIDIA Tegra X1
net.optimized_memory = 0
mini_batch = 1, batch = 1, time_steps = 1, train = 0
layer filters size/strd(dil) input output
0 Create CUDA-stream - 0
Create cudnn-handle 0
conv 32 3 x 3/ 1 416 x 416 x 3 β†’ 416 x 416 x 32 0.299 BF
1 conv 64 3 x 3/ 2 416 x 416 x 32 β†’ 208 x 208 x 64 1.595 BF
2 conv 32 1 x 1/ 1 208 x 208 x 64 β†’ 208 x 208 x 32 0.177 BF
3 conv 64 3 x 3/ 1 208 x 208 x 32 β†’ 208 x 208 x 64 1.595 BF
4 Shortcut Layer: 1, wt = 0, wn = 0, outputs: 208 x 208 x 64 0.003 BF
5 conv 128 3 x 3/ 2 208 x 208 x 64 β†’ 104 x 104 x 128 1.595 BF
6 conv 64 1 x 1/ 1 104 x 104 x 128 β†’ 104 x 104 x 64 0.177 BF
7 conv 128 3 x 3/ 1 104 x 104 x 64 β†’ 104 x 104 x 128 1.595 BF
8 Shortcut Layer: 5, wt = 0, wn = 0, outputs: 104 x 104 x 128 0.001 BF
9 conv 64 1 x 1/ 1 104 x 104 x 128 β†’ 104 x 104 x 64 0.177 BF
10 conv 128 3 x 3/ 1 104 x 104 x 64 β†’ 104 x 104 x 128 1.595 BF
11 Shortcut Layer: 8, wt = 0, wn = 0, outputs: 104 x 104 x 128 0.001 BF
12 conv 256 3 x 3/ 2 104 x 104 x 128 β†’ 52 x 52 x 256 1.595 BF
13 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
14 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
15 Shortcut Layer: 12, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
16 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
17 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
18 Shortcut Layer: 15, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
19 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
20 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
21 Shortcut Layer: 18, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
22 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
23 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
24 Shortcut Layer: 21, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
25 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
26 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
27 Shortcut Layer: 24, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
28 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
29 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
30 Shortcut Layer: 27, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
31 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
32 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
33 Shortcut Layer: 30, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
34 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
35 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
36 Shortcut Layer: 33, wt = 0, wn = 0, outputs: 52 x 52 x 256 0.001 BF
37 conv 512 3 x 3/ 2 52 x 52 x 256 β†’ 26 x 26 x 512 1.595 BF
38 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
39 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
40 Shortcut Layer: 37, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
41 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
42 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
43 Shortcut Layer: 40, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
44 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
45 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
46 Shortcut Layer: 43, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
47 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
48 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
49 Shortcut Layer: 46, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
50 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
51 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
52 Shortcut Layer: 49, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
53 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
54 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
55 Shortcut Layer: 52, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
56 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
57 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
58 Shortcut Layer: 55, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
59 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
60 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
61 Shortcut Layer: 58, wt = 0, wn = 0, outputs: 26 x 26 x 512 0.000 BF
62 conv 1024 3 x 3/ 2 26 x 26 x 512 β†’ 13 x 13 x1024 1.595 BF
63 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
64 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
65 Shortcut Layer: 62, wt = 0, wn = 0, outputs: 13 x 13 x1024 0.000 BF
66 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
67 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
68 Shortcut Layer: 65, wt = 0, wn = 0, outputs: 13 x 13 x1024 0.000 BF
69 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
70 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
71 Shortcut Layer: 68, wt = 0, wn = 0, outputs: 13 x 13 x1024 0.000 BF
72 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
73 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
74 Shortcut Layer: 71, wt = 0, wn = 0, outputs: 13 x 13 x1024 0.000 BF
75 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
76 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
77 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
78 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
79 conv 512 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 512 0.177 BF
80 conv 1024 3 x 3/ 1 13 x 13 x 512 β†’ 13 x 13 x1024 1.595 BF
81 conv 255 1 x 1/ 1 13 x 13 x1024 β†’ 13 x 13 x 255 0.088 BF
82 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.00
83 route 79 β†’ 13 x 13 x 512
84 conv 256 1 x 1/ 1 13 x 13 x 512 β†’ 13 x 13 x 256 0.044 BF
85 upsample 2x 13 x 13 x 256 β†’ 26 x 26 x 256
86 route 85 61 β†’ 26 x 26 x 768
87 conv 256 1 x 1/ 1 26 x 26 x 768 β†’ 26 x 26 x 256 0.266 BF
88 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
89 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
90 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
91 conv 256 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 256 0.177 BF
92 conv 512 3 x 3/ 1 26 x 26 x 256 β†’ 26 x 26 x 512 1.595 BF
93 conv 255 1 x 1/ 1 26 x 26 x 512 β†’ 26 x 26 x 255 0.177 BF
94 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.00
95 route 91 β†’ 26 x 26 x 256
96 conv 128 1 x 1/ 1 26 x 26 x 256 β†’ 26 x 26 x 128 0.044 BF
97 upsample 2x 26 x 26 x 128 β†’ 52 x 52 x 128
98 route 97 36 β†’ 52 x 52 x 384
99 conv 128 1 x 1/ 1 52 x 52 x 384 β†’ 52 x 52 x 128 0.266 BF
100 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
101 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
102 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
103 conv 128 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 128 0.177 BF
104 conv 256 3 x 3/ 1 52 x 52 x 128 β†’ 52 x 52 x 256 1.595 BF
105 conv 255 1 x 1/ 1 52 x 52 x 256 β†’ 52 x 52 x 255 0.353 BF
106 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.00
Total BFLOPS 65.879
avg_outputs = 532444
Allocate additional workspace_size = 52.43 MB
Loading weights from yolov3.weights…
seen 64, trained: 32013 K-images (500 Kilo-batches_64)
Done! Loaded 107 layers from weights-file
video file: /dev/video0
[ WARN:0] global /home/megan/opencv/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module source reported: Could not read from resource.
[ WARN:0] global /home/megan/opencv/modules/videoio/src/cap_gstreamer.cpp (1034) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/megan/opencv/modules/videoio/src/cap_gstreamer.cpp (597) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Video stream: 640 x 480
OpenCV exception: create_window_cv
Objects:

FPS:0.0 AVG_FPS:0.0
OpenCV exception: wait_key_cv
Objects:

laptop: 45%
diningtable: 85%
diningtable: 52%
chair: 100%
chair: 99%
chair: 97%
chair: 36%
bottle: 72%
bottle: 31%
handbag: 35%
person: 98%
person: 97%
person: 94%

FPS:0.2 AVG_FPS:0.0
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 33%
diningtable: 85%
diningtable: 49%
chair: 99%
chair: 99%
chair: 97%
chair: 43%
chair: 33%
bottle: 71%
bottle: 33%
handbag: 27%
person: 98%
person: 98%
person: 94%

FPS:0.3 AVG_FPS:0.0
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 44%
diningtable: 87%
diningtable: 51%
chair: 99%
chair: 98%
chair: 97%
chair: 43%
chair: 31%
bottle: 74%
bottle: 33%
handbag: 34%
person: 98%
person: 97%
person: 91%

FPS:0.5 AVG_FPS:0.0
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 46%
diningtable: 87%
diningtable: 42%
chair: 99%
chair: 98%
chair: 97%
chair: 42%
chair: 31%
bottle: 75%
bottle: 30%
handbag: 33%
person: 99%
person: 98%
person: 92%

FPS:0.6 AVG_FPS:0.0
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 50%
tvmonitor: 52%
diningtable: 84%
diningtable: 42%
chair: 100%
chair: 98%
chair: 98%
chair: 47%
chair: 29%
bottle: 74%
bottle: 30%
handbag: 34%
person: 99%
person: 97%
person: 95%

FPS:0.7 AVG_FPS:0.0
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 44%
tvmonitor: 32%
diningtable: 86%
diningtable: 44%
chair: 99%
chair: 98%
chair: 97%
chair: 55%
bottle: 76%
handbag: 33%
person: 99%
person: 97%
person: 96%

FPS:0.8 AVG_FPS:1.7
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 49%
diningtable: 85%
diningtable: 42%
chair: 99%
chair: 98%
chair: 98%
chair: 54%
chair: 30%
bottle: 69%
bottle: 25%
handbag: 33%
person: 99%
person: 99%
person: 98%

FPS:0.9 AVG_FPS:1.7
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 38%
diningtable: 87%
diningtable: 42%
chair: 99%
chair: 98%
chair: 98%
chair: 53%
chair: 28%
bottle: 77%
bottle: 32%
handbag: 32%
person: 99%
person: 96%
person: 92%

FPS:1.0 AVG_FPS:1.7
OpenCV exception: show_image_mat
OpenCV exception: wait_key_cv
Objects:

laptop: 46%
diningtable: 48%
diningtable: 39%
diningtable: 30%
chair: 99%
chair: 93%
chair: 88%
chair: 46%
chair: 38%
bottle: 70%
suitcase: 27%
handbag: 32%

What power mode are you set at? Are you at MAX 4 cores or something else? I think I was getting 5 fps on the Nano when I ran this on it. Kill all other apps and windows before starting it.

Do you get video just running gststreamer?

I think this should produce video.
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, format=MJPG ! jpegdec ! xvimagesink

My Linux environment is running at 0:MAXN.

I think this should produce video. for test
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, format=MJPG ! jpegdec ! xvimagesink

Hi, doesn’t seem to work.

ok this ran on my Nano β€œpulled from archive i no longer have nano”

gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, framerate=30/1, format=MJPG ! jpegdec ! xvimagesink

If you cant play video like this the problem may be with gst-launch

Okay, I have tried the above code, but it gave me the same error. However, I’m very sure that the webcam works because I could switched it on using GoogleNet and MobileNetV2 SSD.

Good info for yolo and nano here: https://jkjung-avt.github.io/
I would look at the required packages he had installed you might be missing some required package. Sorry cant be of much more help.

Oops: below

okay thank you so much! Will check it out :D

1 Like