private void Ini_tirar_foto() { AForge.Video.DirectShow.FilterInfoCollection videosources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); if (videosources != null) { videoSource = new AForge.Video.DirectShow.VideoCaptureDevice(videosources[0].MonikerString); videoSource.NewFrame += (s, f) => perfilPB.Image = (Bitmap)f.Frame.Clone(); videoSource.Start(); } }
public static string[] GetVideoInputs() { var devices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice); List <string> list = new List <string>(); for (int i = 0; i < devices.Count; i++) { list.Add(devices[i].Name); } return(list.ToArray()); }
public TFCapturaVideo() { InitializeComponent(); AForge.Video.DirectShow.FilterInfoCollection videosources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); if (videosources != null) { videoSource = new AForge.Video.DirectShow.VideoCaptureDevice(videosources[0].MonikerString); videoSource.NewFrame += (s, e) => pbImagem.Image = (Bitmap)e.Frame.Clone(); videoSource.Start(); } }
IList <CameraInterfaceInformation> GetCameraInterfaceInformationList() { var ret = new List <CameraInterfaceInformation>(); try { var vidKeyStr = "vid_" + Win32SetupDiForEgsDevice.VendorId.ToString("x", CultureInfo.InvariantCulture); var pidKeyStr = "pid_" + Win32SetupDiForEgsDevice.ProductId.ToString("x", CultureInfo.InvariantCulture); AForgeVideoCaptureDeviceInformationCollection = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); int variousMakersCamerasCount = AForgeVideoCaptureDeviceInformationCollection.Count; for (int i = 0; i < variousMakersCamerasCount; i++) { string description = AForgeVideoCaptureDeviceInformationCollection[i].Name; string devicePath = AForgeVideoCaptureDeviceInformationCollection[i].MonikerString; if (devicePath.Contains(vidKeyStr) && devicePath.Contains(pidKeyStr)) { var matchedItem = new CameraInterfaceInformation() { Index = (uint)i, Description = description, DevicePath = devicePath }; // TODO: MUSTDO: get serial number from device path var devicePathSubStrings = devicePath.Split('#').SelectMany(e => e.Split('&')); if (false) { foreach (var item in devicePathSubStrings) { Debug.WriteLine(item); } ; } matchedItem.RootDeviceDevicePath = devicePathSubStrings.Where(e => e.ToLowerInvariant().Contains("exva")).SingleOrDefault(); ret.Add(matchedItem); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); if (ApplicationCommonSettings.IsDebugging) { Debugger.Break(); } throw; } return(ret); }
public static bool CheckSupportSize(int cameraId, int width, int height) { var videoDevices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice); var videoDevice = new AForge.Video.DirectShow.VideoCaptureDevice(videoDevices[cameraId].MonikerString); foreach (var item in videoDevice.VideoCapabilities) { if (item.FrameSize.Width == width && item.FrameSize.Height == height) { videoDevice.VideoResolution = item; } } if (videoDevice.VideoResolution == null) { return(false); } else { return(true); } }
public CameraAForge(int camera, int width, int height, Action <byte[]> callBack) { _callBack = callBack; _ffscale = new FFScale(width, height, 3, 24, width, height, 0, 12); videoDevices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice); videoDevice = new AForge.Video.DirectShow.VideoCaptureDevice(videoDevices[camera].MonikerString); foreach (var item in videoDevice.VideoCapabilities) { if (item.FrameSize.Width == width && item.FrameSize.Height == height) { videoDevice.VideoResolution = item; } } if (videoDevice.VideoResolution == null) { throw new Exception(string.Format("摄像头不支持{0}*{1}分辨率", width, height)); } videoDevice.NewFrame += NewFrame; videoDevice.RGBRawFrame += YUVFrame; }
public void FindFace(PictureBox pb) { AForge.Video.DirectShow.VideoCaptureDevice FinalVideoSource; AForge.Video.DirectShow.FilterInfoCollection VideoCaptuerDevices; VideoCaptuerDevices = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); FinalVideoSource = new AForge.Video.DirectShow.VideoCaptureDevice(VideoCaptuerDevices[0].MonikerString); FinalVideoSource.NewFrame += new AForge.Video.NewFrameEventHandler((sender, eventArgs) => { Bitmap image = (Bitmap)eventArgs.Frame.Clone(); pb.Image = image; }); FinalVideoSource.Start(); FinalVideoSource.NewFrame += new AForge.Video.NewFrameEventHandler((sender, eventArgs) => { Bitmap image = (Bitmap)eventArgs.Frame.Clone(); //görüntüde yüz aranacağı belirtilir. Accord.Vision.Detection.Cascades.FaceHaarCascade cascade = new Accord.Vision.Detection.Cascades.FaceHaarCascade(); //görüntü üzerinde arama yapar. İkinci parametresi minimum arama alanıdır. Accord.Vision.Detection.HaarObjectDetector detector = new Accord.Vision.Detection.HaarObjectDetector(cascade, 1); detector.SearchMode = Accord.Vision.Detection.ObjectDetectorSearchMode.Single; detector.ScalingFactor = 1.5f; detector.ScalingMode = Accord.Vision.Detection.ObjectDetectorScalingMode.GreaterToSmaller; detector.UseParallelProcessing = true; detector.Suppression = 3; Rectangle[] faces = detector.ProcessFrame(image); Graphics g = Graphics.FromImage(image); foreach (var face in faces) { Pen p = new Pen(Color.Red, 10f); g.DrawRectangle(p, face); } g.Dispose(); pb.Image = image; }); }
public TakePicture(MainForm mainForm) { InitializeComponent(); this.mainForm = mainForm; AForge.Video.DirectShow.FilterInfoCollection videosources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); if (videosources != null) { //videoSource.GetCameraProperty(AForge.Video.DirectShow.CameraControlProperty.) videoSource = new AForge.Video.DirectShow.VideoCaptureDevice(videosources[0].MonikerString); videoSource.NewFrame += (s, e) => { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); takenPicture.Dispose(); } pictureBox1.Image = (Bitmap)e.Frame.Clone(); takenPicture = (Bitmap)e.Frame.Clone(); }; videoSource.Start(); } }
public Form1(int tempo, int qtd, string path, string nome) { InitializeComponent(); AForge.Video.DirectShow.FilterInfoCollection videosources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice); if (videosources != null) { videoSource = new AForge.Video.DirectShow.VideoCaptureDevice(videosources[0].MonikerString); videoSource.NewFrame += (s, e) => { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } pictureBox1.Image = (Bitmap)e.Frame.Clone(); }; videoSource.Start(); } timer1.Interval = tempo; _qtd = qtd; _path = path; _nomeOriginal = nome; }