Reputation: 1260
I just can't believe I've found NOTHING on google, I'm starting to think that may be a DUMB question, but I have to ask.
I WANT to get the MAXIMUM RESOLUTION supported by a webcam, how can I do that?
This is my actual code:
// Maximum amount of bandwidth that the current
// outgoing video feed can use, in bytes per second.
var bandwidth:int = 0;
var quality:int = 100; // This value is 0-100 with 1 being the lowest quality.
var cam:Camera = Camera.getCamera();
if(cam==null)
writeErrorPopup(NOCAMERA_ERR);
else
{
cam.addEventListener(StatusEvent.STATUS,statusHandler);
function statusHandler(evt:StatusEvent):void
{
if(cam.muted)
{
writeErrorPopup(CAMPERMISSION_ERR);
}
else
{
trace(cam.width);
}
}
cam.setQuality(bandwidth, quality);
//cam.setMode(640,480,30,false);
// setMode(videoWidth, videoHeight, video fps, favor area)
What I have understood is:
default setMode of any webcam sets its resolution to 160x120, and infact the trace returns me the 160x120 value.
if I uncomment the 640x480 setmode the trace returns me the 640x480 value, which is OK, but this is a static value, I want to understand WHICH is the webcam resolution..
any hint?
Upvotes: 2
Views: 9580
Reputation: 1006
The above answer is in the wrong order. It should be:
var cam:Camera = Camera.getCamera();
if (cam != null)
{
cam.setMode(2048,1536,30);
var vid:Video = new Video(cam.width, cam.height);
vid.attachCamera(cam);
addChild(vid);
}
This method works on windows, however I'm finding that on the mac, it is allowing all sizes up to 1920x1080 regardless of the capabilities of the camera. It will set it to the HD size regardless of whether the aspect ratio is wrong. I haven't found a workaround yet.
Upvotes: 0
Reputation: 21
same feeling ! no one on google can give a simple answer with no special talk ! here it is :
var cam:Camera = Camera.getCamera();
if (cam != null)
{
var vid:Video = new Video(cam.width, cam.height);
// setmode(width, height, framerate);
cam.setMode(2048,1536,30);
vid.attachCamera(cam);
addChild(vid);
vid.width = 2048;
vid.height =1536;
}
Upvotes: 2
Reputation: 22604
There's one way to find out:
Camera.setMode sets the height and width of the camera to the nearest possible value matching your requested resolution. So if you pick a 4:3 aspect ratio and set the size to, say, 8192x6144, you should be able to get the highest possible resolution of the camera. Just to make sure, you could also try a 16:9 or 16:10 ratio and see which returns the best result.
Upvotes: 7