ActionScript Flash - 网络摄像头“onFrameChanged”事件?

时间:2012-01-15 16:49:27

标签: flash actionscript-3 event-handling webcam augmented-reality

我正在开发一个适用于网络摄像头的Flash应用程序 我想分析视频录制的每一帧......哪个是正确的事件听众?

这是我的实际代码:

private var video: Video;
private var webcam: Camera;

public function AugmentedReality() {
    webcam = Camera.getCamera();
    if (webcam != null) {
        webcam.setMode(WEB_CAMERA_WIDTH, WEB_CAMERA_HEIGHT, VIDEO_FRAME_RATE);
        video = new Video(VIDEO_WIDTH, VIDEO_HEIGHT);
        video.attachCamera(webcam);
        this.addChild(video);
        this.addEventListener(Event.ENTER_FRAME, handler);
    }
}

private function handler(aEvent : Event):void {
    // I don't want to use this handler,
    // it is called several times on the same frame if FPS is low
}

1 个答案:

答案 0 :(得分:1)

我不确定你的意思是“分析视频录制的每一帧”,但有ActivityEvent,用于检测自上一帧以来相机图像发生了变化:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#setMotionLevel

motion detection and motion tracking using Flash/ActionScript和Camera对象中也有很多工作可以找到代码示例。