AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

2.2.5 Version and Resize Webcam Configuration

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

2.2.5 Version and Resize Webcam Configuration

Postby mrf123 » Sat Apr 28, 2018 2:55 pm

How I can config the resolution of web cam in 2.2.5 Version of Aforge?

videoSource2 = new VideoCaptureDevice(videoDevices[1].MonikerString);
videoSource2.DesiredFrameRate = framerate;
videoSourcePlayer2.VideoSource = videoSource2;
videoSourcePlayer2.Start();
mrf123
 
Posts: 5
Joined: Sat Apr 28, 2018 2:51 pm

Re: 2.2.5 Version and Resize Webcam Configuration

Postby andrew.kirillov » Mon Apr 30, 2018 7:02 am

Use VideoResolution property to set resolution and frame rate. Use VideoCapabilities to get the list of supported resolutions.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: 2.2.5 Version and Resize Webcam Configuration

Postby mrf123 » Fri May 04, 2018 8:54 am

I know about it, not laughing to me, but I get problem when code this property. would you please add a line of code to show how set the resolution in C#?
mrf123
 
Posts: 5
Joined: Sat Apr 28, 2018 2:51 pm

Re: 2.2.5 Version and Resize Webcam Configuration

Postby andrew.kirillov » Fri May 04, 2018 9:20 am

Just do a simple search and find the solution. For example, the Snapshot Maker sample application uses VideoResolution property, so can help in understanding how to use it.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: 2.2.5 Version and Resize Webcam Configuration

Postby mrf123 » Mon May 07, 2018 8:16 am

Your snapshot maker example is not works on VS 2015 last update. No camera is found by this example, and rebuild has problem. I think these two method is not works about resolution settings with camera in your last update.
mrf123
 
Posts: 5
Joined: Sat Apr 28, 2018 2:51 pm

Re: 2.2.5 Version and Resize Webcam Configuration

Postby JuKu » Thu Aug 02, 2018 8:56 am

I'm a bit late here, but this works in my software. The trick I found is that after setting up the source, some cameras need time to respond, therefore a "try few times" loop:

Code: Select all
           
            VideoCaptureDevice source = new VideoCaptureDevice(MonikerStr);
            int tries = 0;
            while (tries < 4)
            {
                if (source == null)
                {
                    Thread.Sleep(20);
                    tries++;
                    break;
                }
                if (source.VideoCapabilities.Length > 0)
                {
                    for (int i = 0; i < source.VideoCapabilities.Length; i++)
                    {
                        MainForm.DisplayText("X: " + source.VideoCapabilities[i].FrameSize.Width.ToString() +
                            ", Y: " + source.VideoCapabilities[i].FrameSize.Height.ToString());
                    }
                    return;
                }
            }
            // if we didn't return from above:
            MainForm.DisplayText("Could not get resolution info.", KnownColor.Purple);
JuKu
 
Posts: 16
Joined: Wed Nov 13, 2013 10:44 am




Return to AForge.NET Framework

cron