LATEST VERSION 2.0 (10.02.2012)

Description

A module based on OpenCV library to eneabling movement detection. This module works with an UImage variable. It returns the position of the central moment of a detected moving region. You can also display the image with the detected region selected. The module only works with a static camera so in order to use it on a robot, it needs to stop moving for the duration of movement detection.

moveDetection

Module functions

UMoveDetection.new(&image); - initialize the module with a source image
UMoveDetection.mode; - set detector mode
  mode 0 - you have to get the image then call detector function manually (see example 1)
  mode 1 - get image manually in a loop (see example 2)
  mode 2 - use input port data-flow (see example 3)
UMoveDetection.image; - access to UImage variable, you can also see the image in Urbi console
UMoveDetection.width; - image width (determined by scale)
UMoveDetection.height; - image height (determined by scale)
UMoveDetection.scale; - set image scale for processing
UMoveDetection.visible; - 1 if color detected
UMoveDetection.x; - x position of central moment of the detected region
UMoveDetection.y; - y position of central moment of the detected region 
UMoveDetection.time; - processing time
UMoveDetection.fps; - algorithm performance
UMoveDetection.input; - object input (use in mode 3 only) 

Detection parameters:
UMoveDetection.duration;
- time window for analysis (in seconds) (default 1s)
UMoveDetection.frameBuffer; - size of the cyclic frame buffer used for motion detection (default 2)
UMoveDetection.diffThreshold; - difference between frame thresholds; depends on image noise (default 30)
UMoveDetection.smooth; - region smoothing filter (default 31) ATTENTION! it must be an odd value. Set smaller value for small image (higher scale)
UMoveDetection.SetImage(cvimage); - use this function to detect an object manually, you can run this function in the background

Urbiscript examples

Example 1

loadModule("UCamera");
var Global.Cam=UCamera.new(0);
loadModule("UMoveDetection");
var Global.Det=UMoveDetection.new(Global.Cam.&image);
Det.scale=2;
Det.frameBuffer=2;
Det.duration=1;
Det.smooth=31;
t: loop {
  Global.Cam.GetImage();
  Global.Det.SetImage(Global.Cam.image);
},

Example 2

loadModule("UCamera");
var Global.Cam=UCamera.new(0);
loadModule("UMoveDetection");
var Global.Det=UMoveDetection.new(Global.Cam.&image);
Det.mode=1;
Det.scale=2;
Det.frameBuffer=2;
Det.duration=1;
Det.smooth=31;
t: loop { Global.Cam.GetImage(); },

Example 3

loadModule("UCamera");
var Global.Cam=UCamera.new(0);
Global.Cam.notify=1;
loadModule("UMoveDetection");
var Global.Det=UMoveDetection.new(Global.Cam.&image);
Det.mode=2;
Det.scale=2;
Det.frameBuffer=2;
Det.duration=1;
Det.smooth=31;
var Conn = Global.Cam.&image >> Global.Det.&input;

Download

LINK

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation