Darknet on Jetson Nano with Sony IMX219 green screen problem - opencv

I am currently trying to run object detection on Jetson Nano with sony IMX219 camera
https://www.waveshare.com/imx219-170-camera.htm
I am trying to run darknet with camera 0:
./darknet detector demo cfg/coco_znacenie.data cfg/yolov3-tiny_znacenie.cfg znacenie1.weights -c 0
And output is:
CUDA-version: 10000 (10000), cuDNN: 7.6.3, GPU count: 1
OpenCV version: 4.1.1
Demo
compute_capability = 530, cudnn_half = 0
net.optimized_memory = 0
mini_batch = 1, batch = 2, time_steps = 1, train = 0
layer filters size/strd(dil) input output
0 conv 16 3 x 3/ 1 416 x 416 x 3 -> 416 x 416 x 16 0.150 BF
1 max 2x 2/ 2 416 x 416 x 16 -> 208 x 208 x 16 0.003 BF
2 conv 32 3 x 3/ 1 208 x 208 x 16 -> 208 x 208 x 32 0.399 BF
3 max 2x 2/ 2 208 x 208 x 32 -> 104 x 104 x 32 0.001 BF
4 conv 64 3 x 3/ 1 104 x 104 x 32 -> 104 x 104 x 64 0.399 BF
5 max 2x 2/ 2 104 x 104 x 64 -> 52 x 52 x 64 0.001 BF
6 conv 128 3 x 3/ 1 52 x 52 x 64 -> 52 x 52 x 128 0.399 BF
7 max 2x 2/ 2 52 x 52 x 128 -> 26 x 26 x 128 0.000 BF
8 conv 256 3 x 3/ 1 26 x 26 x 128 -> 26 x 26 x 256 0.399 BF
9 max 2x 2/ 2 26 x 26 x 256 -> 13 x 13 x 256 0.000 BF
10 conv 512 3 x 3/ 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BF
11 max 2x 2/ 1 13 x 13 x 512 -> 13 x 13 x 512 0.000 BF
12 conv 1024 3 x 3/ 1 13 x 13 x 512 -> 13 x 13 x1024 1.595 BF
13 conv 256 1 x 1/ 1 13 x 13 x1024 -> 13 x 13 x 256 0.089 BF
14 conv 512 3 x 3/ 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BF
15 conv 18 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 18 0.003 BF
16 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, cls_norm: 1.00, scale_x_y: 1.00
17 route 13 -> 13 x 13 x 256
18 conv 128 1 x 1/ 1 13 x 13 x 256 -> 13 x 13 x 128 0.011 BF
19 upsample 2x 13 x 13 x 128 -> 26 x 26 x 128
20 route 19 8 -> 26 x 26 x 384
21 conv 256 3 x 3/ 1 26 x 26 x 384 -> 26 x 26 x 256 1.196 BF
22 conv 18 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 18 0.006 BF
23 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, cls_norm: 1.00, scale_x_y: 1.00
Total BFLOPS 5.448
avg_outputs = 324846
Allocate additional workspace_size = 13.11 MB
Loading weights from znacenie1.weights...
seen 64, trained: 320 K-images (5 Kilo-batches_64)
Done! Loaded 24 layers from weights-file
Webcam index: 0
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Internal data stream error.
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Video stream: 3264 x 2464
But input from camera is green:
Camera is working when I run it by:
gst-launch-1.0 nvarguscamerasrc sensor_mode=0 ! 'video/x-raw(memory:NVMM),width=3280, height=2464, framerate=21/1, format=NV12' ! nvvidconv flip-method=0 ! 'video/x-raw,width=3280, height=2464' ! nvvidconv flip-method=2 ! nvegltransform ! nveglglessink -e
I was trying to test my camera in chromium but chromium wasn't able to detect camera:
I am using clean installation of latest image for my Jetson Nano and everything is up to date. I've already tried different versions of OpenCv but without any progress.
Anybody know what should I try?
EDIT:
Just found how to solve it:
./darknet detector demo cfg/coco_znacenie.data cfg/yolov3-tiny_znacenie.cfg znacenie1.weights "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=1920, height=1080, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"

Related

Can't open label file. (This can be normal only if you use MSCOCO) Yolo

