U Object Detection
LATEST VERSION 3.0 (10.02.2012)
Description:
Another example how to use OpenCV library to detect object on the image.
It was implemented based on existing modules and project:
http://www.urbiforge.org/index.php/Modules/Face-detection
http://www.urbiforge.org/index.php/UrbiOpenSourceContestProjects/2-high
This module works with UCamera module
http://www.urbiforge.org/index.php/Modules/UCamera
and provide some additional functionality.
Requirement:
Urbi SDK 2.7.1 or higher
OpenCV 2.3.1
MS Visual Studio 2008 or higher for compilation from sources
Module functions:
UObjectDetection.new(&image); - initialize with image source
UObjectDetection.mode; - set detector mode
mode 0 - you have to get image then call detector function manually, you can use also this option to OFF detector (see example 1)(see example 1)
mode 1 - get image manually in a loop (see example 2)
mode 2 - use input port data-flow
UObjectDetection.image; - access to UImage variable, you can see image in Urbi console also
UObjectDetection.width; - image width (determined by scale)
UObjectDetection.height; - image height (determined by scale)
UObjectDetection.cascade; - set path and name to cascade
UObjectDetection.scale; - set image scale for processing
UObjectDetection.visible; - 1 if object detected
UObjectDetection.x;
UObjectDetection.y; - object position
UObjectDetection.time; - processing time
UObjectDetection.fps; - algorithm performance
UObjectDetection.input; - object input (use in mode 3 only)
UObjectDetection.SetImage(image); - 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("UObjectDetection");
var Global.Det=UObjectDetection.new(Global.Cam.&image);
Global.Det.cascade="haarcascade_frontalface_alt2.xml";
Global.Det.scale=2;
t:loop
{
Global.Cam.GetImage();
Global.Det.SetImage(Global.Cam.image),
},
Example 2:
loadModule("UCamera");
var Global.Cam=UCamera.new(0);
loadModule("UObjectDetection");
var Global.Det=UObjectDetection.new(Global.Cam.&image);
Global.Det.mode=1;
Global.Det.cascade="haarcascade_frontalface_alt2.xml";
Global.Det.scale=2;
t:loop
{
Global.Cam.GetImage();
},
Example 3:
loadModule("UCamera");
var Global.Cam=UCamera.new(0);
Global.Cam.notify=1;
loadModule("UObjectDetection");
var Global.Det=UObjectDetection.new(Global.Cam.&image);
Global.Det.mode=2;
Global.Det.cascade="haarcascade_frontalface_alt2.xml";
Global.Det.scale=2;
var Conn = Global.Cam.&image >> Global.Det.&input;
//Conn.asynchronous=true; <- If asynchronous it crashes :(
Download here:
Version 3.0
http://lirec.ict.pwr.wroc.pl/~jkedzier/urbi/uobjectdetection30_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