Grab a single Frame from Webcam

csharp Syria
  • 10 years ago

    Hey guys,

    I have a problem. I just tried this sample program <a href="http://www.codeproject.com/KB/audio-video/webcamservice.aspx">http://www.codeproject.com/KB/audio-video/webcamservice.aspx</a>[<a href="http://www.codeproject.com/KB/audio-video/webcamservice.aspx" target="_blank" title="New Window">^</a>], and it worked fine. But i need to take a single Frame about 5 times each second. So that i can save 5 single pictures / sec. But as far as i know and tried to change the time to capture a single frame on 1s for example. Then i saw that the initialising process of the camera takes about 2-3 seconds. I also tried to initialise the camera only once, but then the same picture is taken all the time..so i need to initialise the camera to get a new picture? Is it possible to take more pictures in 1 second?

    if i want to take a frame,my webcamserv.exe gets called

    <code>private void button2_Click(object sender, EventArgs e)
            {
                try
                {
                   
                    n = new System.Diagnostics.Process();
                    n.StartInfo.FileName = "webcamserv.exe";
                    n.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    n.Start();
                   
               
                   
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
    </code>

    The webcamserv.exe does this:

    <code>static void Main(string[] args)
            {
                Program ServiceToRun = new Program();
                new Program().Run();
            }
            public void Run()
            {
                try
                {

                    Image image = Capture.GetImage();
                    String pfad = ConfigurationSettings.AppSettings["path"];
                    image.Save(pfad, ImageFormat.Bmp);
                    image.Dispose();

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Console.ReadKey();
                }
    </code>

    Any solutions? tips?

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only two kinds of languages: the ones people complain about and the ones nobody uses” - Bjarne Stroustrup