GStreamer Motion Metas

From RidgeRun Developer Wiki



Previous: GStreamer_Plugins/Motion_Detection_Bin Index Next: Getting_Started







To communicate motion detection regions of interest(ROI) and detected motions, the RidgeRun’s MotionDetection plugin created two Gstreamer metadata structures (GstMeta): GstRrMotionRoiMeta and GstRrMotionMeta.  These motion metas are attached to the buffers to communicate the information to the other motion elements or to communicate the final application about the detections.

GstRrMotionRoiMeta

GstRrMotionRoiMeta provides extra buffer metadata describing an array of ROIs. Each ROI is a RrMotionRoi structure containing the following information: 

  • name: unique name identifier of the ROI
  • area: normalized area corresponding to the given ROI
  • x1: normalized horizontal position (x) of the ROI left-top corner
  • x2: normalized horizontal position (x) of the ROI right-bottom corner
  • y1: normalized vertical position (y)  of the ROI left-top corner 
  • y2: normalized vertical position (y) of the ROI right-bottom corner.


This meta is mostly used to specify the ROI to use to the downstream motion elements. The GstRrMotionDetection element adds to each buffer the GstRrMotionRoiMeta with the ROI configuration selected through its roi property.  The rest of the motion elements read this meta and process only the area specified, to avoid processing image regions that are not required.  

On the other hand, you must know this meta is used for the subsample mechanism to process only the buffer containing the RrMotionRoiMeta. By default the motion elements will only process buffers containing this meta, ignoring the buffers that don't have it, effectively subsampling the buffers processing.


GstRrMotionMeta

GstRrMotionMeta provides buffer metadata describing the motion regions within each selected ROI. The GstRrMotionMeta consists in a JSON describing each ROI and the bounding boxes of the detected motion regions per ROI.  The JSON contains an array of ROIs with the following structure:

  • name: unique name identifier of the ROI
  • x1: normalized horizontal position (x) of the ROI left-top corner
  • x2: normalized horizontal position (x) of the ROI right-bottom corner
  • y1: normalized vertical position (y)  of the ROI left-top corner 
  • y2: normalized vertical position (y) of the ROI right-bottom corner.
  • motion: an array of motion bounding boxes describing the regions where motion was detected.

Furthermore, the motion structure for the motion array is defined as follows:

  • x1: normalized horizontal position (x) of the motion detected bounding box left-top corner
  • x2: normalized horizontal position (x) of the motion detected bounding box right-bottom corner
  • y1: normalized vertical position (y)  of the motion detected bounding box left-top corner
  • y2: normalized vertical position (y) of the motion detected bounding box right-bottom corner

Following is an example of how a JSON of the GstRrMotionMeta looks like:

{

   "ROIs":[

      {

         "motion":[

            {

               "x1":0.13177083432674408,

               "x2":0.17578125,

               "y1":0.7282407283782959,

               "y2":0.80509257316589355

            },

            {

               "x1":0.62526041269302368,

               "x2":0.6484375,

               "y1":0.62870371341705322,

               "y2":0.75648152828216553

            }

         ],

         "name":"roi",

         "x1":0,

         "x2":1,

         "y1":0,

         "y2":1

      }

   ]

}

GstRrMotionMeta is used by the blob detectors to inform about the motion regions. The blob detectors generate the JSON and attach this meta to the buffers so downstream elements can get the detections. Currently, only the rrmotionoverlay uses the GstRrMotion Meta reading it from the buffer and drawing the motions indicated in the JSON. However, any element or application can get this meta from the buffer to know the areas with motion in the corresponding image. 


Previous: GStreamer_Plugins/Motion_Detection_Bin Index Next: Getting_Started