Hi AlexeyAB,
If I want to output real frame_number in a video along with information of bounding box, how do I suppose to do it?
The format of the output .txt file would be like this:
frame_number : 123
Bounding_boxes : [class1, x1, y1, w1, h1; class2, x2, y2, w2, h2;]
frame_number : 124
Bounding_boxes : [class3, x3, y3, w3, h3; class4, x4, y4, w4, h4;]
I tried put my code at "image.c" => "draw_detections_cv" to generate .txt file for recording information.
But it seems like you used some sort of "buffer" on frames.
Would you please tell me how to get the real frame number?
Thank you very much.
Hi @jackwei0117
This count stores the actual frame than is being processed.
https://github.com/AlexeyAB/darknet/blob/490d02505b42701d9682591631c61d40e6cddeb4/src/demo.c#L186
You could easily change it to global variable and insert you code in the final lines of "detect_in_thread" funcion to print your results in a txt
Just after this line
https://github.com/AlexeyAB/darknet/blob/490d02505b42701d9682591631c61d40e6cddeb4/src/demo.c#L109
@jackwei0117
But it seems like you used some sort of "buffer" on frames.
You can try to set #define FRAMES 1 here to avoid using a "buffer": https://github.com/AlexeyAB/darknet/blob/490d02505b42701d9682591631c61d40e6cddeb4/src/demo.c#L18
And add here code: https://github.com/AlexeyAB/darknet/blob/490d02505b42701d9682591631c61d40e6cddeb4/src/demo.c#L107
static int frame_count = 0;
printf("frame: %d\n", frame_count++);
Dear all,
Thank you for your suggestions.
Actually, I did almost exactly the same method, except that I didn't know the meaning of
#define FRAMES 3
But anyway, it's OK for me now.
Much obliged.
Hi AlexeyAB,
Would you please explain this code:
images[demo_index] = det;
det = images[(demo_index + FRAMES/2 + 1)%FRAMES];
ipl_images[demo_index] = det_img;
det_img = ipl_images[(demo_index + FRAMES / 2 + 1) % FRAMES];
demo_index = (demo_index + 1)%FRAMES;
in demo.c ?
images[FRAMES], and get middle frame.images[demo_index] = det;
det = images[(demo_index + FRAMES/2 + 1)%FRAMES];
The main point is that this code averages the detection by FRAMES frames to get a more stable and more accurate detection:
https://github.com/AlexeyAB/darknet/blob/490d02505b42701d9682591631c61d40e6cddeb4/src/demo.c#L85-L86
I.e. if FRAMES 3 and current frame index = 21, then this code averages the detection by frames (19, 20, 21), so the most relevant frame is the middle (20). So we should get frame20, draw objects on it and show it.
AlexeyAB,
I put my output code of frame number before here:
https://github.com/AlexeyAB/darknet/blob/490d02505b42701d9682591631c61d40e6cddeb4/src/image.c#L312
But the frame numbers are different (for approximately the same recognition result on each frame) when I change
#define FRAMES 3
to
#define FRAMES 1
Any idea why?
Thanks!
Do you mean that detection occurs on the different frame-id for #define FRAMES 3 and #define FRAMES 1?
Use this approach to avoid shift frame-id for different #define FRAMES: https://github.com/AlexeyAB/darknet/issues/412#issuecomment-368848143
AlexeyAB
Got it !
Many many thanks !
Most helpful comment
Use this approach to avoid shift frame-id for different
#define FRAMES: https://github.com/AlexeyAB/darknet/issues/412#issuecomment-368848143