Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set video resolution?

Tags:

c#

aforge

I'm working with aForge and I'm attempting to set the resolution for a video feed from an USB webcam so it fits properly in a pictureBox. I'm aiming for a resolution of 800x600, but the default resolution I get is about 640x480. When I try to set the resolution, I get the message that "members of readonly field cannot be modified". Does anyone with experience with aForge have any ideas/a solution?

like image 838
Donohvan Avatar asked Oct 17 '13 17:10

Donohvan


1 Answers

Exactly: the desiredFrameSize property is obsolete. You must use the VideoResolution property; for example, using resolution number 0:

yourvideoSource.VideoResolution = yourvideoSource.VideoCapabilities[0];

The number of the array represents a different resolution.

Use the following command to determine the amount of available resolutions and dimensions:

yourvideoSource.VideoCapabilities.Length;

for (int i = 0; i < yourvideoSource.VideoCapabilities.Length; i++ ){

    string resolution= "Resolution Number "+Convert.Tostring(i);
    string resolution_size = yourvideoSource.VideoCapabilities[i].FrameSize.ToString();
}
like image 175
Douglas_Londoo Avatar answered Sep 19 '22 14:09

Douglas_Londoo