U Move Detection
LATEST VERSION 2.0 (10.02.2012)
Description:
Another example how to use OpenCV library to detect movement on the image. This module works with UCamera module and provide some additional functionality. It returns position of central moment of detected moving region. You can also display image with selected detected region. Of course it works with static camera or just stop moving a camera (robot head or pan-tilt mechanism) during detection.
Requirement:
Urbi SDK 2.7.1 or higher
OpenCV 2.3.1
MS Visual Studio 2008 or higher for compilation from sources
Module functions:
UMoveDetection.new(&image); - initialize with image source
UMoveDetection.mode; - set detector mode
mode 0 - you have to get image then call detector function manually, you can use this option to OFF detector (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 see image in Urbi console also
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; - position of central moment of detected region
UMoveDetection.y; - -||-
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; - number of cyclic frame buffer used for motion detection (should, probably, depend on FPS) (default 2)
UMoveDetection.diffThreshold; - difference between frames threshold depends on image noise (default 30)
UMoveDetection.smooth; - region smooth filter parameter (default 31) ATTENTION! it must be odd value. Set smaller value for small image (higher scale)
UMoveDetection.SetImage(cvimage); - use this function to detect object manually, you can run this function in background
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;
//Conn.asynchronous=true; <- If asynchronous it crashes :(
Download here:
Version 2.0
http://lirec.ict.pwr.wroc.pl/~jkedzier/urbi/umovedetection20_for_opencv231.zip
You can download OpenCV2.3.1 compiled with Intel TBB libraries.
http://lirec.ict.pwr.wroc.pl/~jkedzier/urbi/OpenCV2.3.1.zip
WRUT