Created
April 19, 2012 13:36
-
-
Save nsdevaraj/2421017 to your computer and use it in GitHub Desktop.
Detect only skin color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" | |
xmlns:s="library://ns.adobe.com/flex/spark" | |
xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="appComplete(event)" width="400" height="300"> | |
<fx:Script> | |
<![CDATA[ | |
import mx.events.FlexEvent; | |
private var video:Video; | |
private var camera:Camera; | |
private var viewbd:BitmapData; | |
private var skinner:DetectSkin = new DetectSkin(); | |
protected function appComplete(event:FlexEvent):void | |
{ | |
init(400,300); | |
addEventListener(Event.ENTER_FRAME, enterFrame); | |
stg.addChild(skinner); | |
} | |
private function setupCamera(wt:int,ht:int):void{ | |
video = new Video(wt,ht); | |
video.attachCamera(camera); | |
} | |
private function init(wt:int,ht:int):void{ | |
var bmp:Bitmap; | |
camera = Camera.getCamera(); | |
if (camera != null){ | |
setupCamera(wt,ht); | |
} else { | |
return; | |
}; | |
viewbd = new BitmapData(wt,ht); | |
bmp = new Bitmap(viewbd); | |
bmp.width = wt; | |
bmp.height = ht; | |
skinner.addChild(bmp); | |
} | |
private function enterFrame(ev:Event):void{ | |
viewbd.lock(); | |
viewbd.draw(video); | |
skinner.detectSkinCount(viewbd); | |
viewbd.unlock(); | |
} | |
]]> | |
</fx:Script> | |
<s:SpriteVisualElement id="stg"/> | |
</s:WindowedApplication> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment