ffmpeg | branch: master | Leandro Santiago <leandrosansi...@gmail.com> | Wed Feb 26 15:17:12 2025 +0100| [d21ed2298ef122c64e578831c6dbd2bb2134df79] | committer: Guo Yejun
avfilter/dnn_detect: fail on filter if mandatory anchor option is missing It prevents the filter of running in case such option is missing, failing early, during init() instead of simply logging an error during runtime. Signed-off-by: Leandro Santiago <leandrosansi...@gmail.com> Reviewed-by: Wenbin Chen <wenbin.c...@intel.com> Reviewed-by: Guo Yejun <yejun....@intel.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d21ed2298ef122c64e578831c6dbd2bb2134df79 --- libavfilter/vf_dnn_detect.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index cd70c64e98..bc9a1777ff 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -173,11 +173,6 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out return AVERROR(EINVAL); } - if (!anchors) { - av_log(filter_ctx, AV_LOG_ERROR, "anchors is not set\n"); - return AVERROR(EINVAL); - } - if (output[output_index].dims[1] * output[output_index].dims[2] * output[output_index].dims[3] % (box_size * cell_w * cell_h)) { av_log(filter_ctx, AV_LOG_ERROR, "wrong cell_w, cell_h or nb_classes\n"); @@ -656,6 +651,14 @@ static av_cold int dnn_detect_init(AVFilterContext *context) DnnDetectContext *ctx = context->priv; DnnContext *dnn_ctx = &ctx->dnnctx; int ret; + int using_yolo = (ctx->model_type == DDMT_YOLOV3 || + ctx->model_type == DDMT_YOLOV4 || + ctx->model_type == DDMT_YOLOV1V2); + + if (using_yolo && !ctx->anchors) { + av_log(ctx, AV_LOG_ERROR, "anchors is not set while being required for YOLO models\n"); + return AVERROR(EINVAL); + } ret = ff_dnn_init(&ctx->dnnctx, DFT_ANALYTICS_DETECT, context); if (ret < 0) _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".