-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathgstgvawatermarkimpl.h
More file actions
107 lines (90 loc) · 6.39 KB
/
gstgvawatermarkimpl.h
File metadata and controls
107 lines (90 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*******************************************************************************
* Copyright (C) 2018-2026 Intel Corporation
*
* SPDX-License-Identifier: MIT
******************************************************************************/
#ifndef _GST_GVA_WATERMARK_IMPL_H_
#define _GST_GVA_WATERMARK_IMPL_H_
#include "inference_backend/image_inference.h"
#include <gst/base/gstbasetransform.h>
#include <gst/video/video.h>
#include <memory>
#ifndef _WIN32
#include <dlstreamer/gst/context.h>
#include <dlstreamer/vaapi/context.h>
#include <opencv2/core/va_intel.hpp>
#endif
#include <opencv2/core.hpp>
#include <opencv2/core/ocl.hpp>
#include <opencv2/imgproc.hpp>
G_BEGIN_DECLS
#define GST_TYPE_GVA_WATERMARK_IMPL (gst_gva_watermark_impl_get_type())
#define GST_GVA_WATERMARK_IMPL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_GVA_WATERMARK_IMPL, GstGvaWatermarkImpl))
#define GST_GVA_WATERMARK_IMPL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GVA_WATERMARK_IMPL, GstGvaWatermarkImplClass))
#define GST_IS_GVA_WATERMARK_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GVA_WATERMARK_IMPL))
#define GST_IS_GVA_WATERMARK_IMPL_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GVA_WATERMARK_IMPL))
typedef struct _GstGvaWatermarkImpl GstGvaWatermarkImpl;
typedef struct _GstGvaWatermarkImplClass GstGvaWatermarkImplClass;
struct _GstGvaWatermarkImpl {
GstBaseTransform base_transform;
GstVideoInfo info;
gchar *device;
gchar *displ_cfg;
bool obb;
bool displ_avgfps;
std::shared_ptr<struct Impl> impl;
InferenceBackend::MemoryType negotiated_mem_type = InferenceBackend::MemoryType::ANY;
#ifndef _WIN32
VADisplay va_dpy = nullptr;
std::shared_ptr<dlstreamer::GSTContext> gst_ctx;
std::shared_ptr<dlstreamer::VAAPIContext> vaapi_ctx;
std::shared_ptr<dlstreamer::MemoryMapperGSTToVAAPI> gst_to_vaapi;
#endif
bool overlay_ready = false;
cv::Mat overlay_cpu;
cv::UMat overlay_gpu;
};
struct _GstGvaWatermarkImplClass {
GstBaseTransformClass base_gvawatermark_class;
};
GType gst_gva_watermark_impl_get_type(void);
enum { PROP_0, PROP_DEVICE, PROP_OBB, PROP_DISPL_AVGFPS, PROP_DISPL_CFG };
#define DISPL_AVGFPS_DESCRIPTION \
"If true, display the average FPS read from gvafpscounter element on the output video, (default false)\n" \
"\t\t\tThe gvafpscounter element must be present in the pipeline.\n" \
"\t\t\te.g.: ... ! gvawatermark displ-avgfps=true ! gvafpscounter ! ..."
#define DISPL_CFG_DESCRIPTION \
"Comma separated list of KEY=VALUE parameters of displayed notations.\n" \
"\t\t\tAvailable options: \n" \
"\t\t\tshow-labels=<bool> enable or disable displaying text labels, default true\n" \
"\t\t\tfont-scale=<double 0.1 to 2.0> scale factor for text labels, default 0.5\n" \
"\t\t\tthickness=<uint 1 to 10> bounding box thickness, default 2\n" \
"\t\t\tcolor-idx=<int> color index for bounding box, keypoints, and text, default -1 (use default colors: 0 red, " \
"1 green, 2 blue)\n" \
"\t\t\tfont-type=<string> font type for text labels (simplex, plain, duplex, complex, triplex, complex_small, " \
"script_simplex, script_complex), default triplex\n" \
"\t\t\tdraw-txt-bg=<bool> enable or disable displaying text labels background, by enabling it the text color " \
"is set to white, default true\n" \
"\t\t\tshow-roi=<string> colon-separated list of labels to include (only these objects will be shown), " \
"default empty\n" \
"\t\t\thide-roi=<string> colon-separated list of labels to exclude (these objects will be hidden), default " \
"empty\n" \
"\t\t\tenable-blur=<bool> enable or disable ROI blurring for privacy protection, default false\n" \
"\t\t\tBlurring is applied only when `enable-blur=true`\n" \
"\t\t\tif no `show-blur-roi` / `hide-blur-roi` filters are set, all ROIs are blurred.\n" \
"\t\t\tshow-blur-roi=<string> colon-separated list of object labels to blur (e.g. 'face:person')\n" \
"\t\t\thide-blur-roi=<string> colon-separated list of object labels to exclude from blurring\n" \
"\t\t\tNOTE: show-blur-roi takes precedence over hide-blur-roi when both are specified\n" \
"\t\t\tNOTE: currently this option is only supported for CPU\n" \
"\t\t\ttext-x=<float> x position (pixels) for full-frame text (e.g. from gvagenai), default 0\n" \
"\t\t\ttext-y=<float> y position (pixels) for full-frame text (e.g. from gvagenai), default 25\n" \
"\t\t\te.g.: displ-cfg=show-labels=false\n" \
"\t\t\te.g.: displ-cfg=font-scale=0.5,thickness=3,color-idx=2,font-type=plain\n" \
"\t\t\te.g.: displ-cfg=show-labels=true,show-roi=person:car:truck\n" \
"\t\t\te.g.: displ-cfg=show-labels=true,hide-roi=bottle:cup\n" \
"\t\t\te.g.: displ-cfg=enable-blur=true,show-blur-roi=face:person\n" \
"\t\t\te.g.: displ-cfg=text-y=680 (place full-frame text near bottom of a 720p frame)\n"
G_END_DECLS
#endif