diff --git a/girs/GstAnalytics-1.0.gir b/girs/GstAnalytics-1.0.gir
index 4ab4707785..77f28c5592 100644
--- a/girs/GstAnalytics-1.0.gir
+++ b/girs/GstAnalytics-1.0.gir
@@ -204,7 +204,7 @@ Get instance size
-
+
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c
index 479153c549..329d838811 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.c
@@ -24,6 +24,8 @@
#include "gstanalyticsmeta.h"
+#include
+
GST_DEBUG_CATEGORY_STATIC (an_relation_meta_debug);
#define GST_CAT_AN_RELATION an_relation_meta_debug
@@ -252,7 +254,12 @@ GType
gst_analytics_relation_meta_api_get_type (void)
{
static GType type = 0;
- static const gchar *tags[] = { NULL };
+ static const gchar *tags[] = {
+ GST_META_TAG_VIDEO_SIZE_STR,
+ GST_META_TAG_VIDEO_ORIENTATION_STR,
+ GST_META_TAG_VIDEO_STR,
+ NULL
+ };
if (g_once_init_enter (&type)) {
GType newType =
gst_meta_api_type_register ("GstAnalyticsRelationMetaAPI", tags);
@@ -319,7 +326,8 @@ gst_analytics_relation_meta_transform (GstBuffer * transbuf,
GST_CAT_TRACE (GST_CAT_AN_RELATION, "meta transform %s",
g_quark_to_string (type));
- if (GST_META_TRANSFORM_IS_COPY (type)) {
+ if (GST_META_TRANSFORM_IS_COPY (type) ||
+ GST_VIDEO_META_TRANSFORM_IS_SCALE (type)) {
GstAnalyticsRelationMeta *rmeta = (GstAnalyticsRelationMeta *) meta;
GstAnalyticsRelationMeta *new = (GstAnalyticsRelationMeta *)
gst_buffer_get_meta (transbuf, GST_ANALYTICS_RELATION_META_API_TYPE);
@@ -339,6 +347,7 @@ gst_analytics_relation_meta_transform (GstBuffer * transbuf,
}
if (new->offset == 0) {
+ guint i;
if (new->rel_order < rmeta->rel_order) {
g_free (new->adj_mat);
@@ -372,6 +381,18 @@ gst_analytics_relation_meta_transform (GstBuffer * transbuf,
new->next_id = rmeta->next_id;
new->offset = rmeta->offset;
+ for (i = 0; i < new->length; i++) {
+ GstAnalyticsRelatableMtdData *rlt_mtd_data =
+ (GstAnalyticsRelatableMtdData *) (new->mtd_data_lookup[i] +
+ new->analysis_results);
+ if (rlt_mtd_data->impl && rlt_mtd_data->impl->mtd_meta_transform) {
+ GstAnalyticsMtd transmtd;
+ transmtd.id = rlt_mtd_data->id;
+ transmtd.meta = new;
+ rlt_mtd_data->impl->mtd_meta_transform (transbuf, &transmtd, buffer,
+ type, data);
+ }
+ }
return TRUE;
} else {
g_warning ("Trying to copy GstAnalyticsRelationMeta into non-empty meta");
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h
index 9e31544e7c..327a5d8979 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsmeta.h
@@ -78,7 +78,7 @@ struct _GstAnalyticsMtd
typedef struct {
const char *name;
- gboolean (*mtd_meta_transform) (GstBuffer *transbuf, GstAnalyticsMtd *mtd,
+ gboolean (*mtd_meta_transform) (GstBuffer *transbuf, GstAnalyticsMtd *transmtd,
GstBuffer *buffer, GQuark type,
gpointer data);
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsobjectdetectionmtd.c b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsobjectdetectionmtd.c
index c31aa62d7c..a7ee4c905c 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsobjectdetectionmtd.c
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/gstanalyticsobjectdetectionmtd.c
@@ -24,6 +24,8 @@
#include "gstanalyticsobjectdetectionmtd.h"
+#include
+
typedef struct _GstAnalyticsODMtdData GstAnalyticsODMtdData;
/**
@@ -49,9 +51,42 @@ struct _GstAnalyticsODMtdData
gfloat location_confidence_lvl;
};
+static gboolean
+gst_analytics_od_mtd_meta_transform (GstBuffer * transbuf,
+ GstAnalyticsMtd * transmtd, GstBuffer * buffer, GQuark type, gpointer data)
+{
+ if (GST_VIDEO_META_TRANSFORM_IS_SCALE (type)) {
+ GstVideoMetaTransform *trans = data;
+ gint ow, oh, nw, nh;
+ GstAnalyticsODMtdData *oddata;
+
+ ow = GST_VIDEO_INFO_WIDTH (trans->in_info);
+ nw = GST_VIDEO_INFO_WIDTH (trans->out_info);
+ oh = GST_VIDEO_INFO_HEIGHT (trans->in_info);
+ nh = GST_VIDEO_INFO_HEIGHT (trans->out_info);
+
+ oddata = gst_analytics_relation_meta_get_mtd_data (transmtd->meta,
+ transmtd->id);
+
+ oddata->x *= nw;
+ oddata->x /= ow;
+
+ oddata->w *= nw;
+ oddata->w /= ow;
+
+ oddata->y *= nh;
+ oddata->y /= oh;
+
+ oddata->h *= nh;
+ oddata->h /= oh;
+ }
+
+ return TRUE;
+}
+
static const GstAnalyticsMtdImpl od_impl = {
"object-detection",
- NULL
+ gst_analytics_od_mtd_meta_transform
};
/**
diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build
index 55bad96d59..13b0eb261a 100644
--- a/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build
+++ b/subprojects/gst-plugins-bad/gst-libs/gst/analytics/meson.build
@@ -20,7 +20,7 @@ gstanalytics = library('gstanalytics-' + api_version,
soversion : soversion,
darwin_versions : osxversion,
install : true,
- dependencies : [gstbase_dep])
+ dependencies : [gstbase_dep, gstvideo_dep])
gst_libraries += [[pkg_name, {'lib': gstanalytics}]]
pkgconfig.generate(gstanalytics,
@@ -43,7 +43,7 @@ if build_gir
'includes' : ['Gst-1.0', 'GstBase-1.0'],
'install' : true,
'extra_args' : gir_init_section + ['-DGST_USE_UNSTABLE_API'],
- 'dependencies' : [gstbase_dep]
+ 'dependencies' : [gstbase_dep, gstvideo_dep]
}
library_def += {'gir': [gir]}
if not static_build
@@ -59,6 +59,6 @@ gst_libraries += [[pkg_name, library_def]]
gstanalytics_dep = declare_dependency(link_with : gstanalytics,
include_directories : [libsinc],
sources: gen_sources,
- dependencies : [gstbase_dep])
+ dependencies : [gstbase_dep, gstvideo_dep])
meson.override_dependency(pkg_name, gstanalytics_dep)