(ニセ)輪郭線を青く
ピクセルデータに総当たりしてるのでとても重い
動いた所が青くなります
/*
ピクセルデータに総当たりしてるのでとても重い
動いた所が青くなります
*/
package{
import flash.display.MovieClip;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.media.Video;
import flash.media.Camera;
[SWF(width="320", height="240", backgroundColor="#000000", frameRate="24")]
public class Main extends MovieClip{
private var video:Video;
private var bmpMC:MovieClip;
private var bmp:Bitmap;
private var bmpDat:BitmapData;
private var bmpDat2:BitmapData;
private var pxArray:Array;
public function Main(){
var camera:Camera = Camera.getCamera();
if ( camera != null ) {
video = new Video( 320, 240 );
video.attachCamera( camera );
video.visible=false;
bmpDat = new BitmapData(video.width, video.height);
bmpDat2 = new BitmapData(video.width, video.height);
bmp = new Bitmap( bmpDat2 );
bmpMC=new MovieClip();
bmpMC.addChild( bmp );
addChild(bmpMC);
var lenJ:uint = video.height;
var lenI:uint = video.width;
pxArray = new Array(lenI);
for(var i:uint = 0; i<=lenI; i++){
pxArray[i] = new Array(lenJ);
for(var j:uint = 0; j<=lenJ; j++){
pxArray[i][j] = 0;
}
}
addEventListener( Event.ENTER_FRAME , capVideo );
}
}
private function capVideo( e:Event ):void{
bmpDat.draw(video);
var lenJ:uint = video.height;
var lenI:uint = video.width;
for(var i:uint = 0; i<=lenI; i++){
for(var j:uint = 0; j<=lenJ; j++){
var color:uint = bmpDat.getPixel(i, j);
var diff:uint = Math.abs(color - pxArray[i][j])/65535;
bmpDat2.setPixel(i, j, diff);
pxArray[i][j] = color;
}
}
}
}
}