36#include <openvino/c/openvino.h>
38#include <c_api/ie_c_api.h>
48 ov_compiled_model_t *compiled_model;
49 ov_output_const_port_t* input_port;
50 ov_preprocess_input_info_t* input_info;
51 ov_output_const_port_t** output_ports;
52 ov_preprocess_output_info_t* output_info;
53 ov_preprocess_prepostprocessor_t* preprocess;
80#define APPEND_STRING(generated_string, iterate_string) \
81 generated_string = generated_string ? av_asprintf("%s %s", generated_string, iterate_string) : \
82 av_asprintf("%s", iterate_string);
84#define OFFSET(x) offsetof(OVOptions, x)
85#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
92 {
"scale",
"Add scale preprocess operation. Divide each element of input by specified value.",
OFFSET(
scale),
AV_OPT_TYPE_FLOAT, { .dbl = 0 }, INT_MIN, INT_MAX,
FLAGS},
93 {
"mean",
"Add mean preprocess operation. Subtract specified value from each element of input.",
OFFSET(
mean),
AV_OPT_TYPE_FLOAT, { .dbl = 0 }, INT_MIN, INT_MAX,
FLAGS},
103 { OK, 0,
"success" },
105 { NOT_IMPLEMENTED,
AVERROR(ENOSYS),
"not implemented" },
107 { PARAMETER_MISMATCH,
AVERROR(EINVAL),
"parameter mismatch" },
109 { OUT_OF_BOUNDS,
AVERROR(EOVERFLOW),
"out of bounds" },
111 { REQUEST_BUSY,
AVERROR(EBUSY),
"request busy" },
112 { RESULT_NOT_READY,
AVERROR(EBUSY),
"result not ready" },
113 { NOT_ALLOCATED,
AVERROR(ENODATA),
"not allocated" },
116 { INFER_CANCELLED,
AVERROR(ECANCELED),
"infer cancelled" },
117 { INVALID_C_PARAM,
AVERROR(EINVAL),
"invalid C parameter" },
119 { NOT_IMPLEMENT_C_METHOD,
AVERROR(ENOSYS),
"not implement C method" },
123static int ov2_map_error(ov_status_e status,
const char **
desc)
127 if (ov2_errors[
i].status == status) {
129 *
desc = ov2_errors[
i].desc;
130 return ov2_errors[
i].av_err;
134 *
desc =
"unknown error";
166 return sizeof(
float);
168 return sizeof(uint8_t);
184 ov_tensor_t* tensor =
NULL;
185 ov_shape_t input_shape = {0};
186 ov_element_type_e precision;
190 precision_e precision;
191 ie_blob_buffer_t blob_buffer;
193 ie_blob_t *input_blob =
NULL;
196 memset(&input, 0,
sizeof(input));
202 if (ov_model->input_port) {
203 ov_output_const_port_free(ov_model->input_port);
204 ov_model->input_port =
NULL;
207 status = ov_model_const_input_by_name(ov_model->ov_model, task->
input_name, &ov_model->input_port);
209 status = ov_model_const_input(ov_model->ov_model, &ov_model->input_port);
212 return ov2_map_error(status,
NULL);
214 status = ov_port_get_any_name(ov_model->input_port, &port_name);
217 return ov2_map_error(status,
NULL);
223 status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
226 return ov2_map_error(status,
NULL);
228 dims = input_shape.dims;
229 status = ov_port_get_element_type(ov_model->input_port, &precision);
232 ov_shape_free(&input_shape);
233 return ov2_map_error(status,
NULL);
235 for (
int i = 0;
i < input_shape.rank;
i++)
246 status |= ie_blob_get_dims(input_blob, &dims);
247 status |= ie_blob_get_precision(input_blob, &precision);
249 ie_blob_free(&input_blob);
254 status = ie_blob_get_buffer(input_blob, &blob_buffer);
256 ie_blob_free(&input_blob);
260 for (
int i = 0;
i < input_shape.rank;
i++)
263 input.
data = blob_buffer.buffer;
273 for (
int i = 0;
i <
ctx->batch_size; ++
i) {
283 ov_tensor_free(tensor);
284 status = ov_tensor_create(precision, input_shape, &tensor);
285 ov_shape_free(&input_shape);
288 return ov2_map_error(status,
NULL);
290 status = ov_tensor_data(tensor, &input.
data);
293 return ov2_map_error(status,
NULL);
295 status = ov_infer_request_set_input_tensor(request->
infer_request, tensor);
298 return ov2_map_error(status,
NULL);
321 input.
data = (uint8_t *)input.
data +
325 ov_tensor_free(tensor);
327 ie_blob_free(&input_blob);
345 ov_tensor_t *output_tensor;
346 ov_shape_t output_shape = {0};
347 ov_element_type_e precision;
356 status = ov_infer_request_get_tensor_by_const_port(request->
infer_request,
357 ov_model->output_ports[
i],
361 "Failed to get output tensor.");
365 status = ov_tensor_data(output_tensor, &
outputs[
i].
data);
368 "Failed to get output data.");
372 status = ov_tensor_get_shape(output_tensor, &output_shape);
377 dims = output_shape.dims;
379 status = ov_port_get_element_type(ov_model->output_ports[
i], &precision);
387 outputs[
i].dims[1] = output_shape.rank > 2 ? dims[output_shape.rank - 3] : 1;
388 outputs[
i].dims[2] = output_shape.rank > 1 ? dims[output_shape.rank - 2] : 1;
389 outputs[
i].dims[3] = output_shape.rank > 0 ? dims[output_shape.rank - 1] : 1;
394 ov_shape_free(&output_shape);
395 ov_tensor_free(output_tensor);
396 output_tensor =
NULL;
401 ie_blob_t *output_blob =
NULL;
402 ie_blob_buffer_t blob_buffer;
403 precision_e precision;
408 "output \"%s\" may not correct, all output(s) are: \"%s\"\n",
413 status = ie_blob_get_buffer(output_blob, &blob_buffer);
415 ie_blob_free(&output_blob);
420 status |= ie_blob_get_dims(output_blob, &dims);
421 status |= ie_blob_get_precision(output_blob, &precision);
423 ie_blob_free(&output_blob);
427 output.
data = blob_buffer.buffer;
429 for (
int i = 0;
i < 4;
i++)
430 output.
dims[
i] = dims.dims[
i];
434 output.
scale =
ctx->ov_option.scale;
435 output.
mean =
ctx->ov_option.mean;
472 for (
int output_i = 0; output_i < ov_model->
nb_outputs; output_i++)
492 ov_shape_free(&output_shape);
494 ov_tensor_free(output_tensor);
496 ie_blob_free(&output_blob);
515 if (!model || !*model)
518 ov_model = (
OVModel *)(*model);
548 if (ov_model->input_port)
549 ov_output_const_port_free(ov_model->input_port);
551 if (ov_model->output_ports[
i])
552 ov_output_const_port_free(ov_model->output_ports[
i]);
554 if (ov_model->preprocess)
555 ov_preprocess_prepostprocessor_free(ov_model->preprocess);
556 if (ov_model->compiled_model)
557 ov_compiled_model_free(ov_model->compiled_model);
558 if (ov_model->ov_model)
559 ov_model_free(ov_model->ov_model);
561 ov_core_free(ov_model->
core);
566 ie_network_free(&ov_model->
network);
568 ie_core_free(&ov_model->
core);
583 ov_preprocess_input_tensor_info_t* input_tensor_info =
NULL;
584 ov_preprocess_output_tensor_info_t* output_tensor_info =
NULL;
585 ov_preprocess_input_model_info_t* input_model_info =
NULL;
586 ov_model_t *tmp_ov_model;
587 ov_layout_t* NHWC_layout =
NULL;
588 ov_layout_t* NCHW_layout =
NULL;
589 const char* NHWC_desc =
"NHWC";
590 const char* NCHW_desc =
"NCHW";
591 const char* device =
ctx->device ?
ctx->device :
"CPU";
594 ie_available_devices_t a_dev;
596 char *all_dev_names =
NULL;
599 if (
fabsf(
ctx->ov_option.scale) < 1e-6f)
602 if (
ctx->batch_size <= 0) {
606 if (
ctx->batch_size > 1) {
608 "change batch_size to 1.\n");
612 status = ov_preprocess_prepostprocessor_create(ov_model->ov_model, &ov_model->preprocess);
615 ret = ov2_map_error(status,
NULL);
620 status = ov_preprocess_prepostprocessor_get_input_info_by_name(ov_model->preprocess, input_name, &ov_model->input_info);
622 status = ov_preprocess_prepostprocessor_get_input_info(ov_model->preprocess, &ov_model->input_info);
625 ret = ov2_map_error(status,
NULL);
629 status = ov_preprocess_input_info_get_tensor_info(ov_model->input_info, &input_tensor_info);
632 ret = ov2_map_error(status,
NULL);
637 status = ov_layout_create(NHWC_desc, &NHWC_layout);
638 status |= ov_layout_create(NCHW_desc, &NCHW_layout);
641 ret = ov2_map_error(status,
NULL);
645 status = ov_preprocess_input_tensor_info_set_layout(input_tensor_info, NHWC_layout);
648 ret = ov2_map_error(status,
NULL);
652 status = ov_preprocess_input_info_get_model_info(ov_model->input_info, &input_model_info);
655 ret = ov2_map_error(status,
NULL);
659 status = ov_preprocess_input_model_info_set_layout(input_model_info, NCHW_layout);
661 status = ov_preprocess_input_model_info_set_layout(input_model_info, NHWC_layout);
664 ret = ov2_map_error(status,
NULL);
668 status = ov_preprocess_input_tensor_info_set_element_type(input_tensor_info, U8);
671 ret = ov2_map_error(status,
NULL);
677 status = ov_model_outputs_size(ov_model->ov_model, &output_size);
680 ret = ov2_map_error(status,
NULL);
683 nb_outputs = output_size;
686 for (
int i = 0;
i < nb_outputs;
i++) {
688 status = ov_preprocess_prepostprocessor_get_output_info_by_name(
689 ov_model->preprocess, output_names[
i], &ov_model->output_info);
691 status = ov_preprocess_prepostprocessor_get_output_info_by_index(
692 ov_model->preprocess,
i, &ov_model->output_info);
695 ret = ov2_map_error(status,
NULL);
698 status |= ov_preprocess_output_info_get_tensor_info(ov_model->output_info, &output_tensor_info);
701 ret = ov2_map_error(status,
NULL);
705 status |= ov_preprocess_output_set_element_type(output_tensor_info, F32);
706 else if (
fabsf(
ctx->ov_option.scale - 1) > 1e-6f ||
fabsf(
ctx->ov_option.mean) > 1e-6f)
707 status |= ov_preprocess_output_set_element_type(output_tensor_info, F32);
709 status |= ov_preprocess_output_set_element_type(output_tensor_info, U8);
712 ret = ov2_map_error(status,
NULL);
715 ov_preprocess_output_tensor_info_free(output_tensor_info);
716 output_tensor_info =
NULL;
717 ov_preprocess_output_info_free(ov_model->output_info);
718 ov_model->output_info =
NULL;
721 if (
fabsf(
ctx->ov_option.scale - 1) > 1e-6f ||
fabsf(
ctx->ov_option.mean) > 1e-6f) {
722 ov_preprocess_preprocess_steps_t* input_process_steps =
NULL;
723 status = ov_preprocess_input_info_get_preprocess_steps(ov_model->input_info, &input_process_steps);
726 ret = ov2_map_error(status,
NULL);
729 status = ov_preprocess_preprocess_steps_convert_element_type(input_process_steps, F32);
730 status |= ov_preprocess_preprocess_steps_mean(input_process_steps,
ctx->ov_option.mean);
731 status |= ov_preprocess_preprocess_steps_scale(input_process_steps,
ctx->ov_option.scale);
734 ov_preprocess_preprocess_steps_free(input_process_steps);
735 input_process_steps =
NULL;
736 ret = ov2_map_error(status,
NULL);
739 ov_preprocess_preprocess_steps_free(input_process_steps);
740 input_process_steps =
NULL;
742 ov_preprocess_input_tensor_info_free(input_tensor_info);
743 input_tensor_info =
NULL;
744 ov_preprocess_input_info_free(ov_model->input_info);
745 ov_model->input_info =
NULL;
748 if(ov_model->ov_model)
749 tmp_ov_model = ov_model->ov_model;
750 status = ov_preprocess_prepostprocessor_build(ov_model->preprocess, &ov_model->ov_model);
753 ov_model_free(tmp_ov_model);
755 ret = ov2_map_error(status,
NULL);
758 ov_model_free(tmp_ov_model);
761 if (!ov_model->output_ports) {
762 ov_model->output_ports =
av_calloc(nb_outputs,
sizeof(*ov_model->output_ports));
763 if (!ov_model->output_ports) {
768 for (
int i = 0;
i < nb_outputs;
i++) {
769 ov_output_const_port_free(ov_model->output_ports[
i]);
770 ov_model->output_ports[
i] =
NULL;
773 for (
int i = 0;
i < nb_outputs;
i++) {
776 status = ov_model_const_output_by_name(ov_model->ov_model, output_names[
i],
777 &ov_model->output_ports[
i]);
779 status = ov_model_const_output_by_index(ov_model->ov_model,
i,
780 &ov_model->output_ports[
i]);
785 status = ov_port_get_any_name(ov_model->output_ports[
i], &port_name);
795 status = ov_core_compile_model(ov_model->
core, ov_model->ov_model, device, 0, &ov_model->compiled_model);
797 ret = ov2_map_error(status,
NULL);
800 ov_preprocess_input_model_info_free(input_model_info);
801 input_model_info =
NULL;
802 ov_layout_free(NCHW_layout);
803 ov_layout_free(NHWC_layout);
805 if (
ctx->batch_size > 1) {
806 input_shapes_t input_shapes;
807 status = ie_network_get_input_shapes(ov_model->
network, &input_shapes);
812 for (
int i = 0;
i < input_shapes.shape_num;
i++)
813 input_shapes.shapes[
i].shape.dims[0] =
ctx->batch_size;
814 status = ie_network_reshape(ov_model->
network, input_shapes);
815 ie_network_input_shapes_free(&input_shapes);
824 status = ie_network_set_input_layout(ov_model->
network, input_name, NHWC);
826 if (status == NOT_FOUND) {
835 status = ie_network_set_output_layout(ov_model->
network, output_name, NHWC);
837 if (status == NOT_FOUND) {
855 status = ie_network_set_input_precision(ov_model->
network, input_name, U8);
866 status = ie_core_get_available_devices(ov_model->
core, &a_dev);
872 for (
int i = 0;
i < a_dev.num_devices;
i++) {
876 ctx->device, all_dev_names);
882 if (
ctx->nireq <= 0) {
893 for (
int i = 0;
i <
ctx->nireq;
i++) {
913 status = ov_compiled_model_create_infer_request(ov_model->compiled_model, &item->
infer_request);
950 if (output_tensor_info)
951 ov_preprocess_output_tensor_info_free(output_tensor_info);
952 if (ov_model->output_info)
953 ov_preprocess_output_info_free(ov_model->output_info);
955 ov_layout_free(NCHW_layout);
957 ov_layout_free(NHWC_layout);
958 if (input_model_info)
959 ov_preprocess_input_model_info_free(input_model_info);
989 ov_model = task->
model;
1002 ret = ov2_map_error(status,
NULL);
1006 status = ov_infer_request_start_async(request->
infer_request);
1009 ret = ov2_map_error(status,
NULL);
1017 ret = ov2_map_error(status,
NULL);
1031 status = ie_infer_request_infer_async(request->
infer_request);
1065 int input_resizable =
ctx->ov_option.input_resizable;
1068 ov_shape_t input_shape = {0};
1069 ov_element_type_e precision;
1072 status = ov_model_const_input_by_name(ov_model->ov_model, input_name, &ov_model->input_port);
1074 status = ov_model_const_input(ov_model->ov_model, &ov_model->input_port);
1077 return ov2_map_error(status,
NULL);
1079 status = ov_port_get_element_type(ov_model->input_port, &precision);
1082 return ov2_map_error(status,
NULL);
1084 status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
1087 return ov2_map_error(status,
NULL);
1089 for (
int i = 0;
i < 4;
i++)
1090 input->
dims[
i] = input_shape.dims[
i];
1093 if (input_shape.dims[1] <= 3)
1100 if (input_resizable) {
1106 ov_shape_free(&input_shape);
1109 char *model_input_name =
NULL;
1110 IEStatusCode status;
1111 size_t model_input_count = 0;
1113 precision_e precision;
1114 status = ie_network_get_inputs_number(ov_model->
network, &model_input_count);
1119 for (
size_t i = 0;
i < model_input_count;
i++) {
1120 status = ie_network_get_input_name(ov_model->
network,
i, &model_input_name);
1125 if (strcmp(model_input_name, input_name) == 0) {
1126 ie_network_name_free(&model_input_name);
1127 status |= ie_network_get_input_dims(ov_model->
network, input_name, &dims);
1128 status |= ie_network_get_input_precision(ov_model->
network, input_name, &precision);
1134 for (
int i = 0;
i < 4;
i++)
1135 input->
dims[
i] = input_shape.dims[
i];
1136 if (input_resizable) {
1141 if (input_shape.dims[1] <= 3)
1150 ie_network_name_free(&model_input_name);
1174 if (!
header->nb_bboxes) {
1178 for (uint32_t
i = 0;
i <
header->nb_bboxes;
i++) {
1180 if (bbox->
x < 0 || bbox->
w < 0 || bbox->
x + bbox->
w >=
frame->width) {
1183 if (bbox->
y < 0 || bbox->
h < 0 || bbox->
y + bbox->
h >=
frame->height) {
1197 switch (func_type) {
1207 lltask->
task = task;
1231 for (uint32_t
i = 0;
i <
header->nb_bboxes;
i++) {
1246 lltask->
task = task;
1262 const char *output_name,
int *output_width,
int *output_height)
1265 ov_dimension_t dims[4] = {{1, 1}, {1, 1}, {input_height, input_height}, {input_width, input_width}};
1267 ov_shape_t input_shape = {0};
1268 ov_partial_shape_t partial_shape;
1270 IEStatusCode status;
1271 input_shapes_t input_shapes;
1279 .input_name = input_name,
1280 .output_names = output_name ? &output_name :
NULL,
1292 if (
ctx->ov_option.input_resizable) {
1293 status = ov_partial_shape_create(4, dims, &partial_shape);
1296 return ov2_map_error(status,
NULL);
1298 status = ov_const_port_get_shape(ov_model->input_port, &input_shape);
1301 return ov2_map_error(status,
NULL);
1303 input_shape.dims[2] = input_height;
1304 input_shape.dims[3] = input_width;
1306 status = ov_shape_to_partial_shape(input_shape, &partial_shape);
1307 ov_shape_free(&input_shape);
1310 return ov2_map_error(status,
NULL);
1313 status = ov_model_reshape_single_input(ov_model->ov_model, partial_shape);
1314 ov_partial_shape_free(&partial_shape);
1317 return ov2_map_error(status,
NULL);
1321 if (!ov_model->compiled_model) {
1323 if (
ctx->ov_option.input_resizable) {
1324 status = ie_network_get_input_shapes(ov_model->
network, &input_shapes);
1325 input_shapes.shapes->shape.dims[2] = input_height;
1326 input_shapes.shapes->shape.dims[3] = input_width;
1327 status |= ie_network_reshape(ov_model->
network, input_shapes);
1328 ie_network_input_shapes_free(&input_shapes);
1336 ret =
init_model_ov(ov_model, input_name, output_name ? &output_name :
NULL, 1);
1375 ov_core_t* core =
NULL;
1376 ov_model_t* ovmodel =
NULL;
1379 size_t node_count = 0;
1380 char *node_name =
NULL;
1381 IEStatusCode status;
1388 model = &ov_model->
model;
1391 status = ov_core_create(&core);
1395 ov_model->
core = core;
1397 status = ov_core_read_model(core,
ctx->model_filename,
NULL, &ovmodel);
1400 status = ov_get_openvino_version(&ver);
1402 "Please check if the model version matches the runtime OpenVINO Version:\n",
1403 ctx->model_filename);
1407 ov_version_free(&ver);
1410 ov_model->ov_model = ovmodel;
1415 status = ie_core_create(
"", &ov_model->
core);
1419 status = ie_core_read_network(ov_model->
core,
ctx->model_filename,
NULL, &ov_model->
network);
1422 ver = ie_c_api_version();
1424 "Please check if the model version matches the runtime OpenVINO %s\n",
1425 ctx->model_filename, ver.api_version);
1426 ie_version_free(&ver);
1431 status = ie_network_get_inputs_number(ov_model->
network, &node_count);
1436 for (
size_t i = 0;
i < node_count;
i++) {
1437 status = ie_network_get_input_name(ov_model->
network,
i, &node_name);
1443 ie_network_name_free(&node_name);
1445 status = ie_network_get_outputs_number(ov_model->
network, &node_count);
1450 for (
size_t i = 0;
i < node_count;
i++) {
1451 status = ie_network_get_output_name(ov_model->
network,
i, &node_name);
1457 ie_network_name_free(&node_name);
1487 if (!ov_model->compiled_model) {
1547 if (
ctx->batch_size > 1) {
1575 IEStatusCode status;
1599 return ov2_map_error(status,
NULL);
1607 status = ie_infer_request_infer_async(request->
infer_request);
SwsAArch64OpImplParams params
static const AVFilterPad outputs[]
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
static __device__ float fabsf(float a)
#define AV_NUM_DETECTION_BBOX_CLASSIFY
At most 4 classifications based on the detected bounding box.
static av_always_inline AVDetectionBBox * av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func_type, DNNExecBaseParams *exec_params)
void ff_dnn_wait_requests(SafeQueue *request_queue, int nireq)
Wait for all inference requests to complete before teardown.
DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVFrame **out)
Extract input and output frame from the Task Queue after asynchronous inference.
int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc)
Fill the Task for Backend Execution.
int ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx)
Allocate input and output frames and fill the Task with execution parameters.
DNN common functions different backends.
#define DNN_DEFINE_CLASS(fname)
static void infer_completion_callback(void *args)
static DNNDataType precision_to_datatype(precision_e precision)
#define APPEND_STRING(generated_string, iterate_string)
static int fill_model_input_ov(OVModel *ov_model, OVRequestItem *request)
static int get_output_ov(DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height)
static int get_datatype_size(DNNDataType dt)
static DNNAsyncStatusType dnn_get_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out)
static int get_input_ov(DNNModel *model, DNNData *input, const char *input_name)
static int init_model_ov(OVModel *ov_model, const char *input_name, const char **output_names, int nb_outputs)
static int execute_model_ov(OVRequestItem *request, Queue *inferenceq)
static const AVOption dnn_openvino_options[]
static DNNModel * dnn_load_model_ov(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx)
static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_params)
static int dnn_flush_ov(const DNNModel *model)
static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Queue *lltask_queue, DNNExecBaseParams *exec_params)
static int contain_valid_detection_bbox(AVFrame *frame)
const DNNModule ff_dnn_backend_openvino
static void dnn_free_model_ov(DNNModel **model)
static void infer_completion_callback(void *args)
static int dnn_get_height_idx_by_layout(DNNLayout layout)
static int dnn_get_width_idx_by_layout(DNNLayout layout)
#define DNN_GENERIC_ERROR
int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
int ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx)
int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index, void *log_ctx)
int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
DNN input&output process between AVFrame and DNNData.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EXTERNAL
Generic error in an external library.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
@ AV_FRAME_DATA_DETECTION_BBOXES
Bounding boxes for object detection and classification, as described by AVDetectionBBoxHeader.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
void ff_queue_destroy(Queue *q)
Destroy the Queue instance.
void * ff_queue_pop_front(Queue *q)
Remove and free first element from the Queue.
int ff_queue_push_back(Queue *q, void *v)
Add data to the tail of the queue.
void * ff_queue_peek_front(Queue *q)
Return a pointer to the data at the head of the queue.
size_t ff_queue_size(Queue *q)
Return the length of the Queue.
Queue * ff_queue_create(void)
Create a Queue instance.
int ff_safe_queue_push_back(SafeQueue *sq, void *v)
Add data to the tail of queue in the SafeQueue after locking mutex.
void * ff_safe_queue_pop_front(SafeQueue *sq)
Remove and free first element from the queue in SafeQueue.
size_t ff_safe_queue_size(SafeQueue *sq)
Return the length of the SafeQueue.
SafeQueue * ff_safe_queue_create(void)
Create and initialize a SafeQueue instance.
void ff_safe_queue_destroy(SafeQueue *sq)
Destroy the SafeQueue instance.
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
char detect_label[AV_DETECTION_BBOX_LABEL_NAME_MAX_SIZE]
Detect result with confidence.
int x
Distance in pixels from the left/top edge of the frame, together with width and height,...
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
const char ** output_names
int(* get_input)(struct DNNModel *model, DNNData *input, const char *input_name)
int(* get_output)(struct DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height)
FramePrePostProc frame_pre_proc
ClassifyPostProc classify_post_proc
FramePrePostProc frame_post_proc
DetectPostProc detect_post_proc
AVFilterContext * filter_ctx
DNNFunctionType func_type
SafeQueue * request_queue
ie_executable_network_t * exe_network
const char * all_output_names
const char * all_input_names
ie_infer_request_t * infer_request
ie_complete_call_back_t callback
LastLevelTaskItem ** lltasks
Linear double-ended data structure.
Double-ended queue with mutex locks ensuring data consistency while multithreading.
const char ** output_names
#define av_malloc_array(a, b)
static FilteringContext * filter_ctx
static float mean(const float *input, int size)