From d52e8ed114301b44f2a1ff526c6164c43da35749 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Wed, 17 Jan 2024 15:21:51 +0800 Subject: [PATCH] libavfilter/vf_dnn_detect: Use class confidence to filt boxes Use class confidence instead of box_score to filt boxes, which is more accurate. Class confidence is obtained by multiplying class probability distribution and box_score. Signed-off-by: Wenbin Chen Reviewed-by: Guo Yejun --- libavfilter/vf_dnn_detect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index caccbf7a12..2bf5ed7476 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -236,9 +236,6 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out conf = post_process_raw_data( detection_boxes_data[cy * cell_w + cx + 4 * cell_w * cell_h]); } - if (conf < conf_threshold) { - continue; - } if (is_NHWC) { x = post_process_raw_data(detection_boxes_data[0]); @@ -257,6 +254,9 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out conf = conf * post_process_raw_data( detection_boxes_data[cy * cell_w + cx + (label_id + 5) * cell_w * cell_h]); } + if (conf < conf_threshold) { + continue; + } bbox = av_mallocz(sizeof(*bbox)); if (!bbox)