I am getting this error during the training of Yolo.
.data file has
classes = 1
train = data/train.txt
valid = data/valid.txt
names = classes.names
backup = backup
train.txt has been placed in "data" folder where complete set of images are there.
train.txt contains:
data/f1a92173-262b-42d1-b64e-213cdf6afdae.jpg
data/92ef9a59-d770-40b6-9ef5-2f909d6cc1c8.jpg
data/ea94af95-b492-4123-9fd7-04ef7ec79608.jpg
data/d288b5f6-f976-4fca-b7a1-b64cb6475d51.jpg
data/6e74d273-9bdb-4fb0-8a0c-edfda365df2e.jpg
data/a886d1b3-9373-46c6-9c65-b224c21cc4a1.jpg
data/89beedca-e0ce-45df-b840-218f54de8fae.jpg
data/3be0c383-ad5b-422e-a003-5676bc9d66df.jpg
data/04204973-a034-4a50-a43e-2ae45186aa50.jpg
data/aaabfc1b-6519-4c80-ad64-60612890501d.jpg
data/bb10de59-4206-46ca-b28d-c0750d460829.jpg
...
cfg files have been modified appropriately and the command which is being used to run the training is:
!darknet/darknet detector train labelled_data.data darknet/cfg/yolov4_custom.cfg custom_weight/yolov4.conv.137 -dont_show
I am using Colab to run the model.
The error which I am getting is:(Compete logs)
CUDA-version: 10010 (11020), cuDNN: 7.6.5, GPU count: 1
OpenCV version: 3.2.0
yolov4_custom
0 : compute_capability = 750, cudnn_half = 0, GPU: Tesla T4
net.optimized_memory = 0
mini_batch = 4, batch = 64, time_steps = 1, train = 1
layer filters size/strd(dil) input output
0 conv 32 3 x 3/ 1 608 x 608 x 1 -> 608 x 608 x 32 0.213 BF
1 conv 64 3 x 3/ 2 608 x 608 x 32 -> 304 x 304 x 64 3.407 BF
2 conv 64 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 64 0.757 BF
3 route 1 -> 304 x 304 x 64
4 conv 64 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 64 0.757 BF
5 conv 32 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 32 0.379 BF
6 conv 64 3 x 3/ 1 304 x 304 x 32 -> 304 x 304 x 64 3.407 BF
7 Shortcut Layer: 4, wt = 0, wn = 0, outputs: 304 x 304 x 64 0.006 BF
8 conv 64 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 64 0.757 BF
9 route 8 2 -> 304 x 304 x 128
10 conv 64 1 x 1/ 1 304 x 304 x 128 -> 304 x 304 x 64 1.514 BF
11 conv 128 3 x 3/ 2 304 x 304 x 64 -> 152 x 152 x 128 3.407 BF
12 conv 64 1 x 1/ 1 152 x 152 x 128 -> 152 x 152 x 64 0.379 BF
13 route 11 -> 152 x 152 x 128
14 conv 64 1 x 1/ 1 152 x 152 x 128 -> 152 x 152 x 64 0.379 BF
15 conv 64 1 x 1/ 1 152 x 152 x 64 -> 152 x 152 x 64 0.189 BF
16 conv 64 3 x 3/ 1 152 x 152 x 64 -> 152 x 152 x 64 1.703 BF
17 Shortcut Layer: 14, wt = 0, wn = 0, outputs: 152 x 152 x 64 0.001 BF
18 conv 64 1 x 1/ 1 152 x 152 x 64 -> 152 x 152 x 64 0.189 BF
19 conv 64 3 x 3/ 1 152 x 152 x 64 -> 152 x 152 x 64 1.703 BF
20 Shortcut Layer: 17, wt = 0, wn = 0, outputs: 152 x 152 x 64 0.001 BF
21 conv 64 1 x 1/ 1 152 x 152 x 64 -> 152 x 152 x 64 0.189 BF
22 route 21 12 -> 152 x 152 x 128
23 conv 128 1 x 1/ 1 152 x 152 x 128 -> 152 x 152 x 128 0.757 BF
24 conv 256 3 x 3/ 2 152 x 152 x 128 -> 76 x 76 x 256 3.407 BF
25 conv 128 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BF
26 route 24 -> 76 x 76 x 256
27 conv 128 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BF
28 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
29 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
30 Shortcut Layer: 27, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
31 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
32 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
33 Shortcut Layer: 30, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
34 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
35 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
36 Shortcut Layer: 33, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
37 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
38 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
39 Shortcut Layer: 36, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
40 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
41 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
42 Shortcut Layer: 39, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
43 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
44 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
45 Shortcut Layer: 42, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
46 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
47 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
48 Shortcut Layer: 45, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
49 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
50 conv 128 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 128 1.703 BF
51 Shortcut Layer: 48, wt = 0, wn = 0, outputs: 76 x 76 x 128 0.001 BF
52 conv 128 1 x 1/ 1 76 x 76 x 128 -> 76 x 76 x 128 0.189 BF
53 route 52 25 -> 76 x 76 x 256
54 conv 256 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 256 0.757 BF
55 conv 512 3 x 3/ 2 76 x 76 x 256 -> 38 x 38 x 512 3.407 BF
56 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
57 route 55 -> 38 x 38 x 512
58 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
59 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
60 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
61 Shortcut Layer: 58, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
62 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
63 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
64 Shortcut Layer: 61, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
65 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
66 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
67 Shortcut Layer: 64, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
68 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
69 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
70 Shortcut Layer: 67, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
71 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
72 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
73 Shortcut Layer: 70, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
74 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
75 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
76 Shortcut Layer: 73, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
77 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
78 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
79 Shortcut Layer: 76, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
80 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
81 conv 256 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 256 1.703 BF
82 Shortcut Layer: 79, wt = 0, wn = 0, outputs: 38 x 38 x 256 0.000 BF
83 conv 256 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 256 0.189 BF
84 route 83 56 -> 38 x 38 x 512
85 conv 512 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 512 0.757 BF
86 conv 1024 3 x 3/ 2 38 x 38 x 512 -> 19 x 19 x1024 3.407 BF
87 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
88 route 86 -> 19 x 19 x1024
89 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
90 conv 512 1 x 1/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.189 BF
91 conv 512 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x 512 1.703 BF
92 Shortcut Layer: 89, wt = 0, wn = 0, outputs: 19 x 19 x 512 0.000 BF
93 conv 512 1 x 1/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.189 BF
94 conv 512 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x 512 1.703 BF
95 Shortcut Layer: 92, wt = 0, wn = 0, outputs: 19 x 19 x 512 0.000 BF
96 conv 512 1 x 1/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.189 BF
97 conv 512 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x 512 1.703 BF
98 Shortcut Layer: 95, wt = 0, wn = 0, outputs: 19 x 19 x 512 0.000 BF
99 conv 512 1 x 1/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.189 BF
100 conv 512 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x 512 1.703 BF
101 Shortcut Layer: 98, wt = 0, wn = 0, outputs: 19 x 19 x 512 0.000 BF
102 conv 512 1 x 1/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.189 BF
103 route 102 87 -> 19 x 19 x1024
104 conv 1024 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x1024 0.757 BF
105 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
106 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
107 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
108 max 5x 5/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.005 BF
109 route 107 -> 19 x 19 x 512
110 max 9x 9/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.015 BF
111 route 107 -> 19 x 19 x 512
112 max 13x13/ 1 19 x 19 x 512 -> 19 x 19 x 512 0.031 BF
113 route 112 110 108 107 -> 19 x 19 x2048
114 conv 512 1 x 1/ 1 19 x 19 x2048 -> 19 x 19 x 512 0.757 BF
115 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
116 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
117 conv 256 1 x 1/ 1 19 x 19 x 512 -> 19 x 19 x 256 0.095 BF
118 upsample 2x 19 x 19 x 256 -> 38 x 38 x 256
119 route 85 -> 38 x 38 x 512
120 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
121 route 120 118 -> 38 x 38 x 512
122 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
123 conv 512 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BF
124 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
125 conv 512 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BF
126 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
127 conv 128 1 x 1/ 1 38 x 38 x 256 -> 38 x 38 x 128 0.095 BF
128 upsample 2x 38 x 38 x 128 -> 76 x 76 x 128
129 route 54 -> 76 x 76 x 256
130 conv 128 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BF
131 route 130 128 -> 76 x 76 x 256
132 conv 128 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BF
133 conv 256 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BF
134 conv 128 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BF
135 conv 256 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BF
136 conv 128 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 128 0.379 BF
137 conv 256 3 x 3/ 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BF
138 conv 18 1 x 1/ 1 76 x 76 x 256 -> 76 x 76 x 18 0.053 BF
139 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.20
nms_kind: greedynms (1), beta = 0.600000
140 route 136 -> 76 x 76 x 128
141 conv 256 3 x 3/ 2 76 x 76 x 128 -> 38 x 38 x 256 0.852 BF
142 route 141 126 -> 38 x 38 x 512
143 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
144 conv 512 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BF
145 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
146 conv 512 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BF
147 conv 256 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 256 0.379 BF
148 conv 512 3 x 3/ 1 38 x 38 x 256 -> 38 x 38 x 512 3.407 BF
149 conv 18 1 x 1/ 1 38 x 38 x 512 -> 38 x 38 x 18 0.027 BF
150 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.10
nms_kind: greedynms (1), beta = 0.600000
151 route 147 -> 38 x 38 x 256
152 conv 512 3 x 3/ 2 38 x 38 x 256 -> 19 x 19 x 512 0.852 BF
153 route 152 116 -> 19 x 19 x1024
154 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
155 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
156 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
157 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
158 conv 512 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 512 0.379 BF
159 conv 1024 3 x 3/ 1 19 x 19 x 512 -> 19 x 19 x1024 3.407 BF
160 conv 18 1 x 1/ 1 19 x 19 x1024 -> 19 x 19 x 18 0.013 BF
161 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.05
nms_kind: greedynms (1), beta = 0.600000
Unused field: 'yolov4-custom.cfg = (null)'
Unused field: 'OpenwithGoogleDocs = (null)'
Total BFLOPS 126.806
avg_outputs = 1046213
Allocate additional workspace_size = 52.43 MB
Loading weights from custom_weight/yolov4.conv.137...
seen 64, trained: 0 K-images (0 Kilo-batches_64)
Warning: Unexpected end of wights-file! l.rolling_mean - l.index = 137
Done! Loaded 137 layers from weights-file
Learning Rate: 0.001, Momentum: 0.949, Decay: 0.0005
Detection layer: 139 - type = 28
Detection layer: 150 - type = 28
Detection layer: 161 - type = 28
Resizing, random_coef = 1.40
896 x 896
Create 6 permanent cpu-threads
Cannot load image data/dd300129-d6f1-4ff4-8245-6baf4dfca61d.jpg
Cannot load image data/a2269867-3a23-4cd4-80ec-8c0f917f5986.jpg
Error in load_data_detection() - OpenCV
Error in load_data_detection() - OpenCV
Can't open label file. (This can be normal only if you use MSCOCO): data/0bbc209a-2a7a-43cb-8664-d6a337dee4a6.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/442b890c-34e0-4007-b085-c81ef82bb78c.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/c8138fcd-28e9-4a7d-a637-05d56816c864.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/b62a6a88-6ad1-43cf-ad59-6d171e89b265.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/78d2518f-eeb8-4234-ab5a-6f41e02b5692.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/f5310d22-83c1-4051-b114-843c10c67749.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/74f69a44-9224-4c14-a6a4-cffef6d1a757.txt
Cannot load image data/643a2621-274d-4c11-a609-507c044fda00.jpg
Error in load_data_detection() - OpenCV
Can't open label file. (This can be normal only if you use MSCOCO): data/8b6d9d85-61c3-4469-b7ca-5dff4047815d.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/06ba1322-0274-47e0-b7eb-07c11d96360f.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/ba8516cc-aa1b-4f6c-ac7a-e34c5b2cda39.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/bcb1273c-d917-4a7b-b882-928223847250.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/8b2e2e6b-422f-4196-9209-10c722b2e860.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/efb0bc45-0769-4e87-9724-071a776f4059.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/983ad361-c6a6-43c5-9aa2-c17b758a3901.txt
Cannot load image data/42122fc5-12ce-4840-ae13-5f70fffdc6e5.jpg
Error in load_data_detection() - OpenCV
Can't open label file. (This can be normal only if you use MSCOCO): data/7e64761d-6224-4888-8976-75453b8fc842.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/b62a6a88-6ad1-43cf-ad59-6d171e89b265.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/4ed5b2b2-9aa1-49f2-84e6-4f634744039e.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/1352a7f3-1f0d-4f1f-af05-daa5d7f8624a.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/46f37e46-e4cd-4677-875b-1f1b28cfc70d.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/195c5e5f-7058-48c5-8fe9-67cffd60c9b3.txt
Cannot load image data/c9ebce2f-0799-422a-9714-37c8880bf93a.jpg
Error in load_data_detection() - OpenCV
Can't open label file. (This can be normal only if you use MSCOCO): data/34034bf2-1e42-45e7-aad2-80df607373bb.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/fedfb751-4365-4ea3-a4d9-ac761534aca3.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/7e64761d-6224-4888-8976-75453b8fc842.txt
Cannot load image data/ebc3e487-6b56-41d3-847d-bb5b04297b9e.jpg
Can't open label file. (This can be normal only if you use MSCOCO): data/7981fc95-1551-4867-8681-2f2d8afc07d8.txt
Error in load_data_detection() - OpenCV
Can't open label file. (This can be normal only if you use MSCOCO): data/8b2543f1-89e6-41d2-8ede-ab0f9b797f41.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/377c27f9-b004-40b4-95b3-dc79b067314c.txt
Cannot load image data/f27e1121-c394-4577-80c6-762f47e916b2.jpg
Error in load_data_detection() - OpenCV
Can't open label file. (This can be normal only if you use MSCOCO): data/9b5ca700-e7f9-4c72-ae12-c1ff11d6b0b3.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/2ee27b62-e1d7-4341-bf2b-9d45dc4068a1.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/a62f0dd3-cf24-4f4e-a2ec-4b93ed207871.txt
Can't open label file. (This can be normal only if you use MSCOCO): data/2a4489f6-6f7b-46f5-a937-281206307943.txt
you have to place the yolo annotated label files '.txt' inside 'data/' folder.
data/f1a92173-262b-42d1-b64e-213cdf6afdae.jpg
data/f1a92173-262b-42d1-b64e-213cdf6afdae.txt
data/92ef9a59-d770-40b6-9ef5-2f909d6cc1c8.jpg
data/92ef9a59-d770-40b6-9ef5-2f909d6cc1c8.txt
...

