AS3 - 网络摄像头的视频尺寸不结转到新的BitmapData - 默认为320×240 [英] AS3 - Webcam video dimensions not carrying over into new BitmapData - defaulting to 320x240

查看:271
本文介绍了AS3 - 网络摄像头的视频尺寸不结转到新的BitmapData - 默认为320×240的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图捕捉1920×1080的摄像头捕捉并创建一个新的位图捕获。我觉得我有所有的尺寸设置正确的,但最终的1920×1080的位图只包含一个小的320×240版本的视频捕捉。救命啊!

 匹配import flash.display.Bitmap;
进口flash.display.BitmapData;

VAR带宽:INT = 1000; //带宽的最大量,当前输出视频输入信号可以使用,以每秒字节数。
VAR质量:INT = 100; //此值是0-100其中1是最低的品质。

VAR凸轮:摄像头= Camera.getCamera();
cam.setQuality(带宽,质量);
cam.setMode(1920,1080,60,真正的); // setMode(videoWidth,videoHeight,视频帧,有利于区域)
VAR视频:视频=新视频();
和Video.attachCamera(凸轮);
video.x = 0;
video.y = -100;
video.width = 1920;
video.height = 1080;
的addChild(视频)

VAR的位图数据:的BitmapData =新的BitmapData(video.width,video.height);

VAR位:位图=新位图(位图数据);
bitmap.x = 0;
bitmap.y = 0;
bitmap.width = 1920;
bitmap.height = 1080;
的addChild(位);
bitmap.visible = FALSE;

capture_mc.buttonMode = TRUE;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);

功能captureImage(E:的MouseEvent):无效{
    的BitmapData.draw(视频)
    bitmap.visible = TRUE;
}
 

解决方案

我有一段时间几乎相同的问题挣扎。位图图像是期望的大小,但照片本身只讨论了位图图像内的空间的第三 - 留下大量的白色空间周围

希望有人能提出更好的解决方案,但这里是我做,以解决它:

  VAR反式:矩阵=新的Matrix();
trans.scale(3,3);
的BitmapData.draw(五,反式);
 

我会建议你例如,更改比例从3到三百二十分之一千九百二十零。

另一个技巧:设置拍照模式后,尝试跟踪摄像头的高度和宽度。这会告诉你有多少个像素实际上被抓获。例如,在我的项目我试着设置了以下设置:

  c.setMode(2048,1536,5,真正的);
跟踪(c.width,c.height,凸轮资源);
 

(其中,c =相机) 输出是960 720凸轮水库 - 这表明这是最大分辨率我的相机可以处理的,而不是所希望的2048 1536

产生的画面是不是像素化的,但它不是那么好由本机软件捕捉到的图片。不知道这是因为我的方法或JPGEno codeR我用COM preSS位图数据。

另外(我可能是错的这个) - 但它可能是值得一试:

  c.setQuality(0,100);
 

从而使带宽不考虑,而把重点放在质量。

I am attempting to capture a 1920x1080 webcam capture and create a new bitmap with the capture. I feel like I have all the dimension settings correct but the final 1920x1080 bitmap only contains a small 320x240 version of the video capture. Help!

import flash.display.Bitmap;
import flash.display.BitmapData;

var bandwidth:int = 1000; // Maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second.
var quality:int = 100; // This value is 0-100 with 1 being the lowest quality. 

var cam:Camera = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(1920,1080,60,true); // setMode(videoWidth, videoHeight, video fps, favor area)
var video:Video = new Video();
video.attachCamera(cam);
video.x = 0;
video.y = -100;
video.width = 1920;
video.height = 1080;
addChild(video);

var bitmapData:BitmapData = new BitmapData(video.width, video.height);

var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 0;
bitmap.y = 0;
bitmap.width = 1920;
bitmap.height = 1080;
addChild(bitmap);
bitmap.visible = false;

capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);

function captureImage(e:MouseEvent):void {
    bitmapData.draw(video);
    bitmap.visible = true;
}

解决方案

I struggled with an almost identical issue for a while. The bitmap image was the desired size, but the photo itself only took up a third of the space within the bitmap image - leaving lots of white space around it.

Hopefully someone can suggest a better solution, but here's what I did to work around it:

var trans:Matrix = new Matrix();
trans.scale(3, 3); 
bitmapData.draw(v, trans );

I would suggest for your example, change the scale from 3 to 1920/320.

Another tip: after setting the camera mode, try tracing the camera height and width. This will tell you how many pixels are actually being captured. For example, in my project I tried setting the following settings:

c.setMode(2048, 1536, 5, true);
trace (c.width, c.height, "cam res");

(where c = the camera) The output was "960 720 cam res" - suggesting that this was the maximum resolution my camera could handle, rather than the desired 2048 by 1536

The resultant picture wasn't pixelated, but it wasn't quite as good as pictures captured by the native software. Not sure if this was because of my method or the JPGEnocoder I used to compress the bitmap data.

Also (and I might be wrong about this) - but it might be worth trying:

c.setQuality(0,100);

thus making the bandwidth not a consideration, and putting the emphasis on the quality.

这篇关于AS3 - 网络摄像头的视频尺寸不结转到新的BitmapData - 默认为320×240的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