0

Using Flash, I'm talking a picture from the user's webcam and saving it as an image.

The image ends up with white borders on the right and bottom edges, however.

I tried to follow this solution, but that only made the white borders smaller, which is better, but I want them gone.

Here is the code that draws the white borders.

VD1 = new Video();
VD1.width = 400;
VD1.height = 300;

myCam = Camera.getCamera();
myCam.setMode(400,300,15); 

VD1.attachCamera(myCam);

var screenshot:BitmapData = new BitmapData(400,300,false);
var m:Matrix = new Matrix();
m.scale(400/(myCam.width),300/(myCam.height));
screenshot.draw(VD1,m);

I can do something like:

m.scale(400/(myCam.width-40),300/(myCam.height-25));

To temporarily remove the white borders, but for certain webcams, like those on a macbook, it doesn't work. How do I get rid of these white borders?

4

1 回答 1

1

Try capturing the video at some other resolutions:

myCam.setMode(320,240,15);

I think you want to find the "sweet spot" that will work nicely w/most web cams. The default capture resolution is 160x120. Try resolutions that are multiples of this: 640x480, 480x360, etc.

If you tell Flash Player to use a capture resolution that the web camera does not support (like maybe 400x300), Flash player will find the closest resolution that the camera supports... and I'm guessing this is what's causing the white borders.

于 2013-08-20T01:09:17.083 回答