[PR] avfilter/dnn: fix object detection of openvino backend (PR #23972)

guoyejun via ffmpeg-devel <[email protected]> Fri, 31 Jul 2026 15:49:51 -0000
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178551301185.51.1523222224383303916@29965ddac10e>
PR #23972 opened by guoyejun
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23972
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23972.patch

update ctx->ov_option.layout to the explict value which will be
used in function init_model_ov.

also move the code before input_resizable which uses the layout


>From 331bba314840e0a9f354c26a565b1e95bac17d0b Mon Sep 17 00:00:00 2001
From: Guo Yejun <[email protected]>
Date: Tue, 28 Jul 2026 22:41:41 +0800
Subject: [PATCH] avfilter/dnn: fix object detection of openvino backend

update ctx->ov_option.layout to the explict value which will be
used in function init_model_ov.

also move the code before input_resizable which uses the layout
---
 libavfilter/dnn/dnn_backend_openvino.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 8df1f346ab..0df4d585e8 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -1088,16 +1088,20 @@ static int get_input_ov(DNNModel *model, DNNData *input, const char *input_name)
     }
     for (int i = 0; i < 4; i++)
         input->dims[i] = input_shape.dims[i];
+
+    if (ctx->ov_option.layout == DL_NONE) {
+        if (input_shape.dims[1] <= 3)
+            ctx->ov_option.layout = DL_NCHW;
+        else
+            ctx->ov_option.layout = DL_NHWC;
+    }
+    input->layout = ctx->ov_option.layout;
+
     if (input_resizable) {
         input->dims[dnn_get_width_idx_by_layout(input->layout)] = -1;
         input->dims[dnn_get_height_idx_by_layout(input->layout)] = -1;
     }
 
-    if (input_shape.dims[1] <= 3) // NCHW
-        input->layout = DL_NCHW;
-    else // NHWC
-        input->layout = DL_NHWC;
-
     input->dt       = precision_to_datatype(precision);
     ov_shape_free(&input_shape);
     return 0;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]