Exemplo n.º 1
0
public Form1() // init
{
    InitializeComponent();
    {
        VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
        {
            comboBox1.Items.Add(VideoCaptureDevice.Name);
        }
        comboBox1.SelectedIndex = 0;
    }
}
Exemplo n.º 2
0
        private void Scan_Click(object sender, EventArgs e)
        {
            label1.Show();
            pictureBox1.Show();
            txtresult.Show();
            btnfile.Hide();
            btndecode.Hide();
            cbxTenCamera.Show();
            btnketnoi.Show();
            btnclear.Show();
            pictureBox2.Hide();
            pictureBox1.Image = null;

            CaptureDevice = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo Device in CaptureDevice)
            {
                cbxTenCamera.Items.Add(Device.Name);
            }
            cbxTenCamera.SelectedIndex = 0;
        }
Exemplo n.º 3
0
        public void runWebcam()
        {
            FilterInfoCollection videosources = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            //Überprüfen, ob mindestens eine Aufnahmequelle vorhanden ist
            if (videosources != null)
            {
                //Die erste Aufnahmequelle an unser Webcam Objekt binden
                //(habt ihr mehrere Quellen, muss nicht immer die erste Quelle die
                //gewünschte Webcam sein!)
                videoSource = new VideoCaptureDevice(videosources[0].MonikerString);
                if (!videoSource.IsRunning)
                {
                    videoSource.NewFrame += new AForge.Video.NewFrameEventHandler(videoSource_NewFrame);
                    //Das Aufnahmegerät aktivieren

                    videoSource.Start();
                }
            }
        }
Exemplo n.º 4
0
        private void LoadVideo()
        {
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices.Count != 0)
            {
                foreach (FilterInfo device in videoDevices)
                {
                    cbxDevices.Items.Add(device.Name);
                }
                btnStart.Enabled = true;
            }
            else
            {
                btnStart.Enabled = false;
                cbxDevices.Items.Add("Não foi encontrado nenhum dispositivo.");
            }

            cbxDevices.SelectedIndex = 0;
        }
Exemplo n.º 5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         foreach (FilterInfo filterInfo in filterInfoCollection)
         {
             comboBox1.Items.Add(filterInfo.Name);
         }
         comboBox1.SelectedIndex = 0;
         device = new VideoCaptureDevice(filterInfoCollection[comboBox1.SelectedIndex].MonikerString);
         device.Start();
         device.NewFrame += Device_NewFrame;
     }
     catch
     {
         pictureBox2.Image = (Bitmap)Properties.Resources.trololoo;
         Wallpaper.Set((Bitmap)pictureBox2.Image.Clone());
     }
 }
Exemplo n.º 6
0
        private void frmRegistroCandidata_Load(object sender, EventArgs e)
        {
            this.cargarMunicipios();

            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo device in videoDevices)
            {
                cmbCamara.Items.Add(device.Name);
            }
            if (cmbCamara.Items.Count > 0)
            {
                cmbCamara.SelectedIndex = 0;
                videoSource             = new VideoCaptureDevice();
            }
            else
            {
                //lblError.Visible = true;
            }
        }
Exemplo n.º 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            VideoCapTureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo VideoCaptureDevice in VideoCapTureDevices)
            {
                comboBox1.Items.Add(VideoCaptureDevice.Name);
            }

            comboBox1.SelectedIndex = 0;

            comboBox2.DataSource = SerialPort.GetPortNames();


            button2.Enabled = true;


            int portSayisi = 0;

            portSayisi = comboBox2.Items.Count;
        }
