我对Flash或动作脚本知之甚少,但是我一直对AS3和网络摄像头有点麻烦。我有一个连接到摄像头的脚本,然后将其输出发送到一个php脚本,以保存捕获的图像。除了一个问题,这一切都可以工作。看起来,实际的Camera对象允许的最大分辨率是320x240。我把一台佳能60D连接到网络摄像机的极端,因为我有一个普通的摄像头,它的最大分辨率应该是1280x720,而我所能得到的是一张320x240的图像。到目前为止我发现的是,我可以从佳能获得的最大值也是320x240。也许我一直在看这个,但我很难过。以下是videoCapture应为1024x768的动作脚本示例。取而代之的是1024x768图像是在黑色背景下创建的,左上角是来自videoCapture的320x240图像。我显然可以调整这一点,但这会挫败质量差的目的。有什么我在这里失踪,或者甚至可能是Flash的一些限制?AS3网络摄像头分辨率/尺寸问题
// adds event listener to the stage for keydown events.
stage.addEventListener(KeyboardEvent.KEY_DOWN, detectEnterKey);
import flash.display.Bitmap;
import flash.display.BitmapData;
import com.adobe.images.JPGEncoder;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
var bandwidth:int = 0;
var quality:int = 100;
var cam:Camera = Camera.getCamera();
var videoCapture:Video = new Video();
var previewPortData:BitmapData = new BitmapData(1024, 768, true, 0x00000000);
var previewPort:Bitmap = new Bitmap(previewPortData);
function onCameraStatus(evt):void {
if (evt.code == "Camera.Muted") {
Security.showSettings(SecurityPanel.CAMERA);
}
}
// detects the keycode looking for enter key pressed.
function detectEnterKey(event:KeyboardEvent):void {
//trace("keycode: "+event.keyCode);
if (event.keyCode == Keyboard.ENTER) {
previewPortData.draw(videoCapture);
var myEncoder:JPGEncoder = new JPGEncoder(100);
var byteArray:ByteArray = myEncoder.encode(previewPortData);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var saveJPG:URLRequest = new URLRequest("save.php");
saveJPG.requestHeaders.push(header);
saveJPG.method = URLRequestMethod.POST;
saveJPG.data = byteArray;
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, sendComplete);
urlLoader.load(saveJPG);
function sendComplete(event:Event):void {
trace("compete");
}
}
}
if (cam == null) {
Security.showSettings(SecurityPanel.CAMERA);
} else {
cam.addEventListener(StatusEvent.STATUS, onCameraStatus)
cam.setQuality(bandwidth, quality);
cam.setMode(1024, 768, 30, false);
videoCapture.attachCamera(cam);
videoCapture.width = 1024;
videoCapture.height = 768;
addChild(videoCapture);
previewPort.x = 430;
previewPort.y = 50;
addChild(previewPort);
}
你使用什么操作系统? – Engineer 2012-03-09 10:22:21
我目前正在使用Windows XP。我没有机会测试其他任何东西。 – 2012-03-09 11:42:46
我肯定会尝试其他操作系统,查找更新的驱动程序等。当您执行cam.setMode()并传递分辨率时,应该尝试查找相机支持的最接近的分辨率。我的经验是,这并不好。尝试使用320x240和1024x768之间的临时分辨率来查看是否可以获得高于320x240的分辨率。 – 2012-04-02 17:29:05