AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.77k stars 7.96k forks source link

Format and style of the bounding box #898

Open kmsravindra opened 6 years ago

kmsravindra commented 6 years ago

@AlexeyAB, I am looking for the code to change the format and style of the bounding box. It would be very helpful if you could point me to where this code is present and how I can change it ? thanks!

salbatron commented 6 years ago

i guess you are interested in this: https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/src/image.c#L536-L548

if you use yolo as .dll, look at this function: https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/src/yolo_console_dll.cpp#L181-L204

AlexeyAB commented 6 years ago

For video: https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/src/image.c#L536-L548

Wazaki-Ou commented 6 years ago

Hi @AlexeyAB

I thought it might be easier to just ask here since my question is similar. Is there a way to retrieve the bounding box for a specific video? when I run my model with a video with the command, I can see the box in the video displayed, but I would like to retrieve the points either through python or saved in a text file. I tried the following command: darknet.exe detector valid data/obj.data yolo-obj.cfg yolo-obj_4700.weights Prince_1_1.mp4 -i 0 but it seems like it only works on the testing data set I put before and I don't understand what the results in the text file refer to (They also don't seem to be normalized like the label format used by YOLO).

Thanks a lot !!

AlexeyAB commented 6 years ago

@Osumann Try to use

darknet.exe detector demo data/coco.data yolov3.cfg yolov3.weights -thresh 0.25 test.mp4 -ext_output > result.txt

Then you can look at the file result.txt

Wazaki-Ou commented 6 years ago

@AlexeyAB I tried the command and all I get is the percentage of the object and fps in thefile. What I am trying to retrieve is the detected spatial boundary for every frame. Maybe the xmin, y min, height and width or just like the format used for training: center point and height and width. Is there any way to get it?

AlexeyAB commented 6 years ago

@Osumann Update your code from this GitHub repo.

What can I get using this command: darknet.exe detector demo data/coco.data yolov3.cfg yolov3.weights -i 0 -thresh 0.25 -ext_output test.mp4 > result.txt

image

and result.txt:

Demo
Total BFLOPS 65.864 

 seen 64 
video file: test.mp4
Video stream: 1280 x 720 

FPS:0.0
Objects:


FPS:0.0
Objects:

person: 84%   (left: 1067   top: 1242   w:  175   h:   81)
person: 72%   (left:    0   top: 1139   w: 1154   h:  138)
person: 71%   (left:  828   top:  926   w:   98   h:   97)
person: 62%   (left:  465   top:  557   w:   91   h:   85)
person: 62%   (left:  281   top:  474   w:  193   h:  135)
person: 60%   (left:  530   top:  617   w:   87   h:   82)
person: 58%   (left:  927   top: 1020   w:   93   h:   75)
person: 55%   (left:   33   top:  124   w:   91   h:   73)
person: 52%   (left:  692   top:  824   w:  131   h:  121)
person: 43%   (left:    0   top:   60   w:   61   h:   69)
person: 34%   (left:  627   top:  704   w:   76   h:   82)
person: 26%   (left: 1177   top: 1247   w:   70   h:  105)
person: 26%   (left:  603   top:  647   w:   44   h:   65)

FPS:0.0
Objects:

...

Wazaki-Ou commented 6 years ago

@AlexeyAB Thank you !! I'll get the new commit and try again !

Wazaki-Ou commented 6 years ago

@AlexeyAB Using the new code, I got the result you showed !! thank you so~ much !! Can you please point me to the lines of code that print the other information (the one below this text) so that I can comment them out and only save the bounding box. I looked in image.c and I tried commenting out all the other printf() but I still can't get it done.

Demo
Total BFLOPS 65.864 

 seen 64 
video file: test.mp4
Video stream: 1280 x 720 
�[2J�[1;1H
FPS:0.0
Objects:

�[2J�[1;1H
FPS:0.0
Objects:
AlexeyAB commented 6 years ago

@Osumann

https://github.com/AlexeyAB/darknet/blob/1d532aa97fd280dede27c3cd0d6b81665faca284/src/demo.c#L106-L109

Wazaki-Ou commented 6 years ago

@AlexeyAB that worked like a charm !! Thank you again. One more (hopefully last) question. I tried to figure it out, but it seems like something is strange with the y-max (top) value I get in the results. The value of x (left) seems correct, so do the values of width and height, but the y-max (top) is way too high. I use a video with dimension: 1920*1080 and the first frame (for example) is supposed to have a top value of around 950 but I get 1600. When I test using darknet, I get good results and the box keeps following my target. Any idea ?

AlexeyAB commented 6 years ago

@Osumann Thanks. This was a bug, I fixed it.

marcunzueta commented 6 years ago

@AlexeyAB I encountered the same bug as @Osumann could you point where the bug was so I can fix it, without updating all the repo, I locally have?

Thank you very much!

marcunzueta commented 6 years ago

Just found it on the image.c commit 1b7a1a0

Eyshika commented 6 years ago

@AlexeyAB I figured while using this command `darknet.exe detector demo data/coco.data yolov3.cfg yolov3.weights -i 0 -thresh 0.25 -ext_output test.mp4 > result.txt

` to save output in result.txt it somehow encodes the files in UTF-8. Since i want to parse that txt file and compare the output but due to encoded in UTF-8 it doesnt process that well, and i have to remove few keyword from txt file in starting (which actually makes it encoded in UTF-8) manually to do parsing. screen shot 2018-08-06 at 11 25 12 am the keyword i specifically have to remove is <84> and other THTH unused keywords

Can you please point out where it converts the file in UTF-8 ? or Can you please point out how can i save this output file in csv ?

AlexeyAB commented 6 years ago

@Eyshika

./darknet.exe detector test cfg/coco.data yolov3.cfg yolov3.weights -dont_show -ext_output -save_labels < data/test.txt and you will see near with jpg-files also txt-files with the same names.