aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/dnn_filter_common.c
diff options
context:
space:
mode:
authorWenbin Chen <wenbin.chen@intel.com>2024-01-17 15:21:49 +0800
committerGuo Yejun <yejun.guo@intel.com>2024-01-28 11:17:59 +0800
commitc695de56b5ba8b2436e455c2284159759ca444d3 (patch)
treeca20a714e5b0b684e365e00bf35c2dc25cbf1418 /libavfilter/dnn_filter_common.c
parent0c517fcbe8ee864c8390dd08696ec63621a4f3e0 (diff)
downloadffmpeg-c695de56b5ba8b2436e455c2284159759ca444d3.tar.gz
libavfilter/dnn_bakcend_openvino: Add automatic input/output detection
Now when using openvino backend, user doesn't need to set input/output names in command line. Model ports will be automatically detected. For example: ffmpeg -i input.png -vf \ dnn_detect=dnn_backend=openvino:model=model.xml:input=image:\ output=detection_out -y output.png can be simplified to: ffmpeg -i input.png -vf dnn_detect=dnn_backend=openvino:model=model.xml\ -y output.png Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Reviewed-by: Guo Yejun <yejun.guo@intel.com>
Diffstat (limited to 'libavfilter/dnn_filter_common.c')
-rw-r--r--libavfilter/dnn_filter_common.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c
index 3b9182c1d1..f012d450a2 100644
--- a/libavfilter/dnn_filter_common.c
+++ b/libavfilter/dnn_filter_common.c
@@ -57,15 +57,17 @@ int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *fil
av_log(filter_ctx, AV_LOG_ERROR, "model file for network is not specified\n");
return AVERROR(EINVAL);
}
- if (!ctx->model_inputname) {
- av_log(filter_ctx, AV_LOG_ERROR, "input name of the model network is not specified\n");
- return AVERROR(EINVAL);
- }
- ctx->model_outputnames = separate_output_names(ctx->model_outputnames_string, "&", &ctx->nb_outputs);
- if (!ctx->model_outputnames) {
- av_log(filter_ctx, AV_LOG_ERROR, "could not parse model output names\n");
- return AVERROR(EINVAL);
+ if (ctx->backend_type == DNN_TF) {
+ if (!ctx->model_inputname) {
+ av_log(filter_ctx, AV_LOG_ERROR, "input name of the model network is not specified\n");
+ return AVERROR(EINVAL);
+ }
+ ctx->model_outputnames = separate_output_names(ctx->model_outputnames_string, "&", &ctx->nb_outputs);
+ if (!ctx->model_outputnames) {
+ av_log(filter_ctx, AV_LOG_ERROR, "could not parse model output names\n");
+ return AVERROR(EINVAL);
+ }
}
ctx->dnn_module = ff_get_dnn_module(ctx->backend_type, filter_ctx);
@@ -113,8 +115,9 @@ int ff_dnn_get_input(DnnContext *ctx, DNNData *input)
int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height)
{
+ char * output_name = ctx->model_outputnames ? ctx->model_outputnames[0] : NULL;
return ctx->model->get_output(ctx->model->model, ctx->model_inputname, input_width, input_height,
- (const char *)ctx->model_outputnames[0], output_width, output_height);
+ (const char *)output_name, output_width, output_height);
}
int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame)