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_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 []
 
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_flush_frame()

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

Definition at line 209 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 237 of file vf_dnn_classify.c.

◆ dnn_classify_uninit()

static av_cold void dnn_classify_uninit ( AVFilterContext context)
static

Definition at line 293 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.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ dnn_classify_inputs

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

Definition at line 300 of file vf_dnn_classify.c.

◆ dnn_classify_outputs

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

Definition at line 307 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,
.activate = dnn_classify_activate,
}

Definition at line 314 of file vf_dnn_classify.c.

init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
DnnClassifyContext
Definition: vf_dnn_classify.c:37
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
OFFSET2
#define OFFSET2(x)
Definition: vf_dnn_classify.c:48
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:423
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
NULL
#define NULL
Definition: coverity.c:32
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:300
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
DNN_COMMON_OPTIONS
#define DNN_COMMON_OPTIONS
Definition: dnn_filter_common.h:43
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
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:307
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
dnn_classify_uninit
static av_cold void dnn_classify_uninit(AVFilterContext *context)
Definition: vf_dnn_classify.c:293
AV_PIX_FMT_NV12
@ 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:89
OFFSET
#define OFFSET(x)
Definition: vf_dnn_classify.c:47
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_dnn_classify.c:200
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
FLAGS
#define FLAGS
Definition: vf_dnn_classify.c:49
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
dnn_classify_activate
static int dnn_classify_activate(AVFilterContext *filter_ctx)
Definition: vf_dnn_classify.c:237
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228