FFmpeg
Data Structures | Macros | Functions | Variables
vf_dnn_classify.c File Reference
#include "libavformat/avio.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "filters.h"
#include "dnn_filter_common.h"
#include "formats.h"
#include "internal.h"
#include "libavutil/time.h"
#include "libavutil/avstring.h"
#include "libavutil/detection_bbox.h"

Go to the source code of this file.

Data Structures

struct  DnnClassifyContext
 

Macros

#define OFFSET(x)   offsetof(DnnClassifyContext, dnnctx.x)
 
#define OFFSET2(x)   offsetof(DnnClassifyContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (dnn_classify)
 
static int dnn_classify_post_proc (AVFrame *frame, DNNData *output, uint32_t bbox_index, AVFilterContext *filter_ctx)
 
static void free_classify_labels (DnnClassifyContext *ctx)
 
static int read_classify_label_file (AVFilterContext *context)
 
static av_cold int dnn_classify_init (AVFilterContext *context)
 
static int dnn_classify_query_formats (AVFilterContext *context)
 
static int dnn_classify_flush_frame (AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
 
static int dnn_classify_activate (AVFilterContext *filter_ctx)
 
static av_cold void dnn_classify_uninit (AVFilterContext *context)
 

Variables

static const AVOption dnn_classify_options []
 
static const AVFilterPad dnn_classify_inputs []
 
static const AVFilterPad dnn_classify_outputs []
 
const AVFilter ff_vf_dnn_classify
 

Detailed Description

implementing an classification filter using deep learning networks.

Definition in file vf_dnn_classify.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(DnnClassifyContext, dnnctx.x)

Definition at line 47 of file vf_dnn_classify.c.

◆ OFFSET2

#define OFFSET2 (   x)    offsetof(DnnClassifyContext, x)

Definition at line 48 of file vf_dnn_classify.c.

◆ FLAGS

Definition at line 49 of file vf_dnn_classify.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( dnn_classify  )

◆ dnn_classify_post_proc()

static int dnn_classify_post_proc ( AVFrame frame,
DNNData output,
uint32_t  bbox_index,
AVFilterContext filter_ctx 
)
static

Definition at line 64 of file vf_dnn_classify.c.

Referenced by dnn_classify_init().

◆ free_classify_labels()

static void free_classify_labels ( DnnClassifyContext ctx)
static

Definition at line 119 of file vf_dnn_classify.c.

Referenced by dnn_classify_uninit().

◆ read_classify_label_file()

static int read_classify_label_file ( AVFilterContext context)
static

Definition at line 128 of file vf_dnn_classify.c.

Referenced by dnn_classify_init().

◆ dnn_classify_init()

static av_cold int dnn_classify_init ( AVFilterContext context)
static

Definition at line 186 of file vf_dnn_classify.c.

◆ dnn_classify_query_formats()

static int dnn_classify_query_formats ( AVFilterContext context)
static

Definition at line 200 of file vf_dnn_classify.c.

◆ dnn_classify_flush_frame()

static int dnn_classify_flush_frame ( AVFilterLink outlink,
int64_t  pts,
int64_t *  out_pts 
)
static

Definition at line 214 of file vf_dnn_classify.c.

Referenced by dnn_classify_activate().

◆ dnn_classify_activate()

static int dnn_classify_activate ( AVFilterContext filter_ctx)
static

Definition at line 243 of file vf_dnn_classify.c.

◆ dnn_classify_uninit()

static av_cold void dnn_classify_uninit ( AVFilterContext context)
static

Definition at line 300 of file vf_dnn_classify.c.

Variable Documentation

◆ dnn_classify_options

const AVOption dnn_classify_options[]
static
Initial value:
= {
{ "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 2 }, INT_MIN, INT_MAX, FLAGS, "backend" },
{ "confidence", "threshold of confidence", OFFSET2(confidence), AV_OPT_TYPE_FLOAT, { .dbl = 0.5 }, 0, 1, FLAGS},
{ "labels", "path to labels file", OFFSET2(labels_filename), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ "target", "which one to be classified", OFFSET2(target), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ NULL }
}

Definition at line 50 of file vf_dnn_classify.c.

◆ dnn_classify_inputs

const AVFilterPad dnn_classify_inputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 307 of file vf_dnn_classify.c.

◆ dnn_classify_outputs

const AVFilterPad dnn_classify_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 315 of file vf_dnn_classify.c.

◆ ff_vf_dnn_classify

const AVFilter ff_vf_dnn_classify
Initial value:
= {
.name = "dnn_classify",
.description = NULL_IF_CONFIG_SMALL("Apply DNN classify filter to the input."),
.priv_size = sizeof(DnnClassifyContext),
.priv_class = &dnn_classify_class,
}

Definition at line 323 of file vf_dnn_classify.c.

init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
dnn_classify_query_formats
static int dnn_classify_query_formats(AVFilterContext *context)
Definition: vf_dnn_classify.c:200
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
DnnClassifyContext
Definition: vf_dnn_classify.c:37
OFFSET2
#define OFFSET2(x)
Definition: vf_dnn_classify.c:48
NULL
#define NULL
Definition: coverity.c:32
activate
filter_frame For filters that do not use the activate() callback
dnn_classify_init
static av_cold int dnn_classify_init(AVFilterContext *context)
Definition: vf_dnn_classify.c:186
dnn_classify_inputs
static const AVFilterPad dnn_classify_inputs[]
Definition: vf_dnn_classify.c:307
DNN_COMMON_OPTIONS
#define DNN_COMMON_OPTIONS
Definition: dnn_filter_common.h:43
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
dnn_classify_outputs
static const AVFilterPad dnn_classify_outputs[]
Definition: vf_dnn_classify.c:315
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
dnn_classify_uninit
static av_cold void dnn_classify_uninit(AVFilterContext *context)
Definition: vf_dnn_classify.c:300
OFFSET
#define OFFSET(x)
Definition: vf_dnn_classify.c:47
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FLAGS
#define FLAGS
Definition: vf_dnn_classify.c:49
dnn_classify_activate
static int dnn_classify_activate(AVFilterContext *filter_ctx)
Definition: vf_dnn_classify.c:243
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:244
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229