Beispiel #1
1
        // Open local video capture device
        private void localVideoCaptureDeviceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new VideoCaptureDeviceForm();

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                // open it
                OpenVideoSource(form.VideoDevice);
            }
        }
Beispiel #2
1
        public AForgeCamera(string preferedCameraName = null, int preferedWidth = 640, int preferedHeight = 480, DownSample downSampleVideo = DownSample.None)
        {
            this.downSampleVideo = downSampleVideo;

            if (preferedCameraName != null)
            {
                FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                foreach (FilterInfo info in videoDevices)
                {
                    if (info.Name.Contains(preferedCameraName))
                    {
                        videoCaptureDevice = new VideoCaptureDevice(info.MonikerString);
                        videoCaptureDevice.DesiredFrameSize = new Size(preferedWidth, preferedHeight);
                        break;
                    }
                }
            }

            if (videoCaptureDevice == null)
            {
                VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
                if (form.ShowDialog(null) == DialogResult.OK)
                {
                    // create video source
                    videoCaptureDevice = form.VideoDevice;
                }
            }

            if (videoCaptureDevice != null)
            {
                //videoCaptureDevice.DesiredFrameRate = 5;
                //videoCaptureDevice.ProvideSnapshots = true;
                //videoCaptureDevice.DesiredSnapshotSize = new Size(preferedWidth, preferedHeight);
                //videoCaptureDevice.SnapshotFrame += new NewFrameEventHandler(videoCaptureDevice_SnapshotFrame);

                asyncCopiedVideoImage = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width, videoCaptureDevice.DesiredFrameSize.Height, 32, new BlenderBGRA());
                if (downSampleVideo == DownSample.HalfSize)
                {
                    imageForExternalUse = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width / 2, videoCaptureDevice.DesiredFrameSize.Height / 2, 32, new BlenderBGRA());
                }
                else
                {
                    imageForExternalUse = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width, videoCaptureDevice.DesiredFrameSize.Height, 32, new BlenderBGRA());
                }
                videoCaptureDevice.Start();
                videoCaptureDevice.NewFrame += new NewFrameEventHandler(source_NewFrame);
            }
        }
Beispiel #3
0
        public List<FilterInfo> getCamList()
        {
            List<FilterInfo> cameras = new List<FilterInfo>();
            try
            {
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                videoDeviceList = new VideoCaptureDeviceForm();

                if (videoDevices.Count == 0)
                {
                    throw new ApplicationException();
                }
                deviceExist = true;

                foreach (FilterInfo device in videoDevices)
                {
                    cameras.Add(device);
                }
            }
            catch (ApplicationException)
            {
                deviceExist = false;
                cameras = null;
            }
            return cameras;
        }
Beispiel #4
0
        public void Start()
        {
            AForge.Video.DirectShow.VideoCaptureDeviceForm f = new AForge.Video.DirectShow.VideoCaptureDeviceForm();
            f.ShowDialog();

            capturingDevice = f.VideoDevice;

            f.VideoDevice.NewFrame += VideoDevice_NewFrame;
            f.VideoDevice.Start();

            FPSLoop          = new DispatcherTimer();
            FPSLoop.Interval = TimeSpan.FromSeconds(1);
            FPSLoop.Tick    += FPSLoop_Tick;
            FPSLoop.Start();
        }
Beispiel #5
0
        private void PlayRecord(object sender, EventArgs e)
        {
            VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();

            // create new instance of video data analyser
            _videDataAnalyser = new DataAnalyser(_selectedRecord, _selectedRecord.Id);

            // create video source
            FileVideoSource fileSource = new FileVideoSource(_selectedRecord.AbsolutePath);

            // open
            OpenVideoSource(fileSource);
        }
Beispiel #6
0
        private void OpenRecord_Click(object sender, EventArgs e)
        {
            VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                // create video source
                FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);
                _recordToSave = new Records { AbsolutePath = openFileDialog.FileName };
                // open it
                OpenVideoSource(fileSource);
            }

            if (RecordsGridView.Rows.Count > 0)
            {
                RecordsGridView.CurrentRow.Selected = false;
            }
        }
Beispiel #7
0
 private void button_ChangeVideoSource_Click(object sender, RoutedEventArgs e)
 {
     VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
     if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         videoSource = form.VideoDevice;
         glyphRecogniser.InjectVideoSource(videoSource);
     }
     else
     {
         Console.WriteLine("Couldn't open video source");
     }
 }