video API structure

Following listing presents how to access video stream from robot structure and how robot structure functions utilize modules.

//example of robot.video function
//getting color of user torso - UImageTool and UKinect cooperation
function GetTorsoColor()
{
   if (robot.video.humanDetector.torso.visible) //it torso is visible
    {
    var window = robot.video.humanDetector.torso.color.window|
    var pointCor = robot.video.humanDetector.torso.positionOnImage| //we copy torso coordinates
    ImageTool4.setImage(Kinect.colorImage);
    if (pointCor.size>0) 
    {
  var x1=pointCor[0]-window;
  var y1=pointCor[1]-window;
  //checking if coordinates are inside image
  if (x1>(640-window-1)) x1=640-window-1;
  if (y1>(480-window-1)) y1=480-window-1;
  if (x1<0) x1=0;
  if (y1<0) y1=0;
  ImageTool4.imgROI(x1,y1,window,window); //using ImageTool to snip the fragment of the image around the torso
  ImageTool4.imgMedianBlur(11);//bluring the fragment of the image around the torso, in order to get its mean color
  var pointVal = ImageTool4.getPixelValue(window/2,window/2);//getting the mean color of the torso
  robot.video.humanDetector.torso.color.value = pointVal;//assigning the color to variable inside the robot structure
  //torso color visualization
  ImageTool4.putCircle(window/2,window/2,window/4,pointVal[0],pointVal[1],pointVal[2],-1);
  ImageTool4.putCircle(window/2,window/2,window/4-1,0,0,0,1);
  ImageTool4.putCircle(window/2,window/2,window/4,255,255,255,1);
  ImageTool4.updateImage;
    } else {
  robot.video.humanDetector.torso.color.value = [];
  ImageTool4.createImage(window,window,0,0,0);
  ImageTool4.putLine(0,0,window-1,window-1,200,0,0,1);
  ImageTool4.putLine(0,window-1,window-1,0,200,0,0,1);
  ImageTool4.updateImage;
    };
    };    
};
//using notify access mechanism in urbiscript for automatic update of torso color
UVar.new(Global.Kinect,"value4");
Kinect.&value4.notifyAccess( closure() {GetTorsoColor();});
Global.Kinect.getSlot("value4").copy(robot.video.humanDetector.torso.color,"value");
//reading the current torso color in urbiscript:
robot.video.humanDetector.torso.color.value;

 

 

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

FLASH Documentation