mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
opencv: motioncells: Switch to C++
Switch gstmotioncells to C++ for consistency with other OpenCV elements, and support of the new 2.4.11 API. https://bugzilla.gnome.org/show_bug.cgi?id=754148
This commit is contained in:
parent
b02dd59b52
commit
10085a5d01
5 changed files with 29 additions and 45 deletions
|
@ -17,7 +17,7 @@ libgstopencv_la_SOURCES = gstopencv.cpp \
|
|||
gstpyramidsegment.cpp \
|
||||
gsttemplatematch.c \
|
||||
gsttextoverlay.cpp \
|
||||
gstmotioncells.c \
|
||||
gstmotioncells.cpp \
|
||||
gstskindetect.cpp \
|
||||
gstretinex.cpp \
|
||||
gstfacedetect.cpp \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* GStreamer MotioCells detect areas of motion
|
||||
* Copyright (C) 2011 Robert Jobbagy <jobbagy.robert@gmail.com>
|
||||
* Copyright (C) 2011 Nicola Murino <nicola.murino@gmail.com>
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
|
@ -67,7 +67,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include "gstmotioncells.h"
|
||||
#include "motioncells_wrapper.h"
|
||||
#include <gst/video/video.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_motion_cells_debug);
|
||||
|
@ -214,95 +213,95 @@ gst_motion_cells_class_init (GstMotioncellsClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_GRID_X,
|
||||
g_param_spec_int ("gridx", "Number of Horizontal Grids",
|
||||
"You can give number of horizontal grid cells.", GRID_MIN, GRID_MAX,
|
||||
GRID_DEF, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
GRID_DEF, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_GRID_Y,
|
||||
g_param_spec_int ("gridy", "Number of Vertical Grids",
|
||||
"You can give number of vertical grid cells.", GRID_MIN, GRID_MAX,
|
||||
GRID_DEF, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
GRID_DEF, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_SENSITIVITY,
|
||||
g_param_spec_double ("sensitivity", "Motion Sensitivity",
|
||||
"You can tunning the element motion sensitivity.", SENSITIVITY_MIN,
|
||||
SENSITIVITY_MAX, SENSITIVITY_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_THRESHOLD,
|
||||
g_param_spec_double ("threshold", "Lower bound of motion cells number",
|
||||
"Threshold value for motion, when motion cells number greater sum cells * threshold, we show motion.",
|
||||
THRESHOLD_MIN, THRESHOLD_MAX, THRESHOLD_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_GAP,
|
||||
g_param_spec_int ("gap",
|
||||
"Gap is time in second, elapsed time from last motion timestamp. ",
|
||||
"If elapsed time minus form last motion timestamp is greater or equal than gap then we post motion finished bus message. ",
|
||||
GAP_MIN, GAP_MAX, GAP_DEF,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_POSTNOMOTION,
|
||||
g_param_spec_int ("postnomotion", "POSTNOMOTION",
|
||||
"If non 0 post a no_motion event is posted on the bus if no motion is detected for N seconds",
|
||||
POST_NO_MOTION_MIN, POST_NO_MOTION_MAX, POST_NO_MOTION_DEF,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MINIMUNMOTIONFRAMES,
|
||||
g_param_spec_int ("minimummotionframes", "MINIMUN MOTION FRAMES",
|
||||
"Define the minimum number of motion frames that trigger a motion event",
|
||||
MINIMUM_MOTION_FRAMES_MIN, MINIMUM_MOTION_FRAMES_MAX,
|
||||
MINIMUM_MOTION_FRAMES_DEF,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DISPLAY,
|
||||
g_param_spec_boolean ("display", "Display",
|
||||
"Motion Cells visible or not on Current Frame", FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_POSTALLMOTION,
|
||||
g_param_spec_boolean ("postallmotion", "Post All Motion",
|
||||
"Element post bus msg for every motion frame or just motion start and motion stop",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_USEALPHA,
|
||||
g_param_spec_boolean ("usealpha", "Use alpha",
|
||||
"Use or not alpha blending on frames with motion cells", TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
#if 0
|
||||
/* FIXME: should not be a long property, make it either gint or gint64
|
||||
* (is this property actually used or useful for anything?) */
|
||||
g_object_class_install_property (gobject_class, PROP_DATE,
|
||||
g_param_spec_long ("date", "Motion Cell Date",
|
||||
"Current Date in milliseconds", DATE_MIN, DATE_MAX, DATE_DEF,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
#endif
|
||||
g_object_class_install_property (gobject_class, PROP_DATAFILE,
|
||||
g_param_spec_string ("datafile", "DataFile",
|
||||
"Location of motioncells data file (empty string means no saving)",
|
||||
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
NULL, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DATAFILE_EXT,
|
||||
g_param_spec_string ("datafileextension", "DataFile Extension",
|
||||
"Extension of datafile", DEF_DATAFILEEXT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MOTIONMASKCOORD,
|
||||
g_param_spec_string ("motionmaskcoords", "Motion Mask with Coordinates",
|
||||
"The upper left x, y and lower right x, y coordinates separated with \":\", "
|
||||
"describe a region. Regions separated with \",\"", NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MOTIONMASKCELLSPOS,
|
||||
g_param_spec_string ("motionmaskcellspos",
|
||||
"Motion Mask with Cells Position",
|
||||
"The line and column idx separated with \":\" what cells want we mask-out, "
|
||||
"describe a cell. Cells separated with \",\"", NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_CELLSCOLOR,
|
||||
g_param_spec_string ("cellscolor", "Color of Motion Cells",
|
||||
"The color of motion cells separated with \",\"", "255,255,0",
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MOTIONCELLSIDX,
|
||||
g_param_spec_string ("motioncellsidx", "Motion Cells Of Interest(MOCI)",
|
||||
"The line and column idx separated with \":\", "
|
||||
"describe a cell. Cells separated with \",\"", NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_CALCULATEMOTION,
|
||||
g_param_spec_boolean ("calculatemotion", "Calculate Motion",
|
||||
"If needs calculate motion on frame you need this property setting true otherwise false",
|
||||
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
TRUE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MOTIONCELLTHICKNESS,
|
||||
g_param_spec_int ("motioncellthickness", "Motion Cell Thickness",
|
||||
"Motion Cell Border Thickness, if it's -1 then motion cell will be fill",
|
||||
THICKNESS_MIN, THICKNESS_MAX, THICKNESS_DEF,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
gst_element_class_set_static_metadata (element_class,
|
||||
"motioncells",
|
||||
|
@ -868,8 +867,8 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
motioncells_count, i;
|
||||
int thickness, success, motioncellsidxcnt, numberOfCells,
|
||||
motioncellsnumber, cellsOfInterestNumber;
|
||||
int mincellsOfInterestNumber, motiondetect, minimum_motion_frames,
|
||||
postnomotion;
|
||||
int mincellsOfInterestNumber, motiondetect;
|
||||
uint minimum_motion_frames, postnomotion;
|
||||
char *datafile;
|
||||
bool display, changed_datafile, useAlpha;
|
||||
gint64 starttime;
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <opencv2/core/core_c.h>
|
||||
#include "motioncells_wrapper.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
/* #defines don't like whitespacey bits */
|
||||
|
@ -63,24 +64,6 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstMotioncells GstMotioncells;
|
||||
typedef struct _GstMotioncellsClass GstMotioncellsClass;
|
||||
|
||||
typedef struct {
|
||||
int upper_left_x;
|
||||
int upper_left_y;
|
||||
int lower_right_x;
|
||||
int lower_right_y;
|
||||
} motionmaskcoordrect;
|
||||
|
||||
typedef struct {
|
||||
int R_channel_value;
|
||||
int G_channel_value;
|
||||
int B_channel_value;
|
||||
} cellscolor;
|
||||
|
||||
typedef struct {
|
||||
int lineidx;
|
||||
int columnidx;
|
||||
} motioncellidx;
|
||||
|
||||
struct _GstMotioncells
|
||||
{
|
||||
GstElement element;
|
||||
|
@ -99,7 +82,8 @@ struct _GstMotioncells
|
|||
cellscolor *motioncellscolor;
|
||||
motioncellidx *motioncellsidx, *motionmaskcellsidx;
|
||||
int motionmaskcoord_count, motioncells_count, motionmaskcells_count;
|
||||
int gap, thickness, datafileidx, postnomotion, minimum_motion_frames;
|
||||
int thickness;
|
||||
guint gap, datafileidx, postnomotion, minimum_motion_frames;
|
||||
guint64 motion_begin_timestamp, last_motion_timestamp, motion_timestamp,
|
||||
last_nomotion_notified, prev_buff_timestamp, cur_buff_timestamp;
|
||||
gint64 diff_timestamp, starttime;
|
||||
|
|
|
@ -56,6 +56,9 @@
|
|||
static int instanceCounter = 0;
|
||||
static bool element_id_was_max = false;
|
||||
|
||||
vector < instanceOfMC > motioncellsvector;
|
||||
vector < int > motioncellsfreeids;
|
||||
|
||||
MotionCells *mc;
|
||||
char p_str[] = "idx failed";
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@ struct instanceOfMC
|
|||
int id;
|
||||
MotionCells *mc;
|
||||
};
|
||||
vector < instanceOfMC > motioncellsvector;
|
||||
vector < int >motioncellsfreeids;
|
||||
|
||||
int searchIdx (int p_id);
|
||||
extern "C"
|
||||
|
|
Loading…
Reference in a new issue