FFmpeg
Loading...
Searching...
No Matches
vf_dnn_classify.c File Reference

implementing an classification filter using deep learning networks. More...

#include "libavutil/file_open.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "filters.h"
#include "dnn_filter_common.h"
#include "video.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)
 
#define OFFSET2(x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 

Functions

 AVFILTER_DNN_DEFINE_CLASS (dnn_classify, DNN_OV)
 
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_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 enum AVPixelFormat pix_fmts []
 
const FFFilter 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)
Value:

Definition at line 44 of file vf_dnn_classify.c.

◆ OFFSET2

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

Definition at line 45 of file vf_dnn_classify.c.

◆ FLAGS

Definition at line 46 of file vf_dnn_classify.c.

Function Documentation

◆ AVFILTER_DNN_DEFINE_CLASS()

AVFILTER_DNN_DEFINE_CLASS ( dnn_classify ,
DNN_OV  )

◆ 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 60 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 115 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 124 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 182 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 205 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 233 of file vf_dnn_classify.c.

◆ dnn_classify_uninit()

static av_cold void dnn_classify_uninit ( AVFilterContext * context)
static

Definition at line 289 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 = DNN_OV }, INT_MIN, INT_MAX, FLAGS, .unit = "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 }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
@ DNN_OV
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#define OFFSET2(x)

Definition at line 47 of file vf_dnn_classify.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_GRAYF32
Definition pixfmt.h:588
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76

Definition at line 196 of file vf_dnn_classify.c.

◆ ff_vf_dnn_classify

const FFFilter ff_vf_dnn_classify
Initial value:
= {
.p.name = "dnn_classify",
.p.description = NULL_IF_CONFIG_SMALL("Apply DNN classify filter to the input."),
.p.priv_class = &dnn_classify_class,
.priv_size = sizeof(DnnClassifyContext),
.activate = dnn_classify_activate,
}
int ff_dnn_filter_init_child_class(AVFilterContext *filter)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static av_cold int preinit(AVBitStreamFilterContext *ctx)
Definition source.c:137
static av_cold void dnn_classify_uninit(AVFilterContext *context)
static int dnn_classify_activate(AVFilterContext *filter_ctx)
static av_cold int dnn_classify_init(AVFilterContext *context)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37

Definition at line 296 of file vf_dnn_classify.c.