GstMotionDetect on Jetson TK1

Gst Motion Detect 0.10

Evaluating gst-motion-detect 0.10

This section shows the steps to use the evaluation version of RidgeRun's Motion Detect GStreamer plugin.

1. Copy the binary to the proper location in the TK1 board:

cp libgstmotion.so /usr/lib/arm-linux-gnueabihf/gstreamer-0.10/

2. Now check that the plugin is properly loaded by gstreamer:

gst-inspect-0.10 motion

This command should display the plugin information.

3. Finally execute the test pipeline. For this pipeline to work you will need a camera connected to the TK1 with support for 640x480@30fps, by default the pipeline uses /dev/video0.

gst-launch-0.10 v4l2src ! 'video/x-raw-yuv, width=(int)640, height=(int)480, framerate=(fraction)30/1, format=(fourcc)YUY2' ! ffmpegcolorspace ! 'video/x-raw-yuv, width=(int)640, height=(int)480, framerate=(fraction)30/1, format=(fourcc)NV12' ! motion window-x1=0 window-y1=0 window-x2=639 window-y2=479 sample-width=640 sample-height=480 bg-timeout=30 bg-frames=2 frames-offset=0 frames-to-motion=1 threshold=3 sensitivity=4 enable=true  ! 'video/x-raw-yuv, width=(int)640, height=(int)480, framerate=(fraction)30/1, format=(fourcc)NV12' ! ffmpegcolorspace ! 'video/x-raw-yuv, width=(int)640, height=(int)480, framerate=(fraction)30/1, format=(fourcc)YUY2' ! xvimagesink

This pipeline detects motion within a 640x480 window, you can play with the motion properties to change the area of detection. Also take into account that the ideal threshold and sensitivity of detection will depend on the camera used and the environment lighting conditions.

When the plugin detects motion you will see the following messages in the terminal:

******* SENDING START MOTION SIGNAL *******
******* SENDING STOP MOTION SIGNAL *******

Building gst-motion-detect 0.10

This section shows how to build gst-motion-detect-0.10 plugin for TK1. After obtaining the source code from RidgeRun, clone it in the TK1 board and run:

./autogen.sh
./configure --prefix /usr --libdir /usr/lib/arm-linux-gnueabihf/
make
sudo make install

Note: In case that a visual feedback of the detected movement is desired, the debug option can be enabled running the configure step as follows:

./configure --prefix /usr --libdir /usr/lib/arm-linux-gnueabihf/ --enable-debug

After the install, you should be able to inspect the plugin as follows:

gst-inspect-0.10 motion

Gst Motion Detect 1.0

Building gst-motion-detect 1.0

This section shows how to build gst-motion-detect-1.0 plugin for TK1. After obtaining the source code from RidgeRun, clone it in the TK1 board and run:

sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
./autogen.sh
./configure --prefix /usr --libdir /usr/lib/arm-linux-gnueabihf/
make
sudo make install

After the install, you should be able to inspect the plugin as follows:

gst-inspect-1.0 motiondetect

Testing gst-motion-detect 1.0

The plugin can be tested with the following pipeline. To work it requires a camera device in /dev/video0.

gst-launch-1.0 v4l2src ! 'video/x-raw, width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1' ! videoconvert ! 'video/x-raw, width=(int)640, height=(int)480, format=(string)NV12, framerate=(fraction)30/1' ! motiondetect window-x1=0 window-y1=0 window-x2=639 window-y2=479 sample-width=640 sample-height=480 bg-timeout=30 bg-frames=20 frames-offset=10 frames-to-motion=2 threshold=3 sensitivity=6 motion-trace=true ! videoconvert ! xvimagesink

The motion-trace property enable visual feedback of the motion detected by the plugin.