From 13bf797ced0b527fa770d4b29884a5b0b8f19898 Mon Sep 17 00:00:00 2001 From: "Guo, Yejun" Date: Tue, 9 Mar 2021 14:51:42 +0800 Subject: lavfi/dnn: add post process for detection --- libavfilter/dnn/dnn_backend_openvino.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'libavfilter/dnn') diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 3bea2d526a..0757727a9c 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -236,16 +236,32 @@ static void infer_completion_callback(void *args) av_assert0(request->task_count >= 1); for (int i = 0; i < request->task_count; ++i) { task = request->tasks[i]; - if (task->do_ioproc) { - if (task->ov_model->model->frame_post_proc != NULL) { - task->ov_model->model->frame_post_proc(task->out_frame, &output, task->ov_model->model->filter_ctx); + + switch (task->ov_model->model->func_type) { + case DFT_PROCESS_FRAME: + if (task->do_ioproc) { + if (task->ov_model->model->frame_post_proc != NULL) { + task->ov_model->model->frame_post_proc(task->out_frame, &output, task->ov_model->model->filter_ctx); + } else { + ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx); + } } else { - ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx); + task->out_frame->width = output.width; + task->out_frame->height = output.height; } - } else { - task->out_frame->width = output.width; - task->out_frame->height = output.height; + break; + case DFT_ANALYTICS_DETECT: + if (!task->ov_model->model->detect_post_proc) { + av_log(ctx, AV_LOG_ERROR, "detect filter needs to provide post proc\n"); + return; + } + task->ov_model->model->detect_post_proc(task->out_frame, &output, 1, task->ov_model->model->filter_ctx); + break; + default: + av_assert0(!"should not reach here"); + break; } + task->done = 1; output.data = (uint8_t *)output.data + output.width * output.height * output.channels * get_datatype_size(output.dt); -- cgit v1.2.3