Exemplo n.º 8
0
 private void Form1_Load(object sender, EventArgs e)
 {
     FileWriter   = new VideoFileWriter();
     videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo aa in videoDevices)
     {
         comboBox2.Items.Add(aa.Name);
     }
     tableLayoutPanel3.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
     tableLayoutPanel4.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
     waveInDevices = WaveIn.DeviceCount;
     for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
     {
         WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
         comboBox3.Items.Add(deviceInfo.ProductName);
     }
     button1.Enabled = false;
     button3.Enabled = false;
     button4.Enabled = false;
 }
        public async Task CheckAsync(TimeSpan recursiveTimer)
        {
            FilterInfoCollection WebcamColl;

            WebcamColl       = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            Device           = new VideoCaptureDevice(WebcamColl[0].MonikerString);
            Device.NewFrame += Device_NewFrame;
            Device.Start();
            Thread.Sleep(1000);
            Device.SignalToStop();

            ImageTesting imageTesting = new ImageTesting();

            imageTesting.CropFacesAsync(results);


            await Task.FromResult(5);

            CheckAsync(recursiveTimer);
        }
Exemplo n.º 10
0
        public Form1()
        {
            InitializeComponent();

            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices.Count == 0)
            {
                camerasList.Enabled = false;
            }
            else
            {
                foreach (FilterInfo i in videoDevices)
                {
                    camerasList.Items.Add(i.Name);
                }

                camerasList.SelectedIndex = 0;
            }
        }
Exemplo n.º 11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            secondInFramesDefault = 150;


            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            //fill dropbox
            foreach (FilterInfo device in videoDevices)
            {
                DeviceDropBox.Items.Add(device.Name);
            }
            DeviceDropBox.Items.Add("Video File");
            DeviceDropBox.SelectedIndex = 2;
            device      = new VideoCaptureDevice();
            videoSource = new FileVideoSource();
            writer      = new AVIWriter();
            //asyncVS = new AsyncVideoSource();
            secondInFrames = secondInFramesDefault;
        }
Exemplo n.º 12
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        void ConnectLocalCamera()
        {
            if (cbCamera.Items.Count == 0 || cbCamera.SelectedIndex == -1)
            {
                return;
            }
            if (m_videoSource != null)
            {
                m_videoSource.Stop();
            }
            else
            {
                FilterInfoCollection videosources = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                m_videoSource = new VideoCaptureDevice(videosources[cbCamera.SelectedIndex].MonikerString);
            }

            m_videoSource.NewFrame += new NewFrameEventHandler(OnCameraFrame);
            m_videoSource.Start();
            btnSnapshot.Visible = true;
        }
