How to scale the captured image with an WebCam control


Samuel Vanneste

Hello David,
I have just tried the new Webcam control with Firefox and Opera but the taken picture doesn't respect the original image's proportions.

Is it just on my part (a problem with my webcam perhaps) ?

Many thanks


decsoft

Hello Samuel,

No; it's not a problem with your webcam, Samuel, don't worry about that. The possible problem is we play with the video size in order to made the video capture. This information is only available at runtime, and the captured image size is the same than the video one. However, if we need to shown the captured image (not always needed) and we use for that an Image control (that's the way) then probably the image appear not well scaled, since the Image control sizes may is not the same than the video/captured image size.

If we maintain the application without scaling there the problem is reduced. However, I want to put available in runtime the video size (width and height) in a couple of new WebCam control variables. Then may we can use such information along the "SetStyle" action to set, if we wanted, the size of the Image control. I will inform here when this update are available Samuel.

If you need more help or have any further question, please, post it here.

P.S. Below we can see a capture of the WebCam sample application running here in my system, with a "Fake camera" program, just for another comparison.



Samuel Vanneste

Thanks a lot David, this makes sense. I am so used with other controls where the preview image provides the resulted one that I did not thought of this :)


decsoft

Hello Samuel,

You're welcome. Honestly I am not an expert in the field, but we play here three different sizes:

1º The video size, who probably does not match the WebCam control size, but scaled

2º The captured video image, who have exactly the same dimensions than the video "says"

3º The Image control, who can shown the captured image, but not neccesary have the same size

I probably we need to think into the Image capture as a preview of the video capture. If I am not wrong, the Base64 representation of the captured image have the right size, that is, the video size, that is, independently of the Image control.

Again I want to say that, at least in some cases, having the real video size (the offered by the involved API) can be useful, so I want to put the appropiate "width" and "height" variables for the WebCam control. So we can use it if needed.



decsoft

Hello Samuel,

You can upgrade your App Builder copy. Now the WebCam control have a new "Metadata" event and the "runtime" variables "VideoWidth" and "VideoHeight". I modify a bit the WebCam app sample so you can take a look if you wanted.



Samuel Vanneste

Hello David,
YES! It is working very well now. Thanks a lot for that great improvement :D


decsoft

You're welcome Samuel!



decsoft

Hello Samuel,

Certainly using the video measures information/variables provided by App Builder (in the WebCam's control's Metadata event, but not necessary using that event, we can scale the WebCam captured image. I add a kind of "scale" app's function in the "WebCam" app sample, so maybe you want to take a look. ;)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.