I did this Code with AForge. The Output should be a Picture taken with the Wabcam(Saved in "C:\users\me\Desktop\Picture.jpg"). The Code just dont do that and I have no Idea why. Thanks
static void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
bitmap.Save(@"c:\users\me\desktop\picture.jpg");
}
static void Main(string[] args)
{
FilterInfoCollection videoDevices = new FilterInfoCollection( FilterCategory.VideoInputDevice ); VideoCaptureDevice videoSource = new VideoCaptureDevice( videoDevices[0].MonikerString );
videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
videoSource.Start();
videoSource.SignalToStop();
}
Try this:
public static bool x = false;
static void Main(string[] args)
{
FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
videoSource.Start();
while (true)
{
if (x == true)
{
videoSource.SignalToStop();
break;
}
}
}
static void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();
bitmap.Save(@"C:\Users\Skydr\Desktop\C++_Project\a.jpg");
x = true;
}