video API examples

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

//simple example of face tracking
robot.video.Run(),//starts infinite loop which updates video stream
faceTracking: loop
{
    if (robot.video.humanDetector.head.faceIsTracking) {
      var pos = robot.video.humanDetector.head.position;//all necessary information extracted from the video are provided by robot structure
      robot.body.neck.head.MoveAt(-pos[4],pos[3],1); 
    };
},
//we can easily use other video features, e.g. movement tracking
tag2:whenever (robot.video.moveDetector.visible)//whenever movement was detected
{
   echo("Movement detected, X: "+ robot.video.moveDetector.x + ", Y: " + robot.video.moveDetector.y);//print coordinates of center of area where movement was detected
   robot.video.photo.Take("camera");//takes the photo from camera
   robot.video.photo.Save("path/fileName.jpg");//and saves it to given location and name
},
t:loop{
   robot.video.display[0].show(robot.video.camera.image);
   robot.video.display[1].show(robot.video.camera.image);
   sleep(30ms);
},

 

 

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

FLASH Documentation