Skip to main content
iyyappans
Participant
December 18, 2012
Question

Finding webcam's ax resolution and aspect ratio

  • December 18, 2012
  • 1 reply
  • 2062 views

Hello,

I am displaying webcam preview to the user and then allowing them to take their own photos.

I have used Camera class for this. Everything is working fine except that I am unable to find the maximum resolution supported by the camera for video and stills.

For my purpose of face recognition, it is important to capture the photos at the highest possible resolution supported by the webcam hardware. I have searched forums and tried different approaches but was unable to find a solution for finding the cameras highest resolution.

Also, another issue associated to this what I face is that, since I am unable to get the camera's resolution. I am also not able to get the camera's aspect ratio.

Since different webcams are in different aspect ratio's these days, when I try to display it into a predefined box, the video and the captured image output are either stretched or skewed.

Please suggest me a solution for this problem

Thanks for your help,

Iyyappan

This topic has been closed for replies.

1 reply

sinious
Legend
December 18, 2012

The Camera class has a width and height property to the instance received via getCamera. This Adobe article shows you how to get the native resolution of the webcam:

http://help.adobe.com/en_US/as3/dev/WSfffb011ac560372f3fa68e8912e3ab6b8cb-8000.html#WS5b3ccc516d4fbf351e63e3d118a9b8f074-7feb

You also have setMode in which you can request a specific resolution and the cameras driver and Flash will auto-select the best/closest match to the resolution you desire:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#setMode%28%29

Cameras vary and are almost all capable of multiple resolutions and aspects. You should be pretty safe choosing the lowest possible resolution you require to achieve your facial recognition with setMode(). If your software doesn't give a good result, branch some code to try alternate resolutions.

iyyappans
iyyappansAuthor
Participant
December 19, 2012

Hi Sinious,

Thanks for your suggestions, they are very helpful and it worked great on Windows OS(using external camera).

But the problem is with IMac which has built in Camera which returns width and height values of camera class as 160 x 120.

It would be helpful if i could some help on this mac problem.

Thanks

Iyyappan S

sinious
Legend
December 19, 2012

The codebase is centralized so what you can do with the above mentioned methods is the same. In other words, unless you're willing to use a native extension and make this a desktop app, you're limited to just what ActionScript can do.

This is from the hip but I genuinely think you can consider the lowest common denominator of webcam resolutions would be a minimum of 1.3MP. Is that enough? If so, use the setMode method above and I think you can safely assume at LEAST that resolution is available. I have a lot of ancient Mac laptops (the oldest cams) at work and none of them are below 2.0. That should be way above your minimum requirement. It does require you to train your subject to be as close as possible to the camera so you maximize the input data you capture.