开发者

How to increase the Quality of the camera using AS3?

I'm trying for a webcam based application. I started the code like this:

import flash.media.Camera;
import flash.media.Video;
var cam:Camera = Camera.getCamera();
a.vid1.attachCamera(cam);
a.vid1.smoothing = true;

My problem is that the quality of the video. Im using an iMac machine, in which camera quality is good. Is there any way to increase the qu开发者_运维知识库ality of the camera output?

Thanks for the help.


Here is a sample code

package
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.ActivityEvent;
    import flash.events.MouseEvent;
    import flash.media.Camera;
    import flash.media.Video;

    public class iosTest extends Sprite
    {

        private var cam:Camera;
        private var vid:Video;


        public function iosTest()
        {
            super();

            // support autoOrients
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            cam = Camera.getCamera();

            if (!cam) 
            {
                trace("No camera is installed.");
            }
            else 
            {
                connectCamera();
            }
        }

        private function connectCamera():void 
        {
            cam.setMode(640, 480, 25); 
            cam.setQuality(0,100);
            vid             = new Video();
            vid.width       = cam.width;
            vid.height      = cam.height; 
            vid.attachCamera(cam);
            addChild(vid);    

            stage.addEventListener(MouseEvent.CLICK, clickHandler);
        }

        private function clickHandler(e:MouseEvent):void 
        {

            return;

            switch (cam.width) {
                case 160:
                    cam.setMode(320, 240, 10); 
                    break;
                case 320:
                    cam.setMode(640, 480, 5); 
                    break;
                default:
                    cam.setMode(160, 120, 15); 
                    break;
            } 
            removeChild(vid);           
            connectCamera();
        }

    }
}


Use setQuality()

Parameters

bandwidth:int — Specifies the maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second. To specify that Flash Player video can use as much bandwidth as needed to maintain the value of quality, pass 0 for bandwidth. The default value is 16384.

quality:int — An integer that specifies the required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable values range from 1 (lowest quality, maximum compression) to 100 (highest quality, no compression). To specify that picture quality can vary as needed to avoid exceeding bandwidth, pass 0 for quality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