- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using AForge.Video;
- using AForge.Video.DirectShow;
- using System.Drawing;
- namespace CamCap2
- {
- class Program
- {
- static FilterInfoCollection WebcamColl;
- static VideoCaptureDevice Device;
- static string CaptureFileName;
- static void Capture(int cameraIndex = 0)
- {
- Device.Start();
- }
- static int Main(string[] args)
- {
- if (args == null)
- {
- Console.WriteLine("args is null");
- }
- else
- {
- Console.Write("args length is ");
- Console.WriteLine(args.Length);
- for (int i = 0; i < args.Length; i++)
- {
- string argument = args[i];
- if (argument.ToLower() == "-filename")
- {
- var watch = System.Diagnostics.Stopwatch.StartNew();
- Console.WriteLine("Your file will be saved in: " + args[i + 1]);
- CaptureFileName = args[i + 1];
- Capture();
- watch.Stop();
- var elapsedMs = watch.ElapsedMilliseconds;
- Console.WriteLine("Executed in " + elapsedMs + "ms");
- return 0;
- }
- }
- }
- //Console.ReadLine();
- return 0;
- }
- static void Cam_SnapshotTaken(object sender, NewFrameEventArgs eventArgs)
- {
- Image img = (Bitmap)eventArgs.Frame.Clone();
- img.Save(@CaptureFileName);
- Device.SignalToStop();
- }
- }
- }
Последни пейстове