Exemplo n.º 13
0
        // Importante        //
        // Installare AForge //

        public Form1() // init
        {
            InitializeComponent();
            {
                VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
                {
                    comboBox1.Items.Add(VideoCaptureDevice.Name);
                }
                comboBox1.SelectedIndex = 0;

                // resize image
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

                // create motion detector
                detector = new MotionDetector(
                    new SimpleBackgroundModelingDetector(),
                    new MotionAreaHighlighting());
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// 利用第3方组件,获取摄像设备
 /// </summary>
 private void getCamList()
 {
     try
     {
         //AForge.Video.DirectShow.FilterInfoCollection 设备枚举类
         videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         //清空列表框
         if (videoDevices.Count == 0)
         {
             throw new ApplicationException();
         }
         //全局变量,标示设备摄像头设备是否存在
         DeviceExist = true;
     }
     catch (ApplicationException)
     {
         DeviceExist = false;
         MessageBox.Show("未找到可用的相机设备");
     }
 }
Exemplo n.º 15
0
 public static void Instantiate_Camera()
 {
     videoDevicesList = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo videoDevice in videoDevicesList)
     {
         Console.WriteLine(videoDevice.Name);
     }
     if (videoDevicesList.Count > 0)
     {
         Console.WriteLine("mamy kamerek: " + videoDevicesList.Count);
     }
     else
     {
         Console.WriteLine("Nie mamy kamerek :/");
     }
     videoSource           = new VideoCaptureDevice(videoDevicesList[0].MonikerString);
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
     videoSource.Start();
     Console.WriteLine("kamerka wybrana: " + videoDevicesList[0].Name);
 }
Exemplo n.º 16
0
 public frmUser()
 {
     InitializeComponent();
     // get list of video devices
     videoDevicesList = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo videoDevice in videoDevicesList)
     {
         cmbVideoSource.Items.Add(videoDevice.Name);
     }
     if (cmbVideoSource.Items.Count > 0)
     {
         cmbVideoSource.SelectedIndex = 0;
     }
     else
     {
         MessageBox.Show("No video sources found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     // stop the camera on window close
     this.Closing += frmUser_Closing;
 }
Exemplo n.º 17
0
 public void BuscarDispositivos()
 {
     try
     {
         DispositivoDeVideo = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         if (DispositivoDeVideo.Count == 0)
         {
             ExisteDispositivo = false;
         }
         else
         {
             ExisteDispositivo = true;
             CargarDispositivos(DispositivoDeVideo);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("No tienes cámara .... pndjo");
     }
 }
Exemplo n.º 18
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            //获取摄像头列表
            var devs = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            //实例化设备控制类
            Camera = new VideoCaptureDevice(devs[0].MonikerString);

            //配置录像参数(宽,高,帧率,比特率,等)
            Camera.VideoResolution = Camera.VideoCapabilities[0];

            //设置回调,aforge会不断从这个回调推出图像数据
            Camera.NewFrame += Camera_NewFrame;

            //开始
            Camera.Start();

            //打开录像文件(如果没有则创建,如果有也会清空).
            VideoOutPut.Open("E:/VIDEO.MP4", Camera.VideoResolution.FrameSize.Width, Camera.VideoResolution.FrameSize.Height, Camera.VideoResolution.AverageFrameRate, VideoCodec.MPEG4, Camera.VideoResolution.BitCount);
        }
Exemplo n.º 19
0
        private void MainFOrm_Load(object sender, EventArgs e)
        {
            try
            {
                webcams = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                foreach (FilterInfo webcam in webcams)
                {
                    comboBox1.Items.Add(webcam.Name);
                }

                comboBox1.SelectedIndex = 0;
                cam = new VideoCaptureDevice();
            }
            catch
            {
                Error obj = new Error();
                obj.ShowDialog();
            }
        }
        private void SellProduct_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;
            this.Location        = new Point(0, 0);

            label2.Left = (this.Width - label2.Width) / 2;

            productNewBindingSource.DataSource = context.ProductNews
                                                 .Where(p => p.product_status != 0)
                                                 .ToList();

            productSetBindingSource1.DataSource = context.ProductSets
                                                  .Where(p => p.set_isDel == 0 && p.set_status == true)
                                                  .ToList();
            webcams = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo webcam in webcams)
            {
                comboBox1.Items.Add(webcam.Name);
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Initialize webcam
 /// </summary>
 private void webcam()
 {
     try
     {
         // enumerate video devices
         videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         // create video source
         videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
         // set NewFrame event handler
         videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
         // start the video source
         videoSource.Start();
     }
     catch (Exception ex)
     {
         // This try-catch horror continues
         System.Console.WriteLine(ex.Message);
         MessageBox.Show("Webcam error", "PLDControl", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 22
0
        public void SetUpVideoSources()
        {
            videoDeviceList = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo videoDevice in videoDeviceList)
            {
                cmbVideoSource.Items.Add(videoDevice.Name);
            }
            if (cmbVideoSource.Items.Count > 0)
            {
                cmbVideoSource.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show("No video sources found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            videoSource           = new VideoCaptureDevice(videoDeviceList[cmbVideoSource.SelectedIndex].MonikerString);
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
        }
Exemplo n.º 23
0
        public frmUtilCamera()
        {
            InitializeComponent();
            FilterInfoCollection videosources = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videosources != null)
            {
                if (videosources.Count != 0)
                {
                    videoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(videosources[0].MonikerString);
                    videoSource.NewFrame += new NewFrameEventHandler(CapturaFrame);

                    videoSource.Start();
                }
                else
                {
                    throw new Exception("Hardware de Câmera não localizado.");
                }
            }
        }
Exemplo n.º 24
0
 private void Setting_Load(object sender, EventArgs e)
 {
     filters = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo device in filters)
     {
         CameraDropdown.Items.Add(device.Name + "{" + device.MonikerString + "}");
     }
     if (cam != null)
     {
         string target = Prefs.GetPref("camera", "default");
         for (int i = 0; i < CameraDropdown.Items.Count; i++)
         {
             if ((string)CameraDropdown.Items[i] == target)
             {
                 CameraDropdown.SelectedIndex = i;
                 break;
             }
         }
     }
 }
Exemplo n.º 25
0
        public Form2(Form1 form1)
        {
            InitializeComponent();
            IDTextBox.Enabled = false;
            IDGenerate(IDTextBox);

            PurchaseTimePicker.Format     = DateTimePickerFormat.Time;
            PurchaseTimePicker.ShowUpDown = true;
            Controls.Add(PurchaseTimePicker);

            CaptureButton.Enabled = false;

            Devices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            for (int i = 0; i < Devices.Count; i++)
            {
                String cameraName = Devices[i].Name;
                CameraComboBox.Items.Add(cameraName);
            }
        }
Exemplo n.º 26
0
        //String[] lines1;
        //String[] lines2;
        //int count = 0;


        public Capture()
        {
            InitializeComponent();
            //foreach (string s in lines)
            //{
            //    while(s != null && s!= "")
            //    {
            //        lines1[count] = lines[count].Split(' ')[0];
            //        lines2[count] = lines[count].Split(' ')[1];
            //        count++;
            //    }
            //}
            TakePhoto.Enabled = false;
            cameras           = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo info in cameras)
            {
                Devices.Items.Add(info.Name);
            }
            Devices.SelectedIndex = 0;
        }
Exemplo n.º 27
0
        private void webCamera_Load(object sender, EventArgs e)
        {
            // enumerate video devices
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices.Count != 0)
            {
                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    devicesCombo.Items.Add(device.Name);
                }
            }
            else
            {
                devicesCombo.Items.Add("Не найдено ни одной камеры");
            }
            devicesCombo.SelectedIndex = 0;
            EnableConnectionControls(true);
        }
Exemplo n.º 28
0
        //public int selectedDeviceIndex = 0;

        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "打开摄像头")
            {
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                videoSource  = new VideoCaptureDevice(videoDevices[txtCamera.SelectedIndex].MonikerString);//连接摄像头

                //videoSource.VideoResolution = videoSource.VideoCapabilities[txtCamera.SelectedIndex];
                vspMember.VideoSource = videoSource;
                // set NewFrame event handler
                vspMember.Start();
                button1.Text = "关闭摄像头";
            }
            else
            {
                vspMember.SignalToStop();
                vspMember.WaitForStop();
                button1.Text = "打开摄像头";
            }
        }
