cmenschel.de/flash A photo slideshow with a hand gesture interface developed in Adobe Flash Actionscript3 and FDT.
The gestures of the user are detected by a webcam and serve as an interface to control a photo slideshow.
Move your right hand in front of the camera to load a picture from the right side.
Perform actions on the left to swipe a pic from the left.
Alternatively, the mouse can be used as a control.
A hand gesture interface is obviously not for everyday use.
Eventually the hand or the whole arm get tired.
The mouse will still be our most important human computer interface.
But it makes fun and you get rid off the mouse. Check it out: cmenschel.de/flash – slash flash
Here we go: The AS3 classes for Motion Detection
1. Load the Webcam in Flash: our class: “Cam”
package Media {
import flash.media.Camera;
public class Cam {
protected var cam :Camera;
public var camLoad:Boolean = false;
protected var camFPS :Number = 25;
protected var camW :Number = 1115;
protected var camH :Number = 500;
public function Cam() {
cam = Camera.getCamera();
if (cam == null) camLoad = false;
else {
camLoad = true;
cam.setMode(camW, camH, camFPS);
}
}
}
}
2. Start the Video and the Motion Detection. Our class: “MotionDetection”
package Media {
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.display.BitmapData;
import flash.utils.setInterval;
import flash.media.Camera;
import flash.media.Video;
import flash.geom.Point;
import flash.geom.Rectangle;
public class MotionDetection extends Cam {
private var video :Video;
private var now :BitmapData;
private var prev :BitmapData;
private var myInt :Number;
private var rect : Rectangle;
private var pt : Point;
public var direction:String;
public function MotionDetection() {
if (camLoad) {
video = new Video(cam.width, cam.height);
video.attachCamera(cam);
video.y = 130;
video.scaleX = -1;
video.x = video.width;
video.alpha = 45;
now = new BitmapData(video.width, video.height);
prev = new BitmapData(video.width, video.height);
rect = new Rectangle(0, 0, video.width, video.height);
pt = new Point(0, 0);
myInt = setInterval(render, 2000/camFPS);
}
}
private function render ():void {
if (!cam.currentFPS) return;
now.draw(video);
now.draw(prev,new Matrix(),new ColorTransform(),'difference');
now.threshold(now,rect,pt,'>',0xff111111,0xffffffff);
prev.draw(video);
if (now.getPixel(0,video.height/2) > 1677721) {
direction = "left";
}
}
}
}







0 Antworten bisher ↓
Bisher wurden noch keine Kommentare geschrieben. Sei der erste Autor!
Schreibe einen Kommentar!