History

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.

Leandro Santiago committed 1 year ago

Commit d21ed221 parent 90fbb401 file · +8 −5Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_dnn_detect.c+8−5
@@ -173,11 +173,6 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out · 172 unmodified lines
173173 return AVERROR(EINVAL);
174174 }
175175
176− if (!anchors) {
177− av_log(filter_ctx, AV_LOG_ERROR, "anchors is not set\n");
178− return AVERROR(EINVAL);
179− }
180−
181176 if (output[output_index].dims[1] * output[output_index].dims[2] *
182177 output[output_index].dims[3] % (box_size * cell_w * cell_h)) {
183178 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) · 472 unmodified lines
656651 DnnDetectContext *ctx = context->priv;
657652 DnnContext *dnn_ctx = &ctx->dnnctx;
658653 int ret;
654+ int using_yolo = (ctx->model_type == DDMT_YOLOV3 ||
655+ ctx->model_type == DDMT_YOLOV4 ||
656+ ctx->model_type == DDMT_YOLOV1V2);
657+
658+ if (using_yolo && !ctx->anchors) {
659+ av_log(ctx, AV_LOG_ERROR, "anchors is not set while being required for YOLO models\n");
660+ return AVERROR(EINVAL);
661+ }
659662
660663 ret = ff_dnn_init(&ctx->dnnctx, DFT_ANALYTICS_DETECT, context);
661664 if (ret < 0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t