Detection result not displayed in YOLO

I'm newest in YOLO.
I compile darknet in windows.>>darknet.exe
-Visual studio 2019
open cv 3.4
cuda 10.2
I tried to execute sample code.
> darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/dog.jpg
Code is runnning correctly and the prediction figure is shown, but detected result is not shown in the figure.
evaluation result (ex.dog 100%) may not be not calculated.
Log
C:\dev\darknet-master\build\darknet\x64> darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/dog.jpg
CUDA-version: 10020 (11000), cuDNN: 8.0.5, CUDNN_HALF=1, GPU count: 1
CUDNN_HALF=1
OpenCV version: 4.3.0
0 : compute_capability = 750, cudnn_half = 1, GPU: GeForce GTX 1650
net.optimized_memory = 0
mini_batch = 1, batch = 1, time_steps = 1, train = 0
layer filters size/strd(dil) input output
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 = 18.88 MB
Loading weights from yolov3.weights...
seen 64, trained: 32013 K-images (500 Kilo-batches_64)
Done! Loaded 107 layers from weights-file
Detection layer: 82 - type = 28
Detection layer: 94 - type = 28
Detection layer: 106 - type = 28
data/dog.jpg: Predicted in 629.940000 milli-seconds.
When you execute this command, it generates a file named predictions.jpg.
In it are the bounding boxes in the images.
It turns out that I must remove CUDNN_HALF from the pre-processors list in MS Visual Studio. PROBLEM SOLVED!
It's also important to add a threshold in the end of the line:
darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/dog.jpg thresh -0.5 -ext_output
If nothing appears, you can change the value. For example, to -0.3