Exemplo n.º 29
0
        public static void HandleGetWebcams(GetWebcams command, Client client)
        {
            var deviceInfo          = new Dictionary <string, List <Size> >();
            var videoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo videoCaptureDevice in videoCaptureDevices)
            {
                List <Size> supportedResolutions = new List <Size>();
                var         device = new VideoCaptureDevice(videoCaptureDevice.MonikerString);
                foreach (var resolution in device.VideoCapabilities)
                {
                    supportedResolutions.Add(resolution.FrameSize);
                }
                deviceInfo.Add(videoCaptureDevice.Name, supportedResolutions);
            }
            if (deviceInfo.Count > 0)
            {
                new GetWebcamsResponse(deviceInfo).Execute(client);
            }
        }
Exemplo n.º 30
0
        }                                       //Setting a stopwatch in case I  will need to add delay


        private void Form1_Load(object sender, EventArgs e)
        {
            watch  = Stopwatch.StartNew();
            filter = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            serialPort1.Open();                                                 //Opens the port for serial communication
            writeToPort(new Point(280, 184));                                   //Default Position of the turret
            device = new VideoCaptureDevice(filter[0].MonikerString);

            do
            {
                int data_rx = serialPort1.ReadChar();
                Console.WriteLine(data_rx);
                if (data_rx == 1)
                {
                    i = 1;
                }
            } while (i < 1);
            device.NewFrame += Device_NewFrame;
            device.Start();
        }
