-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
96 changed files
with
5,604 additions
and
926 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ m4/ | |
.libs/ | ||
stamp-h* | ||
autoregen.sh | ||
gstinference-*.pc | ||
gst-inference-*.pc | ||
|
||
# Build outputs | ||
.deps/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc | |
|
||
ALWAYS_SUBDIRS = \ | ||
gst-libs \ | ||
gst \ | ||
ext \ | ||
tests \ | ||
common \ | ||
|
@@ -54,3 +55,8 @@ CRUFT_DIRS = | |
include $(top_srcdir)/common/cruft.mak | ||
|
||
all-local: check-cruft | ||
|
||
pkgconfigdir = $(libdir)/pkgconfig | ||
pkgconfig_DATA = gst-inference-@[email protected] | ||
|
||
EXTRA_DIST = gst-inference.pc.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
plugin_LTLIBRARIES = libgstinferenceoverlay.la | ||
plugin_LTLIBRARIES = libgstinferenceoverlayplugin.la | ||
|
||
libgstinferenceoverlay_la_SOURCES = \ | ||
libgstinferenceoverlayplugin_la_SOURCES = \ | ||
gstclassificationoverlay.cc \ | ||
gstdetectionoverlay.cc \ | ||
gstinferenceoverlay.c \ | ||
gstplugin.cc \ | ||
gstinferenceoverlay.cc \ | ||
gstembeddingoverlay.cc | ||
|
||
libgstinferenceoverlay_la_CFLAGS = \ | ||
libgstinferenceoverlayplugin_la_CFLAGS = \ | ||
$(GST_CFLAGS) \ | ||
$(GST_BASE_CFLAGS) \ | ||
$(GST_PLUGINS_BASE_CFLAGS) \ | ||
|
@@ -15,7 +16,7 @@ libgstinferenceoverlay_la_CFLAGS = \ | |
-I$(top_srcdir)/gst-libs | ||
|
||
|
||
libgstinferenceoverlay_la_CXXFLAGS = \ | ||
libgstinferenceoverlayplugin_la_CXXFLAGS = \ | ||
$(GST_CXXFLAGS) \ | ||
$(GST_BASE_CFLAGS) \ | ||
$(GST_PLUGINS_BASE_CFLAGS) \ | ||
|
@@ -25,23 +26,24 @@ libgstinferenceoverlay_la_CXXFLAGS = \ | |
-std=c++11 | ||
|
||
|
||
libgstinferenceoverlay_la_LIBADD = \ | ||
libgstinferenceoverlayplugin_la_LIBADD = \ | ||
$(GST_LIBS) \ | ||
$(GST_BASE_LIBS) \ | ||
$(GST_PLUGINS_BASE_LIBS) \ | ||
$(GST_VIDEO_LIBS) \ | ||
$(OPENCV_LIBS) \ | ||
$(R2INFERENCE_LIBS) \ | ||
$(top_builddir)/gst-libs/gst/r2inference/libgstinference-@[email protected] \ | ||
$(top_builddir)/gst-libs/gst/opencv/libgstinferenceoverlay-@[email protected] | ||
$(top_builddir)/gst-libs/gst/opencv/libgstinferencebaseoverlay-@[email protected] | ||
|
||
libgstinferenceoverlay_la_LDFLAGS = \ | ||
libgstinferenceoverlayplugin_la_LDFLAGS = \ | ||
$(GST_PLUGIN_LDFLAGS) | ||
|
||
libgstinferenceoverlay_la_LIBTOOLFLAGS = \ | ||
libgstinferenceoverlayplugin_la_LIBTOOLFLAGS = \ | ||
$(GST_PLUGIN_LIBTOOLFLAGS) | ||
|
||
noinst_HEADERS = \ | ||
gstclassificationoverlay.h \ | ||
gstdetectionoverlay.h \ | ||
gstinferenceoverlay.h \ | ||
gstembeddingoverlay.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* GStreamer | ||
* Copyright (C) 2018 RidgeRun | ||
* Copyright (C) 2018-2020 RidgeRun <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
|
@@ -18,30 +18,28 @@ | |
* Boston, MA 02111-1307, USA. | ||
* | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "gstclassificationoverlay.h" | ||
#include "gst/r2inference/gstinferencemeta.h" | ||
#ifdef OCV_VERSION_LT_3_2 | ||
#include "opencv2/highgui/highgui.hpp" | ||
#else | ||
#include "opencv2/imgproc.hpp" | ||
#include "opencv2/highgui.hpp" | ||
#endif | ||
|
||
/* *INDENT-OFF* */ | ||
static const cv::Scalar black = cv::Scalar (0, 0, 0, 0); | ||
static const cv::Scalar white = cv::Scalar (255, 255, 255, 255); | ||
/* *INDENT-ON* */ | ||
|
||
GST_DEBUG_CATEGORY_STATIC (gst_classification_overlay_debug_category); | ||
#define GST_CAT_DEFAULT gst_classification_overlay_debug_category | ||
|
||
/* prototypes */ | ||
static GstFlowReturn | ||
gst_classification_overlay_process_meta (GstInferenceOverlay * | ||
inference_overlay, GstVideoFrame * frame, GstMeta * meta, | ||
gdouble font_scale, gint thickness, gchar ** labels_list, gint num_labels); | ||
gst_classification_overlay_process_meta (GstInferenceBaseOverlay * | ||
inference_overlay, cv::Mat & cv_mat, GstVideoFrame * frame, GstMeta * meta, | ||
gdouble font_scale, gint thickness, gchar ** labels_list, gint num_labels, | ||
LineStyleBoundingBox style); | ||
|
||
enum | ||
{ | ||
|
@@ -50,26 +48,27 @@ enum | |
|
||
struct _GstClassificationOverlay | ||
{ | ||
GstInferenceOverlay parent; | ||
GstInferenceBaseOverlay parent; | ||
}; | ||
|
||
struct _GstClassificationOverlayClass | ||
{ | ||
GstInferenceOverlay parent; | ||
GstInferenceBaseOverlay parent; | ||
}; | ||
|
||
/* class initialization */ | ||
|
||
G_DEFINE_TYPE_WITH_CODE (GstClassificationOverlay, gst_classification_overlay, | ||
GST_TYPE_INFERENCE_OVERLAY, | ||
GST_TYPE_INFERENCE_BASE_OVERLAY, | ||
GST_DEBUG_CATEGORY_INIT (gst_classification_overlay_debug_category, | ||
"classificationoverlay", 0, | ||
"debug category for classification_overlay element")); | ||
|
||
static void | ||
gst_classification_overlay_class_init (GstClassificationOverlayClass * klass) | ||
{ | ||
GstInferenceOverlayClass *io_class = GST_INFERENCE_OVERLAY_CLASS (klass); | ||
GstInferenceBaseOverlayClass *io_class = | ||
GST_INFERENCE_BASE_OVERLAY_CLASS (klass); | ||
|
||
gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass), | ||
"classificationoverlay", "Filter", | ||
|
@@ -93,29 +92,17 @@ gst_classification_overlay_init (GstClassificationOverlay * | |
} | ||
|
||
static GstFlowReturn | ||
gst_classification_overlay_process_meta (GstInferenceOverlay * | ||
inference_overlay, GstVideoFrame * frame, GstMeta * meta, | ||
gdouble font_scale, gint thickness, gchar ** labels_list, gint num_labels) | ||
gst_classification_overlay_process_meta (GstInferenceBaseOverlay * | ||
inference_overlay, cv::Mat & cv_mat, GstVideoFrame * frame, GstMeta * meta, | ||
gdouble font_scale, gint thickness, gchar ** labels_list, gint num_labels, | ||
LineStyleBoundingBox style) | ||
{ | ||
GstClassificationMeta *class_meta; | ||
gint index, i, width, height, channels; | ||
gint index, i; | ||
gdouble max, current; | ||
cv::Mat cv_mat; | ||
cv::String str; | ||
cv::Size size; | ||
|
||
switch (GST_VIDEO_FRAME_FORMAT (frame)) { | ||
case GST_VIDEO_FORMAT_RGB: | ||
case GST_VIDEO_FORMAT_BGR: | ||
channels = 3; | ||
break; | ||
default: | ||
channels = 4; | ||
break; | ||
} | ||
width = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0) / channels; | ||
height = GST_VIDEO_FRAME_HEIGHT (frame); | ||
|
||
class_meta = (GstClassificationMeta *) meta; | ||
|
||
/* Get the most probable label */ | ||
|
@@ -133,16 +120,15 @@ gst_classification_overlay_process_meta (GstInferenceOverlay * | |
} else { | ||
str = cv::format ("Label #%d prob:%f", index, max); | ||
} | ||
cv_mat = cv::Mat (height, width, CV_MAKETYPE (CV_8U, channels), | ||
(char *) frame->data[0]); | ||
|
||
/* Put string on screen | ||
* 10*font_scale+16 aproximates text's rendered size on screen as a | ||
* lineal function to avoid using cv::getTextSize | ||
*/ | ||
cv::putText (cv_mat, str, cv::Point (0, 10*font_scale+16), cv::FONT_HERSHEY_PLAIN, | ||
font_scale, white, thickness + (thickness*0.5)); | ||
cv::putText (cv_mat, str, cv::Point (0, 10*font_scale+16), cv::FONT_HERSHEY_PLAIN, | ||
font_scale, black, thickness); | ||
cv::putText (cv_mat, str, cv::Point (0, 10 * font_scale + 16), | ||
cv::FONT_HERSHEY_PLAIN, font_scale, white, thickness + (thickness * 0.5)); | ||
cv::putText (cv_mat, str, cv::Point (0, 10 * font_scale + 16), | ||
cv::FONT_HERSHEY_PLAIN, font_scale, black, thickness); | ||
|
||
return GST_FLOW_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* GStreamer | ||
* Copyright (C) 2019 RidgeRun | ||
* Copyright (C) 2018-2020 RidgeRun <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
|
@@ -22,12 +22,12 @@ | |
#ifndef _GST_CLASSIFICATION_OVERLAY_H_ | ||
#define _GST_CLASSIFICATION_OVERLAY_H_ | ||
|
||
#include <gst/opencv/gstinferenceoverlay.h> | ||
#include <gst/opencv/gstinferencebaseoverlay.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define GST_TYPE_CLASSIFICATION_OVERLAY (gst_classification_overlay_get_type()) | ||
G_DECLARE_FINAL_TYPE (GstClassificationOverlay, gst_classification_overlay, GST, CLASSIFICATION_OVERLAY, GstInferenceOverlay) | ||
G_DECLARE_FINAL_TYPE (GstClassificationOverlay, gst_classification_overlay, GST, CLASSIFICATION_OVERLAY, GstInferenceBaseOverlay) | ||
|
||
G_END_DECLS | ||
|
||
|
Oops, something went wrong.