imagemagick - find coordinates of outline of transparent png (not border)

While it's easily done to visually outline, is it possible to have imagemagick output the coordinates of the outline of a transparent image?
Note, by outline, I don't mean just the bounding box border, but the actual contour around an arbitrarily shaped transparent image geometry.
Let's say you start with this image, which has a transparent background:
You can extract the transparency and find the edges like this:
convert penguin.png -alpha extract -edge 1 -threshold 50% edges.png
If, rather than an image, you want a list of the coordinates of the contour (i.e. the white pixels), you could do this instead:
convert penguin.png -alpha extract -edge 1 -threshold 50% -depth 8 txt: | awk -F: '/white/{print $1}'
256,0
253,1
254,1
255,1
257,1
258,1
259,1
253,2
259,2
252,3
253,3
...
...
Replace awk and everything after it with more to see what the awk is actually doing - it is just printing the coordinates of every pixel that is white.
The above pixels come out in row order, not like a contour where adjacent pixels come out together. If you want that, you might prefer to generate an SVG of the transparency with potrace like this:
convert penguin.png -alpha extract -threshold 50% pgm:- | potrace - --svg < alpha.pgm > result.svg
Output
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="500.000000pt" height="577.000000pt" viewBox="0 0 500.000000 577.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.13, written by Peter Selinger 2001-2015
</metadata>
<g transform="translate(0.000000,577.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M0 3294 l0 -2476 25 16 c31 20 104 21 152 1 20 -8 38 -14 40 -12 2 2
-8 35 -23 73 -49 129 -29 246 43 260 51 10 109 -12 159 -58 43 -40 44 -40 44
-15 0 41 60 120 99 130 28 7 32 11 26 30 -24 70 -15 385 16 637 44 346 171
715 351 1023 34 58 35 77 5 77 -43 0 -242 47 -277 65 -68 35 -196 130 -248
185 -83 86 -119 154 -153 286 -31 124 -38 237 -18 307 13 49 15 49 91 -15 177
-151 388 -309 477 -357 42 -23 108 -60 146 -81 76 -43 194 -83 228 -78 19 3
23 12 28 60 4 32 12 65 19 73 15 18 16 17 -35 34 -88 29 -255 122 -255 141 0
5 12 15 27 22 24 11 48 10 168 -9 77 -12 179 -22 226 -23 80 0 87 2 111 28 60
64 64 105 11 123 -21 6 -76 30 -122 51 l-84 39 -30 -21 c-21 -16 -32 -19 -40
-11 -19 19 8 54 63 84 46 25 59 27 109 22 31 -3 66 -8 79 -11 77 -16 -65 130
-178 182 -84 38 -150 45 -340 35 -225 -12 -242 -15 -322 -55 -57 -28 -68 -31
-68 -17 0 26 77 95 150 134 206 112 479 177 741 177 l97 0 -20 38 c-37 70 -10
186 68 294 54 75 56 88 23 119 -16 15 -29 36 -29 47 0 12 -4 24 -10 27 -19 12
-10 57 18 94 69 89 125 236 167 431 24 113 41 148 68 137 19 -7 43 -83 52
-162 l7 -60 33 90 c18 50 36 110 40 135 10 61 55 111 55 61 0 -11 9 -35 20
-54 29 -49 40 -235 17 -289 -9 -21 -12 -38 -8 -38 4 0 34 22 65 50 31 27 66
55 78 61 20 11 21 9 14 -22 -3 -18 -24 -72 -46 -119 -22 -48 -40 -90 -40 -94
0 -14 43 17 110 80 143 136 324 456 306 545 -4 21 -1 31 12 38 11 7 -402 10
-1260 11 l-1278 0 0 -2476z"/>
<path d="M2613 5669 c17 -82 18 -107 9 -133 -7 -18 -12 -47 -12 -64 0 -18 -14
-60 -31 -93 -17 -34 -28 -64 -25 -67 10 -10 49 17 129 88 43 39 84 70 92 70
23 0 17 -31 -15 -79 -17 -24 -30 -49 -30 -56 0 -6 -32 -58 -70 -115 -39 -56
-69 -104 -67 -106 4 -5 111 33 153 54 33 17 42 18 57 7 9 -7 17 -17 17 -23 0
-16 -104 -125 -134 -141 -14 -8 -26 -17 -26 -20 0 -4 23 -17 50 -30 53 -25
100 -63 100 -80 0 -19 -36 -30 -116 -36 -43 -3 -103 -8 -133 -11 l-54 -6 82
-80 c92 -90 185 -225 230 -331 34 -83 71 -217 71 -260 0 -15 5 -38 12 -50 18
-34 31 -169 29 -311 -1 -97 2 -133 12 -145 8 -9 29 -43 47 -76 19 -33 58 -96
87 -139 64 -93 107 -175 122 -233 10 -36 17 -44 49 -54 59 -18 220 -22 467 -9
127 6 316 15 420 20 184 9 267 15 311 25 46 10 364 35 451 35 64 0 93 -4 96
-12 3 -7 6 566 6 1275 l1 1287 -1204 0 -1203 0 20 -101z"/>
<path d="M4971 3138 c-20 -33 -89 -96 -165 -153 -23 -17 -103 -92 -179 -168
-77 -75 -145 -137 -153 -137 -8 0 -27 -21 -43 -47 -29 -47 -30 -47 -178 -99
-81 -29 -158 -53 -171 -53 -12 -1 -61 -15 -109 -31 -50 -18 -106 -30 -133 -30
-25 1 -101 -2 -170 -6 -100 -5 -136 -3 -179 10 -30 9 -70 16 -89 16 -33 0 -33
-1 -25 -32 4 -18 8 -92 8 -164 l0 -132 32 -20 c17 -12 70 -64 117 -117 68 -76
96 -119 140 -208 58 -118 106 -256 106 -302 0 -24 3 -26 23 -20 12 3 42 9 67
12 69 8 83 -18 98 -180 16 -176 45 -309 96 -446 24 -64 48 -129 54 -146 17
-50 52 -247 52 -295 0 -69 -42 -141 -129 -221 -99 -91 -141 -111 -239 -112
-91 -2 -129 14 -157 67 -23 42 -35 44 -76 14 -35 -26 -138 -36 -191 -19 -60
20 -78 45 -78 106 0 47 4 57 24 70 41 27 148 62 227 74 41 6 89 14 107 17 19
3 32 11 32 20 0 8 12 42 26 75 24 58 25 66 15 145 -7 57 -25 120 -57 204 -26
66 -50 120 -53 120 -16 -1 -49 -42 -73 -90 -56 -110 -125 -182 -277 -287 -66
-46 -158 -73 -248 -73 -82 0 -93 -4 -173 -65 -85 -65 -188 -116 -290 -143
-139 -38 -226 -46 -470 -45 -201 1 -250 4 -339 23 -57 12 -116 20 -130 17 -14
-3 -73 -22 -131 -42 -97 -34 -111 -37 -192 -33 l-87 4 -6 -40 c-4 -23 -9 -55
-12 -73 -7 -43 -51 -82 -104 -92 -25 -5 786 -9 1934 -10 l1977 -1 0 1585 c0
872 -2 1585 -4 1585 -2 0 -14 -15 -25 -32z"/>
<path d="M0 358 l0 -358 458 1 c393 1 450 2 407 14 -146 37 -255 105 -435 270
-30 28 -102 83 -160 122 -173 118 -218 166 -256 271 -11 32 -13 -14 -14 -320z"/>
</g>
</svg>
Assuming you have a transparent "input.png", first convert all nontransparent pixels to white, then use the "-edge" option to find the transitions between transparent and white:
convert input.png -negate -threshold 1 -edge 1 edge.png
Note that this will not only outline the image but will outline any "holes" in it as well. For example, try it with the built-in "logo:" image:
convert logo: -transparent white logotrans.png
convert logotrans.png -negate -threshold 1 -edge 1 t.png
which transforms this
to this

