ActionScript 管理空中摄像机应用程序

发布于 2024-12-25 13:15:31 字数 133 浏览 2 评论 0原文

有谁知道由attachCamera()调度的事件的名称,我想在相机加载时拍照,我尝试在调用attachCamera后执行我的代码,但它使VideoDisplay为空,这就是为什么我会想知道在 Attachcamera() 完成加载后是否触发了一个事件。

Does anyone know the name of the event that is dispatch by the attachCamera(), i would like to take a picture ones the camera is loaded, i try to execute my code after call attachCamera but it takes the VideoDisplay empty, that's why i would like to know if there is an event triggered after the attachcamera() is complete loeaded.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

单调的奢华 2025-01-01 13:15:31

要“拍摄”照片,您需要绘制位图,该位图使用相机输入作为源。您必须定义位图容器的 x/y 并将其放置在其中...

绘制位图后,您可以对其执行许多操作...取决于您想要的内容。

To "take" a picture, you'll need to draw a bitmap, which uses the camera input as it's source. You must define the x/y of the bitmap container and place it inside...

There are a number of things you can do with the bitmap once it's drawn...Depends on what you want.

旧街凉风 2025-01-01 13:15:31

您可以通过查看此 Adobe 文档中关于 Camera 类的示例。此外,研究如何使用 Video 对于了解 Air 的使用方式也很有用可能会使用相机提要(这依赖于使用 视频类,当然)。

You can see how the camera activity might work by looking at this example in the Adobe docs on the Camera class. Also, researching how to use Video is useful in understanding how Air might use the camera feed (this relies on using the Video class, of course).

谎言 2025-01-01 13:15:31

计时器可以工作,但更直接的解决方案是在调用 Video.attachCamera() 后处理由 Camera 实例分派的第一个 ActivityEvent。像这样:

var video:Video = new Video();
var camera:Camera = Camera.getCamera();
camera.addEventListener(ActivityEvent.ACTIVITY, onCameraActivity);

private function onCameraActivity (evt:ActivityEvent) :void {
    camera.removeEventListener(ActivityEvent.ACTIVITY, onCameraActivity);

    // wait a bit to ensure the camera frame is not empty    
    var timer:Timer = new Timer(50, 1);
    timer.addEventListener(TimerEvent.TIMER_COMPLETE,
        function (evt:TimerEvent) :void {
            timer.removeEventListener(TimerEvent.TIMER_COMPLETE, arguments.callee);

            // take snapshot here
            var bitmapData:BitmapData = new BitmapData(video.width, video.height);
            bitmapData.draw(video);
        }
    );
    timer.start();
}

编辑:有些相机需要一些时间来初始化,因此在 ActivityEvent.ACTIVITY 之后捕获第一帧会导致空白帧。添加了短暂的超时来解决此问题。

A timer will work, but a more direct solution is to handle the first ActivityEvent dispatched by the Camera instance after Video.attachCamera() is called. Like so:

var video:Video = new Video();
var camera:Camera = Camera.getCamera();
camera.addEventListener(ActivityEvent.ACTIVITY, onCameraActivity);

private function onCameraActivity (evt:ActivityEvent) :void {
    camera.removeEventListener(ActivityEvent.ACTIVITY, onCameraActivity);

    // wait a bit to ensure the camera frame is not empty    
    var timer:Timer = new Timer(50, 1);
    timer.addEventListener(TimerEvent.TIMER_COMPLETE,
        function (evt:TimerEvent) :void {
            timer.removeEventListener(TimerEvent.TIMER_COMPLETE, arguments.callee);

            // take snapshot here
            var bitmapData:BitmapData = new BitmapData(video.width, video.height);
            bitmapData.draw(video);
        }
    );
    timer.start();
}

EDIT: Some cameras take a bit of time to initialize, so capturing the first frame after ActivityEvent.ACTIVITY results in a blank frame. Added a brief timeout to address this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文