1

, Hi, everyone. I'm currently experiencing some problems with an image capture application I need to complete in C#.

I have a Windows Form C# program that uses the DirectShow .NET library to obtain a constant flow of still images from a webcam at about 20+ frames per second. Each image is loaded into a System.Drawing.Bitmap object and processed with some filters and logic. The result is presented to the user in a picture box as the modified capture from the webcam at the same frame rate of capture or saved to disk in JPEG format.

It all works well except for the capture itself. After capturing still images constantly for a random period of time (anywhere from minutes to hours), I start getting exceptions from DirectShow .NET that the still capture timed out, or simply crashes and the whole program stops working.

I have tried to dispose of the DirectShow .NET resources and re-acquiring them, but in some instances, the program hangs waiting for either the disposal to complete or for the re-acquisition to happen.

I don't know if I'm doing it right by using the still capture, or if there is another way to access each frame from the camera with DirectShow .NET or any other technology to do the described processing that will not cause any problems after extended periods of uninterrupted work.

I do not need to show the processed video frames to the user all the time, so, I cannot have a preview window showing all the time. When the user is not monitoring, the program saves the frames to disk in JPEG format.

Any suggestions on what could be the problem, or if I should switch to another technology for the capture (if so, suggestions and information are welcome)?

sidezr
  • 163
  • 1
  • 12
  • You seem to be doing it right, except possible bugs and you possibly need to change the code slightly to do minimal blocking in the thread you receive frames on (because this processing time counts towards slowing the capture itself). – Roman R. Nov 06 '15 at 11:36

0 Answers0