Convert 8bit Color image to Gray For VGA

I have a 8 bit color image . What is the method to convert this into a Grayscale Image .
For a normal 24 bit true color RGB image, we either perform averaging ( R + G + B ) / 3
And then there's' the Weighted Averaging wherein we calculate 0.21 R + 0.72 G + 0.07 B.
However these above formula works for a 24 bit image (correct me if i'm wrong) . Where 8 bits are used to denote R, G, B content each. Thus when we apply the above averaging methods, we get a resultant 8 bit grayscale image from a 24 bit True color image.
So how to calculate grayscale image for an 8 bit color image :
Please note :
Structure of an 8 bit color image is as follows :
Refer this link
Bit 7 6 5 4 3 2 1 0
Data R R R G G G B B
As we can see,
Bits 7,6,5 denote Red content
Bits 4,3,2 denote Green content
Bits 1,0 denote Blue content
So the above image will actually have 4 shades in total
(because, in grayscale, a white pixel is obtained when there is 100 % contribution of each of the R,G,B components. And since Blue component has only 2 bits, effectively, there are 22 combinations i.e. 4 levels. )
Therefore, if i consider 2 bits of R ,G and B, i manage to obtain gray levels as follows :
R G B GrayLevel
00 00 00 Black
01 01 01 Gray 1
10 10 10 Gray 2
11 11 11 White
Which bits to consider from Red and Green components and which to ignore .!
How to quantify the graylevels for values of bits other than the ones mentioned above.
EDIT
I want to implement the above system upon an FPGA, hence memory is a keen aspect. Quality of the image doesn't matter much. Somehow is it possible to quantify all the values of the 8 bit color img into the respective gray shades ?
This approach gives output range of gray 0..255 (not all gray levels are used):
b = rgb8 & 3;
g = (rgb8 >> 2) & 7;
r = rgb8 >> 5;
gray255 = 8 * b + 11 * r + 22 * g;
If you have 256 bytes available, you can fill LUT (Look-Up Table) once, and use it instead of calculations:
grayimage[i] = LUT[rgb8image[i]];
If you really want to stick to 2 bits per gray pixel and you can afford simple multipliers, you can think of the formula
G = 5 x R + 9 x G + 4 B
where R and G are taken with 3 bits and B with just 2 (the coefficient has been adapted). This will yield a 7 bits value, in range [0,110], of which you will keep the most significant 2.
You may think to adapt the coefficients to occupy the four levels more evenly.
You essentially have a Rubik's cube of colours, which measures 8 x 8 x 4 if you can take a moment to imagine that. One side has 8 squares going from black to red, one side has 8 squares going from black to green and one side has 4 squares going from black to blue.
In essence, you can divide it up how you like since you don't care too much for quality. So, if you want 4 output grey levels, you can essentially make any two cuts you like and lump together everything inside each of the resulting shapes as a single grey level. Normally, you would aim to make the volumes of each lump the same - so you could cut the red side in half and the green side in half and ignore any differences in the blue channel as one option.
One way to do it might be to make equi-volumed lumps according to the distance from the origin, i.e. from black. I don't have an 8x8x4 cube available, but imagine the Earth was 8x8x4, then we would be making all pixels in the inner core black, those in the outer core dark grey, those in the mantle light grey and the crust white - such that the number of your original pixels in each lump was the same. It sounds complicated but isn't!
Let's run through all your possible Red, Green and Blue values and calculate the distance of each one from black, using
d=R^2 +G^2 +B^2
then sort the values by that distance and then number the lines:
#!/bin/bash
for r in 0 1 2 3 4 5 6 7; do
for g in 0 1 2 3 4 5 6 7; do
for b in 0 1 2 3; do
# Calculate distance from black corner (r=g=b=0) - actually squared but it doesn't matter
((d2=(r*r)+(g*g)+(b*b)))
echo $d2 $r $g $b
done
done
done | sort -n | nl
# sort numerically by distance from black, then number output lines sequentially
That gives this where the first column is the line number, the second column is the distance from black (and the values are sorted by this column), and then there follows R, G and B:
1 0 0 0 0 # From here onwards, pixels map to black
2 1 0 0 1
3 1 0 1 0
4 1 1 0 0
5 2 0 1 1
6 2 1 0 1
7 2 1 1 0
8 3 1 1 1
9 4 0 0 2
10 4 0 2 0
11 4 2 0 0
12 5 0 1 2
13 5 0 2 1
14 5 1 0 2
15 5 1 2 0
16 5 2 0 1
17 5 2 1 0
18 6 1 1 2
19 6 1 2 1
20 6 2 1 1
21 8 0 2 2
22 8 2 0 2
23 8 2 2 0
24 9 0 0 3
25 9 0 3 0
26 9 1 2 2
27 9 2 1 2
28 9 2 2 1
29 9 3 0 0
30 10 0 1 3
31 10 0 3 1
32 10 1 0 3
33 10 1 3 0
34 10 3 0 1
35 10 3 1 0
36 11 1 1 3
37 11 1 3 1
38 11 3 1 1
39 12 2 2 2
40 13 0 2 3
41 13 0 3 2
42 13 2 0 3
43 13 2 3 0
44 13 3 0 2
45 13 3 2 0
46 14 1 2 3
47 14 1 3 2
48 14 2 1 3
49 14 2 3 1
50 14 3 1 2
51 14 3 2 1
52 16 0 4 0
53 16 4 0 0
54 17 0 4 1
55 17 1 4 0
56 17 2 2 3
57 17 2 3 2
58 17 3 2 2
59 17 4 0 1
60 17 4 1 0
61 18 0 3 3
62 18 1 4 1
63 18 3 0 3
64 18 3 3 0 # From here onwards pixels map to dark grey
65 18 4 1 1
66 19 1 3 3
67 19 3 1 3
68 19 3 3 1
69 20 0 4 2
70 20 2 4 0
71 20 4 0 2
72 20 4 2 0
73 21 1 4 2
74 21 2 4 1
75 21 4 1 2
76 21 4 2 1
77 22 2 3 3
78 22 3 2 3
79 22 3 3 2
80 24 2 4 2
81 24 4 2 2
82 25 0 4 3
83 25 0 5 0
84 25 3 4 0
85 25 4 0 3
86 25 4 3 0
87 25 5 0 0
88 26 0 5 1
89 26 1 4 3
90 26 1 5 0
91 26 3 4 1
92 26 4 1 3
93 26 4 3 1
94 26 5 0 1
95 26 5 1 0
96 27 1 5 1
97 27 3 3 3
98 27 5 1 1
99 29 0 5 2
100 29 2 4 3
101 29 2 5 0
102 29 3 4 2
103 29 4 2 3
104 29 4 3 2
105 29 5 0 2
106 29 5 2 0
107 30 1 5 2
108 30 2 5 1
109 30 5 1 2
110 30 5 2 1
111 32 4 4 0
112 33 2 5 2
113 33 4 4 1
114 33 5 2 2
115 34 0 5 3
116 34 3 4 3
117 34 3 5 0
118 34 4 3 3
119 34 5 0 3
120 34 5 3 0
121 35 1 5 3
122 35 3 5 1
123 35 5 1 3
124 35 5 3 1
125 36 0 6 0
126 36 4 4 2
127 36 6 0 0
128 37 0 6 1
129 37 1 6 0 # From here onwards pixels map to light grey
130 37 6 0 1
131 37 6 1 0
132 38 1 6 1
133 38 2 5 3
134 38 3 5 2
135 38 5 2 3
136 38 5 3 2
137 38 6 1 1
138 40 0 6 2
139 40 2 6 0
140 40 6 0 2
141 40 6 2 0
142 41 1 6 2
143 41 2 6 1
144 41 4 4 3
145 41 4 5 0
146 41 5 4 0
147 41 6 1 2
148 41 6 2 1
149 42 4 5 1
150 42 5 4 1
151 43 3 5 3
152 43 5 3 3
153 44 2 6 2
154 44 6 2 2
155 45 0 6 3
156 45 3 6 0
157 45 4 5 2
158 45 5 4 2
159 45 6 0 3
160 45 6 3 0
161 46 1 6 3
162 46 3 6 1
163 46 6 1 3
164 46 6 3 1
165 49 0 7 0
166 49 2 6 3
167 49 3 6 2
168 49 6 2 3
169 49 6 3 2
170 49 7 0 0
171 50 0 7 1
172 50 1 7 0
173 50 4 5 3
174 50 5 4 3
175 50 5 5 0
176 50 7 0 1
177 50 7 1 0
178 51 1 7 1
179 51 5 5 1
180 51 7 1 1
181 52 4 6 0
182 52 6 4 0
183 53 0 7 2
184 53 2 7 0
185 53 4 6 1
186 53 6 4 1
187 53 7 0 2
188 53 7 2 0
189 54 1 7 2
190 54 2 7 1
191 54 3 6 3
192 54 5 5 2
193 54 6 3 3 # From here onwards pixels map to white
194 54 7 1 2
195 54 7 2 1
196 56 4 6 2
197 56 6 4 2
198 57 2 7 2
199 57 7 2 2
200 58 0 7 3
201 58 3 7 0
202 58 7 0 3
203 58 7 3 0
204 59 1 7 3
205 59 3 7 1
206 59 5 5 3
207 59 7 1 3
208 59 7 3 1
209 61 4 6 3
210 61 5 6 0
211 61 6 4 3
212 61 6 5 0
213 62 2 7 3
214 62 3 7 2
215 62 5 6 1
216 62 6 5 1
217 62 7 2 3
218 62 7 3 2
219 65 4 7 0
220 65 5 6 2
221 65 6 5 2
222 65 7 4 0
223 66 4 7 1
224 66 7 4 1
225 67 3 7 3
226 67 7 3 3
227 69 4 7 2
228 69 7 4 2
229 70 5 6 3
230 70 6 5 3
231 72 6 6 0
232 73 6 6 1
233 74 4 7 3
234 74 5 7 0
235 74 7 4 3
236 74 7 5 0
237 75 5 7 1
238 75 7 5 1
239 76 6 6 2
240 78 5 7 2
241 78 7 5 2
242 81 6 6 3
243 83 5 7 3
244 83 7 5 3
245 85 6 7 0
246 85 7 6 0
247 86 6 7 1
248 86 7 6 1
249 89 6 7 2
250 89 7 6 2
251 94 6 7 3
252 94 7 6 3
253 98 7 7 0
254 99 7 7 1
255 102 7 7 2
256 107 7 7 3
Obviously, the best way to do that is with a lookup table, which is exactly what this is.
Just for kicks, we can look at how it performs if we make some sample images with ImageMagick and process them with this lookup table:
# Make a sample
convert -size 100x100 xc: -sparse-color Bilinear '30,10 red 10,80 blue 70,60 lime 80,20 yellow' -resize 400x400! gradient.png
# Process with suggested LUT
convert gradient.png -fx "#lut.fx" result.png
lut.fx implements the LUT and looks like this:
dd=(49*r*r)+(49*g*g)+(16*b*b);
(dd < 19) ? 0.0 : ((dd < 38) ? 0.25 : ((dd < 54) ? 0.75 : 1.0))
By comparison, if you implement my initial suggestion at the start of my answer, by doing:
R < 0.5 && G < 0.5 => black result
R < 0.5 && G >= 0.5 => dark grey result
R >= 0.5 && G < 0.5 => light grey result
r >= 0.5 && G >= 0.5 => white result
You will get this output - which, as you can see, is better at differentiating red from green, but worse at reflecting the brightness of the original.

Using the modulo operator with integers

I'm trying to work out how the modulo operation 1 % 32 is equal to 1, and 2 % 32 is equal to 2, and so on and so forth.
I have this code:
uint8_t value;
for (uint16_t i = 0; i < 64; i++) {
value = (i % 32);
Serial.println(value);
}
I get a result of:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
I can see the logic when i is equal to 0, or i is equal to 32. For instance, if we take the remainder of the latter: 32 / 32 we get 0. But, for all the numbers within the range of 1 to 31, I can't seem to derive the same answer as the program. For example, if I divide the integers 1 by 32 in order to obtain the remainder, I just get 0. This is the same for 2, 3, 4, 5, 6, n,..
There must be something I'm missing here.
The result of the modulo operation is the remainder:
0 divided by 32 equals 0 with a remainder of 0
1 divided by 32 equals 0 with a remainder of 1
2 divided by 32 equals 0 with a remainder of 2
3 divided by 32 equals 0 with a remainder of 3
4 divided by 32 equals 0 with a remainder of 4
5 divided by 32 equals 0 with a remainder of 5
...
29 divided by 32 equals 0 with a remainder of 29
30 divided by 32 equals 0 with a remainder of 30
31 divided by 32 equals 0 with a remainder of 31
32 divided by 32 equals 1 with a remainder of 0
33 divided by 32 equals 1 with a remainder of 1
34 divided by 32 equals 1 with a remainder of 2
35 divided by 32 equals 1 with a remainder of 3
36 divided by 32 equals 1 with a remainder of 4
37 divided by 32 equals 1 with a remainder of 5
38 divided by 32 equals 1 with a remainder of 6
39 divided by 32 equals 1 with a remainder of 7
...
So the results you see are what you should expect. Consider 2 % 32. "2 divided by 32 equals 0 with a remainder of 2". So 2 % 32 == 2.

Resources