You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Any ideas on what might be the cause to that ?
The text was updated successfully, but these errors were encountered:
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 ?
The text was updated successfully, but these errors were encountered: