Skip to content

Commit

Permalink
Merge branch 'dev-0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
c-trejos authored and Carlos Rodriguez committed Feb 7, 2020
2 parents 7d64646 + 1b836bc commit a442f0b
Show file tree
Hide file tree
Showing 96 changed files with 5,604 additions and 926 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ m4/
.libs/
stamp-h*
autoregen.sh
gstinference-*.pc
gst-inference-*.pc

# Build outputs
.deps/
Expand Down
13 changes: 0 additions & 13 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
GstInference copyright (C) 2019 RidgeRun LLC

This GStreamer plug-in is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.

This GStreamer plug-in is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License below for more details.

----------------------------------------------------------------------

GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

Expand Down
6 changes: 6 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc

ALWAYS_SUBDIRS = \
gst-libs \
gst \
ext \
tests \
common \
Expand Down Expand Up @@ -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
17 changes: 12 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dnl please read gstreamer/docs/random/autotools before changing this file
dnl initialize autoconf
dnl releases only do -Wall, git and prerelease does -Werror too
dnl use a three digit version number for releases, and four for git/pre
AC_INIT([GStreamer Inference],[0.6.1.1],[https://github.com/RidgeRun/gst-inference/issues],[gst-inference])
AC_INIT([GStreamer Inference],[0.7.0.1],[https://github.com/RidgeRun/gst-inference/issues],[gst-inference])

AG_GST_INIT

Expand All @@ -20,7 +20,6 @@ AS_NANO(GST_GIT="no", GST_GIT="yes")

dnl can autoconf find the source ?
AC_CONFIG_SRCDIR([ext/r2inference/gstinference.c])
AC_CONFIG_SRCDIR([ext/opencv/gstinferenceoverlay.c])

dnl define the output header for config
AC_CONFIG_HEADERS([config.h])
Expand Down Expand Up @@ -195,7 +194,7 @@ AC_ARG_ENABLE(Bsymbolic,
dnl *** set variables based on configure arguments ***

dnl set license and copyright notice
GST_LICENSE="Proprietary"
GST_LICENSE="LGPL"
AC_DEFINE_UNQUOTED(GST_LICENSE, "$GST_LICENSE", [GStreamer Inference license])
AC_SUBST(GST_LICENSE)

Expand Down Expand Up @@ -289,8 +288,9 @@ if test "$USE_OPENCV" = "yes"; then
fi

dnl *** r2inference ***
R2INFERENCE_REQ=0.4.0
AG_GST_CHECK_FEATURE(R2INFERENCE, [RidgeRun\'s Inference Framework], r2inference, [
AG_GST_PKG_CHECK_MODULES(R2INFERENCE, r2inference-0.0)
AG_GST_PKG_CHECK_MODULES(R2INFERENCE, r2inference-0.0 >= $R2INFERENCE_REQ)
],[],[],[
AC_MSG_ERROR([Please install R2Inference from https://github.com/RidgeRun/r2inference.git])
])
Expand Down Expand Up @@ -367,6 +367,9 @@ AC_SUBST(GST_PLUGIN_LDFLAGS)

dnl *** output files ***

# Our Include path, to be shared in multiple makefiles
AC_SUBST([GSTINCLUDEDIR],[$includedir/gstreamer-1.0])

dnl keep this alphabetic per directory, please
AC_CONFIG_FILES(
Makefile
Expand All @@ -378,12 +381,17 @@ docs/version.entities
ext/Makefile
ext/opencv/Makefile
ext/r2inference/Makefile
gst/Makefile
gst/inferencecrop/Makefile
gst/inferencefilter/Makefile
gst/inferencedebug/Makefile
gst-libs/Makefile
gst-libs/gst/Makefile
gst-libs/gst/opencv/Makefile
gst-libs/gst/r2inference/Makefile
m4/Makefile
tests/check/Makefile
gst-inference-${GST_API_VERSION}.pc:gst-inference.pc.in
tests/Makefile
tests/examples/classification/Makefile
tests/examples/detection/Makefile
Expand All @@ -394,4 +402,3 @@ tests/files/Makefile
AC_OUTPUT

AG_GST_OUTPUT_PLUGINS

20 changes: 11 additions & 9 deletions ext/opencv/Makefile.am
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) \
Expand All @@ -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) \
Expand All @@ -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
60 changes: 23 additions & 37 deletions ext/opencv/gstclassificationoverlay.cc
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
Expand All @@ -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
{
Expand All @@ -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",
Expand All @@ -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 */
Expand All @@ -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;
}
6 changes: 3 additions & 3 deletions ext/opencv/gstclassificationoverlay.h
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
Expand All @@ -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

Expand Down
Loading

0 comments on commit a442f0b

Please sign in to comment.