AForge.NET Framework is a C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence - image processing, neural networks, genetic algorithms, machine learning, robotics, etc.
I have an ASP.NET code that is using WinFroms, I am trying to capture images from the webcam.
I created a camera handler class as follows:
public static Bitmap img;
public static void Initation()
{
VideoCaptureDevice video;
FilterInfoCollection filter;
try
{
filter = new FilterInfoCollection(FilterCategory.VideoInputDevice);
video = new VideoCaptureDevice(filter[0].MonikerString);
video.NewFrame += new NewFrameEventHandler(Camera_On);
video.Start();
}
catch (Exception ex)
{
throw ex;
}
}
private static void Camera_On(object sender, NewFrameEventArgs eventArgs)
{
img = (Bitmap)eventArgs.Frame.Clone();
}
public static string Save()
{
System.Drawing.Imaging.ImageFormat format = null;
format = System.Drawing.Imaging.ImageFormat.Jpeg;
string name = InitialSetup.currentLkr.Name + @"\" + InitialSetup.currentLkr.Name + "_" + DateTime.Now.ToString() + ".jpg";
name = name.Replace(@"/", "_");
name = name.Replace(" ", "_");
name = name.Replace(":", "-");
name = @"D:\" + name;
img.Save(name);
return name;
}
I first call Initiate and then I call Save, the code was working fine, then suddenly the even handler stopped firing and I started to get null value in my img variable.
I have an ASP.NET code that is using WinFroms, I am trying to capture images from the webcam.
I created a camera handler class as follows:
I first call Initiate and then I call Save, the code was working fine, then suddenly the even handler stopped firing and I started to get null value in my img variable.
Any ideas on what might be the cause to that ?