Exemplo n.º 31
0
        private void ScanVideoDevices()
        {
            AvailableCameraDevices.Clear();

            VideoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (VideoDevices.Count == 0)
            {
                //Console.WriteLine("No camera was found");
            }
            else
            {
                //Console.WriteLine(VideoDevices.Count + " Cameras were found");

                foreach (FilterInfo device in VideoDevices)
                {
                    AvailableCameraDevices.Add(device);
                }
            }
        }
Exemplo n.º 32
0
        private bool UpdateDevice()
        {
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            // update devices
            List<string> deviceName = videoDevices.Cast<FilterInfo>().Select(x => x.Name).ToList();
            EnumManager.UpdateEnum(enumDevice, FInDevice[0].Name, deviceName.Count > 0 ? deviceName.ToArray() : new string[] { "None" });

            List<string> videoFormatName = new List<string>();
            List<string> resolutionName = new List<string>();
            List<string> framerateName = new List<string>();

            bool valid = false;

            FilterInfo filterInfo = videoDevices.Cast<FilterInfo>().ToList().Find(x => x.Name.Equals(FInDevice[0].Name));
            if (filterInfo != null)
            {
                videoSource = new VideoCaptureDevice(filterInfo.MonikerString);

                // update formats
                videoFormatName = videoSource.VideoCapabilities.Select(x=>x.MediaType).Distinct().ToList();
                //videoFormatName.Insert(0, "Default");

                List<VideoCapabilities> videoModeInfo = videoSource.VideoCapabilities.ToList().FindAll(y => y.MediaType.Equals(FInputs[0].IOObject[0].Name)).ToList();
                if (videoModeInfo.Count > 0)
                {
                    // update resolutions
                    List<KeyValuePair<Tuple<int, int>, string>> resolution = videoModeInfo.Select(x => new KeyValuePair<Tuple<int, int>, string>(new Tuple<int, int>(x.FrameSize.Width, x.FrameSize.Height), x.FrameSize.Width + "x" + x.FrameSize.Height)).ToList();
                    resolutionName = resolution.Distinct().OrderBy(x => x.Key).Reverse().ToList().Select(x => x.Value).ToList();
                    //resolutionName.Insert(0, "Default");

                    List<int> framerate = new List<int>();

                    videoModeInfo = videoModeInfo.FindAll(x => (x.FrameSize.Width + "x" + x.FrameSize.Height).Equals(FInputs[1].IOObject[0].Name));
                    if (videoModeInfo.Count > 0)
                    {
                        int res = 0;
                        int.TryParse(FInputs[2].IOObject[0].Name, out res);

                        videoModeInfo.ForEach(delegate(VideoCapabilities vcap)
                        {
                            // forming fps
                            int fps = vcap.MinimumFrameRate;
                            int fpsMax = vcap.MaximumFrameRate;

                            while (fps <= fpsMax) // step by 5 fps
                            {
                                if(!framerate.Contains(fps)) framerate.Add(fps);

                                if (fps == fpsMax) break;

                                if (fps % 5 != 0) fps = 5 * (int)Math.Ceiling(((double)fps) / 5.0); // starting from 5
                                else fps += 5;

                                if (fps > fpsMax) fps = fpsMax;
                            }

                            if (framerate.Contains(res))
                            {
                                videoSource.VideoResolution = vcap;
                                videoSource.Framerate = res;

                                valid  = true;
                            }
                        });

                        framerate.Sort();
                        framerate.Reverse();

                        framerateName = framerate.ConvertAll(x => x.ToString()).ToList();
                        //framerateName.Insert(0, "Default");
                    }
                }
            }

            EnumManager.UpdateEnum(enumVideoFormat, FInputs[0].IOObject[0].Name, videoFormatName.Count > 0 ? videoFormatName.ToArray() : new string[] { "Default" });
            EnumManager.UpdateEnum(enumResolution, FInputs[1].IOObject[0].Name, resolutionName.Count > 0 ? resolutionName.ToArray() : new string[] { "Default" });
            EnumManager.UpdateEnum(enumFramerate, FInputs[2].IOObject[0].Name, framerateName.Count > 0 ? framerateName.ToArray() : new string[] { "Default" });

            return valid;
        }