opencv: update motioncells to GstOpencvVideoFilter
Update motioncells to inherit from GstOpencvVideoFilter instead of from GstElement. This means less code and more uniformity with other OpenCV elements.
This commit is contained in:
parent
f9464ce354
commit
40d0c1aec0
@ -141,7 +141,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("RGB")));
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("RGB")));
|
||||||
|
|
||||||
G_DEFINE_TYPE (GstMotioncells, gst_motion_cells, GST_TYPE_ELEMENT);
|
G_DEFINE_TYPE (GstMotioncells, gst_motion_cells, GST_TYPE_OPENCV_VIDEO_FILTER);
|
||||||
|
|
||||||
static void gst_motion_cells_set_property (GObject * object, guint prop_id,
|
static void gst_motion_cells_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
@ -150,8 +150,8 @@ static void gst_motion_cells_get_property (GObject * object, guint prop_id,
|
|||||||
|
|
||||||
static gboolean gst_motion_cells_handle_sink_event (GstPad * pad,
|
static gboolean gst_motion_cells_handle_sink_event (GstPad * pad,
|
||||||
GstObject * parent, GstEvent * event);
|
GstObject * parent, GstEvent * event);
|
||||||
static GstFlowReturn gst_motion_cells_chain (GstPad * pad, GstObject * parent,
|
static GstFlowReturn gst_motion_cells_transform_ip (GstOpencvVideoFilter *
|
||||||
GstBuffer * buf);
|
filter, GstBuffer * buf, IplImage * img);
|
||||||
|
|
||||||
static void gst_motioncells_update_motion_cells (GstMotioncells * filter);
|
static void gst_motioncells_update_motion_cells (GstMotioncells * filter);
|
||||||
static void gst_motioncells_update_motion_masks (GstMotioncells * filter);
|
static void gst_motioncells_update_motion_masks (GstMotioncells * filter);
|
||||||
@ -176,10 +176,6 @@ gst_motion_cells_finalize (GObject * obj)
|
|||||||
GFREE (filter->motioncellsidx);
|
GFREE (filter->motioncellsidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter->cvImage) {
|
|
||||||
cvReleaseImage (&filter->cvImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
GFREE (filter->motioncellscolor);
|
GFREE (filter->motioncellscolor);
|
||||||
GFREE (filter->prev_datafile);
|
GFREE (filter->prev_datafile);
|
||||||
GFREE (filter->cur_datafile);
|
GFREE (filter->cur_datafile);
|
||||||
@ -194,22 +190,28 @@ static void
|
|||||||
gst_motion_cells_class_init (GstMotioncellsClass * klass)
|
gst_motion_cells_class_init (GstMotioncellsClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
GstOpencvVideoFilterClass *gstopencvbasefilter_class;
|
||||||
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
gstopencvbasefilter_class = (GstOpencvVideoFilterClass *) klass;
|
||||||
|
|
||||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_motion_cells_finalize);
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_motion_cells_finalize);
|
||||||
gobject_class->set_property = gst_motion_cells_set_property;
|
gobject_class->set_property = gst_motion_cells_set_property;
|
||||||
gobject_class->get_property = gst_motion_cells_get_property;
|
gobject_class->get_property = gst_motion_cells_get_property;
|
||||||
|
|
||||||
|
gstopencvbasefilter_class->cv_trans_ip_func = gst_motion_cells_transform_ip;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_GRID_X,
|
g_object_class_install_property (gobject_class, PROP_GRID_X,
|
||||||
g_param_spec_int ("gridx", "Number of Horizontal Grids",
|
g_param_spec_int ("gridx", "Number of Horizontal Grids",
|
||||||
"You can give number of horizontal grid cells.", GRID_MIN, GRID_MAX,
|
"You can give number of horizontal grid cells.", GRID_MIN, GRID_MAX,
|
||||||
GRID_DEF, (GParamFlags) (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_object_class_install_property (gobject_class, PROP_GRID_Y,
|
||||||
g_param_spec_int ("gridy", "Number of Vertical Grids",
|
g_param_spec_int ("gridy", "Number of Vertical Grids",
|
||||||
"You can give number of vertical grid cells.", GRID_MIN, GRID_MAX,
|
"You can give number of vertical grid cells.", GRID_MIN, GRID_MAX,
|
||||||
GRID_DEF, (GParamFlags) (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_object_class_install_property (gobject_class, PROP_SENSITIVITY,
|
||||||
g_param_spec_double ("sensitivity", "Motion Sensitivity",
|
g_param_spec_double ("sensitivity", "Motion Sensitivity",
|
||||||
"You can tunning the element motion sensitivity.", SENSITIVITY_MIN,
|
"You can tunning the element motion sensitivity.", SENSITIVITY_MIN,
|
||||||
@ -315,19 +317,8 @@ gst_motion_cells_class_init (GstMotioncellsClass * klass)
|
|||||||
static void
|
static void
|
||||||
gst_motion_cells_init (GstMotioncells * filter)
|
gst_motion_cells_init (GstMotioncells * filter)
|
||||||
{
|
{
|
||||||
filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
|
gst_pad_set_event_function (GST_BASE_TRANSFORM_SINK_PAD (filter),
|
||||||
GST_PAD_SET_PROXY_CAPS (filter->sinkpad);
|
|
||||||
|
|
||||||
gst_pad_set_event_function (filter->sinkpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_motion_cells_handle_sink_event));
|
GST_DEBUG_FUNCPTR (gst_motion_cells_handle_sink_event));
|
||||||
gst_pad_set_chain_function (filter->sinkpad,
|
|
||||||
GST_DEBUG_FUNCPTR (gst_motion_cells_chain));
|
|
||||||
|
|
||||||
filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
|
|
||||||
GST_PAD_SET_PROXY_CAPS (filter->srcpad);
|
|
||||||
|
|
||||||
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
|
|
||||||
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
|
|
||||||
|
|
||||||
filter->display = TRUE;
|
filter->display = TRUE;
|
||||||
filter->calculate_motion = TRUE;
|
filter->calculate_motion = TRUE;
|
||||||
@ -385,6 +376,8 @@ gst_motion_cells_init (GstMotioncells * filter)
|
|||||||
filter->datafileidx = 0;
|
filter->datafileidx = 0;
|
||||||
filter->id = motion_cells_init ();
|
filter->id = motion_cells_init ();
|
||||||
|
|
||||||
|
gst_opencv_video_filter_set_in_place (GST_OPENCV_VIDEO_FILTER_CAST (filter),
|
||||||
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -821,11 +814,6 @@ gst_motion_cells_handle_sink_event (GstPad * pad, GstObject * parent,
|
|||||||
filter->height = info.height;
|
filter->height = info.height;
|
||||||
|
|
||||||
filter->framerate = (double) info.fps_n / (double) info.fps_d;
|
filter->framerate = (double) info.fps_n / (double) info.fps_d;
|
||||||
if (filter->cvImage)
|
|
||||||
cvReleaseImage (&filter->cvImage);
|
|
||||||
filter->cvImage =
|
|
||||||
cvCreateImage (cvSize (filter->width, filter->height), IPL_DEPTH_8U,
|
|
||||||
3);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -835,19 +823,17 @@ gst_motion_cells_handle_sink_event (GstPad * pad, GstObject * parent,
|
|||||||
res = gst_pad_event_default (pad, parent, event);
|
res = gst_pad_event_default (pad, parent, event);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* chain function
|
/* chain function
|
||||||
* this function does the actual processing
|
* this function does the actual processing
|
||||||
*/
|
*/
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
gst_motion_cells_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
|
||||||
|
IplImage * img)
|
||||||
{
|
{
|
||||||
GstMotioncells *filter;
|
GstMotioncells *filter = gst_motion_cells (base);
|
||||||
GstMapInfo info;
|
|
||||||
filter = gst_motion_cells (parent);
|
|
||||||
GST_OBJECT_LOCK (filter);
|
GST_OBJECT_LOCK (filter);
|
||||||
if (filter->calculate_motion) {
|
if (filter->calculate_motion) {
|
||||||
double sensitivity;
|
double sensitivity;
|
||||||
@ -866,12 +852,11 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
motioncellidx *motioncellsidx;
|
motioncellidx *motioncellsidx;
|
||||||
|
|
||||||
buf = gst_buffer_make_writable (buf);
|
buf = gst_buffer_make_writable (buf);
|
||||||
if (gst_buffer_map (buf, &info, GST_MAP_WRITE)) {
|
|
||||||
filter->cvImage->imageData = (char *) info.data;
|
|
||||||
if (filter->firstframe) {
|
if (filter->firstframe) {
|
||||||
setPrevFrame (filter->cvImage, filter->id);
|
setPrevFrame (img, filter->id);
|
||||||
filter->firstframe = FALSE;
|
filter->firstframe = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
minimum_motion_frames = filter->minimum_motion_frames;
|
minimum_motion_frames = filter->minimum_motion_frames;
|
||||||
postnomotion = filter->postnomotion;
|
postnomotion = filter->postnomotion;
|
||||||
sensitivity = filter->sensitivity;
|
sensitivity = filter->sensitivity;
|
||||||
@ -919,6 +904,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
filter->changed_gridy = FALSE;
|
filter->changed_gridy = FALSE;
|
||||||
filter->changed_startime = FALSE;
|
filter->changed_startime = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
datafile = g_strdup (filter->cur_datafile);
|
datafile = g_strdup (filter->cur_datafile);
|
||||||
filter->cur_buff_timestamp = (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND);
|
filter->cur_buff_timestamp = (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND);
|
||||||
filter->starttime +=
|
filter->starttime +=
|
||||||
@ -928,13 +914,12 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
filter->diff_timestamp =
|
filter->diff_timestamp =
|
||||||
(gint64) (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND);
|
(gint64) (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND);
|
||||||
changed_datafile = filter->changed_datafile;
|
changed_datafile = filter->changed_datafile;
|
||||||
|
|
||||||
motionmaskcells_count = filter->motionmaskcells_count;
|
motionmaskcells_count = filter->motionmaskcells_count;
|
||||||
motionmaskcellsidx =
|
motionmaskcellsidx = g_new0 (motioncellidx, filter->motionmaskcells_count);
|
||||||
g_new0 (motioncellidx, filter->motionmaskcells_count);
|
|
||||||
for (i = 0; i < filter->motionmaskcells_count; i++) {
|
for (i = 0; i < filter->motionmaskcells_count; i++) {
|
||||||
motionmaskcellsidx[i].lineidx = filter->motionmaskcellsidx[i].lineidx;
|
motionmaskcellsidx[i].lineidx = filter->motionmaskcellsidx[i].lineidx;
|
||||||
motionmaskcellsidx[i].columnidx =
|
motionmaskcellsidx[i].columnidx = filter->motionmaskcellsidx[i].columnidx;
|
||||||
filter->motionmaskcellsidx[i].columnidx;
|
|
||||||
}
|
}
|
||||||
motioncells_count = filter->motioncells_count;
|
motioncells_count = filter->motioncells_count;
|
||||||
motioncellsidx = g_new0 (motioncellidx, filter->motioncells_count);
|
motioncellsidx = g_new0 (motioncellidx, filter->motioncells_count);
|
||||||
@ -942,10 +927,11 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
motioncellsidx[i].lineidx = filter->motioncellsidx[i].lineidx;
|
motioncellsidx[i].lineidx = filter->motioncellsidx[i].lineidx;
|
||||||
motioncellsidx[i].columnidx = filter->motioncellsidx[i].columnidx;
|
motioncellsidx[i].columnidx = filter->motioncellsidx[i].columnidx;
|
||||||
}
|
}
|
||||||
|
|
||||||
useAlpha = filter->usealpha;
|
useAlpha = filter->usealpha;
|
||||||
thickness = filter->thickness;
|
thickness = filter->thickness;
|
||||||
success =
|
success =
|
||||||
perform_detection_motion_cells (filter->cvImage, sensitivity,
|
perform_detection_motion_cells (img, sensitivity,
|
||||||
framerate, gridx, gridy,
|
framerate, gridx, gridy,
|
||||||
(gint64) (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND) -
|
(gint64) (GST_BUFFER_TIMESTAMP (buf) / GST_MSECOND) -
|
||||||
filter->diff_timestamp, display, useAlpha, motionmaskcoord_count,
|
filter->diff_timestamp, display, useAlpha, motionmaskcoord_count,
|
||||||
@ -958,6 +944,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
int initerrorcode;
|
int initerrorcode;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
initfailedreason = getInitDataFileFailed (filter->id);
|
initfailedreason = getInitDataFileFailed (filter->id);
|
||||||
initerrorcode = getInitErrorCode (filter->id);
|
initerrorcode = getInitErrorCode (filter->id);
|
||||||
s = gst_structure_new ("motion", "init_error_code", G_TYPE_INT,
|
s = gst_structure_new ("motion", "init_error_code", G_TYPE_INT,
|
||||||
@ -971,6 +958,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
int saveerrorcode;
|
int saveerrorcode;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
savefailedreason = getSaveDataFileFailed (filter->id);
|
savefailedreason = getSaveDataFileFailed (filter->id);
|
||||||
saveerrorcode = getSaveErrorCode (filter->id);
|
saveerrorcode = getSaveErrorCode (filter->id);
|
||||||
s = gst_structure_new ("motion", "save_error_code", G_TYPE_INT,
|
s = gst_structure_new ("motion", "save_error_code", G_TYPE_INT,
|
||||||
@ -981,7 +969,6 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
}
|
}
|
||||||
if (success == -2) {
|
if (success == -2) {
|
||||||
GST_LOG_OBJECT (filter, "frame dropped");
|
GST_LOG_OBJECT (filter, "frame dropped");
|
||||||
gst_buffer_unmap (buf, &info);
|
|
||||||
filter->prev_buff_timestamp = filter->cur_buff_timestamp;
|
filter->prev_buff_timestamp = filter->cur_buff_timestamp;
|
||||||
//free
|
//free
|
||||||
GFREE (datafile);
|
GFREE (datafile);
|
||||||
@ -989,8 +976,9 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
GFREE (motionmaskcellsidx);
|
GFREE (motionmaskcellsidx);
|
||||||
GFREE (motioncellsidx);
|
GFREE (motioncellsidx);
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
return gst_pad_push (filter->srcpad, buf);
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter->changed_datafile = getChangedDataFile (filter->id);
|
filter->changed_datafile = getChangedDataFile (filter->id);
|
||||||
motioncellsidxcnt = getMotionCellsIdxCnt (filter->id);
|
motioncellsidxcnt = getMotionCellsIdxCnt (filter->id);
|
||||||
numberOfCells = filter->gridx * filter->gridy;
|
numberOfCells = filter->gridx * filter->gridy;
|
||||||
@ -1003,6 +991,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
motiondetect = (motioncellsnumber >= mincellsOfInterestNumber) ? 1 : 0;
|
motiondetect = (motioncellsnumber >= mincellsOfInterestNumber) ? 1 : 0;
|
||||||
if ((motioncellsidxcnt > 0) && (motiondetect == 1)) {
|
if ((motioncellsidxcnt > 0) && (motiondetect == 1)) {
|
||||||
char *detectedmotioncells;
|
char *detectedmotioncells;
|
||||||
|
|
||||||
filter->last_motion_timestamp = GST_BUFFER_TIMESTAMP (buf);
|
filter->last_motion_timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
detectedmotioncells = getMotionCellsIdx (filter->id);
|
detectedmotioncells = getMotionCellsIdx (filter->id);
|
||||||
if (detectedmotioncells) {
|
if (detectedmotioncells) {
|
||||||
@ -1011,6 +1000,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
&& (filter->consecutive_motion >= minimum_motion_frames)) {
|
&& (filter->consecutive_motion >= minimum_motion_frames)) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter, "motion started, post msg on the bus");
|
GST_DEBUG_OBJECT (filter, "motion started, post msg on the bus");
|
||||||
filter->previous_motion = TRUE;
|
filter->previous_motion = TRUE;
|
||||||
filter->motion_begin_timestamp = GST_BUFFER_TIMESTAMP (buf);
|
filter->motion_begin_timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
@ -1022,6 +1012,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
} else if (filter->postallmotion) {
|
} else if (filter->postallmotion) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter, "motion, post msg on the bus");
|
GST_DEBUG_OBJECT (filter, "motion, post msg on the bus");
|
||||||
filter->motion_timestamp = GST_BUFFER_TIMESTAMP (buf);
|
filter->motion_timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
s = gst_structure_new ("motion", "motion_cells_indices",
|
s = gst_structure_new ("motion", "motion_cells_indices",
|
||||||
@ -1033,6 +1024,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
} else {
|
} else {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
s = gst_structure_new ("motion", "motion_cells_indices",
|
s = gst_structure_new ("motion", "motion_cells_indices",
|
||||||
G_TYPE_STRING, "error", NULL);
|
G_TYPE_STRING, "error", NULL);
|
||||||
m = gst_message_new_element (GST_OBJECT (filter), s);
|
m = gst_message_new_element (GST_OBJECT (filter), s);
|
||||||
@ -1047,6 +1039,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
if (filter->previous_motion) {
|
if (filter->previous_motion) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (filter, "motion finished, post msg on the bus");
|
GST_DEBUG_OBJECT (filter, "motion finished, post msg on the bus");
|
||||||
filter->previous_motion = FALSE;
|
filter->previous_motion = FALSE;
|
||||||
s = gst_structure_new ("motion", "motion_finished", G_TYPE_UINT64,
|
s = gst_structure_new ("motion", "motion_finished", G_TYPE_UINT64,
|
||||||
@ -1067,6 +1060,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
filter->postnomotion) {
|
filter->postnomotion) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
GstMessage *m;
|
GstMessage *m;
|
||||||
|
|
||||||
filter->last_nomotion_notified = GST_BUFFER_TIMESTAMP (buf);
|
filter->last_nomotion_notified = GST_BUFFER_TIMESTAMP (buf);
|
||||||
s = gst_structure_new ("motion", "no_motion", G_TYPE_UINT64,
|
s = gst_structure_new ("motion", "no_motion", G_TYPE_UINT64,
|
||||||
filter->last_motion_timestamp, NULL);
|
filter->last_motion_timestamp, NULL);
|
||||||
@ -1075,8 +1069,8 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buf, &info);
|
|
||||||
filter->prev_buff_timestamp = filter->cur_buff_timestamp;
|
filter->prev_buff_timestamp = filter->cur_buff_timestamp;
|
||||||
|
|
||||||
//free
|
//free
|
||||||
GFREE (datafile);
|
GFREE (datafile);
|
||||||
GFREE (motionmaskcoords);
|
GFREE (motionmaskcoords);
|
||||||
@ -1086,10 +1080,7 @@ gst_motion_cells_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||||||
GST_WARNING_OBJECT (filter, "error mapping input buffer");
|
GST_WARNING_OBJECT (filter, "error mapping input buffer");
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
}
|
}
|
||||||
} else {
|
return GST_FLOW_OK;
|
||||||
GST_OBJECT_UNLOCK (filter);
|
|
||||||
}
|
|
||||||
return gst_pad_push (filter->srcpad, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* entry point to initialize the plug-in
|
/* entry point to initialize the plug-in
|
||||||
|
@ -45,8 +45,7 @@
|
|||||||
#ifndef __GST_MOTIONCELLS_H__
|
#ifndef __GST_MOTIONCELLS_H__
|
||||||
#define __GST_MOTIONCELLS_H__
|
#define __GST_MOTIONCELLS_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gstopencvvideofilter.h>
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <opencv2/core/core_c.h>
|
#include <opencv2/core/core_c.h>
|
||||||
#include "motioncells_wrapper.h"
|
#include "motioncells_wrapper.h"
|
||||||
|
|
||||||
@ -67,8 +66,7 @@ typedef struct _GstMotioncellsClass GstMotioncellsClass;
|
|||||||
|
|
||||||
struct _GstMotioncells
|
struct _GstMotioncells
|
||||||
{
|
{
|
||||||
GstElement element;
|
GstOpencvVideoFilter element;
|
||||||
GstPad *sinkpad, *srcpad;
|
|
||||||
GstState state;
|
GstState state;
|
||||||
gboolean display, calculate_motion, firstgridx, firstgridy, changed_gridx,
|
gboolean display, calculate_motion, firstgridx, firstgridy, changed_gridx,
|
||||||
changed_gridy, changed_startime;
|
changed_gridy, changed_startime;
|
||||||
@ -78,7 +76,6 @@ struct _GstMotioncells
|
|||||||
gchar *prev_datafile, *cur_datafile, *basename_datafile, *datafile_extension;
|
gchar *prev_datafile, *cur_datafile, *basename_datafile, *datafile_extension;
|
||||||
gint prevgridx, gridx, prevgridy, gridy, id;
|
gint prevgridx, gridx, prevgridy, gridy, id;
|
||||||
gdouble sensitivity, threshold;
|
gdouble sensitivity, threshold;
|
||||||
IplImage *cvImage;
|
|
||||||
motionmaskcoordrect *motionmaskcoords;
|
motionmaskcoordrect *motionmaskcoords;
|
||||||
cellscolor *motioncellscolor;
|
cellscolor *motioncellscolor;
|
||||||
motioncellidx *motioncellsidx, *motionmaskcellsidx;
|
motioncellidx *motioncellsidx, *motionmaskcellsidx;
|
||||||
@ -97,7 +94,7 @@ struct _GstMotioncells
|
|||||||
|
|
||||||
struct _GstMotioncellsClass
|
struct _GstMotioncellsClass
|
||||||
{
|
{
|
||||||
GstElementClass parent_class;
|
GstOpencvVideoFilterClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_motion_cells_get_type (void);
|
GType gst_motion_cells_get_type (void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user