Collection of filters' information objects.

The class allows to enumerate DirectShow filters of specified category. For a list of categories see FilterCategory.

Sample usage:

// enumerate video devices videoDevices = new FilterInfoCollection( FilterCategory.VideoInputDevice ); // list devices foreach ( FilterInfo device in videoDevices ) { // ... }
Inheritance: System.Collections.CollectionBase
Esempio n. 1
1
        public minero_class(int puerto = 2134, GLOBAL_MODE modo = GLOBAL_MODE.MINI_MINERO)
        {
            _modoOperacion = modo;
            bmp1 = new Bitmap(640, 480, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            bw = new BackgroundWorker();
            _puerto = puerto;
            ipEnd = new IPEndPoint(IPAddress.Any, _puerto);
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);

            if (_modoOperacion == GLOBAL_MODE.MINI_MINERO)
            {
                modeloRobot.setDeviceIndex(3);
            }
            else
            {
                modeloRobot.setDeviceIndex(4);
            }
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                // create video source
                videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
                // set NewFrame event handler
                videoSource.NewFrame += videoSource_NewFrame;
            }
            catch (Exception ex)
            {

            }
            //jo¿ystick
            joy.JoystickEvent += joy_JoystickEvent;
        }
Esempio n. 2
0
        public void GetFrame()
        {
            // enumerate video devices
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            //foreach (FilterInfo item in videoDevices)
            //{

            //videoSource = new VideoCaptureDevice(item.MonikerString);
            videoSource = new VideoCaptureDevice(videoDevices[1].MonikerString);
            //videoSource.DesiredFrameSize = new Size(160, 120);

            // create video source
            //VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);

            // set NewFrame event handler
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            // start the video source
            videoSource.Start();
            // ...
            System.Threading.Thread.Sleep(500);
            Trace.WriteLine("FramesReceived: " + videoSource.FramesReceived);
            // signal to stop
            videoSource.SignalToStop();
            // ...
            //}
        }
Esempio n. 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                ///---实例化对象  
                USE_Webcams = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                ///---摄像头数量大于0  
                if (USE_Webcams.Count > 0)
                {
                    ///---禁用按钮  
                    btn_Start.Enabled = true;
                    ///---实例化对象  
                    cam = new VideoCaptureDevice(USE_Webcams[0].MonikerString);
                    ///---绑定事件  
                    cam.NewFrame += new NewFrameEventHandler(Cam_NewFrame);
                }
                else
                {
                    ///--没有摄像头  
                    btn_Start.Enabled = false;
                    ///---提示没有摄像头  
                    MessageBox.Show("没有摄像头外设");
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            capturedevice = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (pictureBox2.Image != null)
                {
                    pictureBox1.Image = (Image)pictureBox2.Image.Clone();
                }
                else
                {
                    MessageBox.Show("check the camera");
                }

                ////////////////////

                IBarcodeReader reader = new BarcodeReader();
                // load a bitmap
                var barcodeBitmap = (Bitmap)pictureBox1.Image;
                // detect and decode the barcode inside the bitmap
                var result = reader.Decode(barcodeBitmap);
                // do something with the result
                if (result != null)
                {
                    txtDecoderType.Text = result.BarcodeFormat.ToString();
                    txtDecoderContent.Text = result.Text;
                Console.Beep();
                }
        }
Esempio n. 5
0
        public void Start()
        {
            FilterInfoCollection videoDevices;
            string camDescr;
            try
            {
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                if (videoDevices.Count == 0)
                {
                    throw new ApplicationException("no webcams");
                }
                else
                {
                    camName = videoDevices[Convert.ToInt32(devIndex)].MonikerString;
                    camDescr = videoDevices[Convert.ToInt32(devIndex)].Name;
                }
            }
            catch (ApplicationException)
            {
                throw new ApplicationException("failed web cams initialize");
            }

            videoSource = new VideoCaptureDevice(camName);
            videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            videoSource.DesiredFrameSize = new Size(Convert.ToInt32(devWidth), Convert.ToInt32(devHeigth));//new Size(320, 240);//new Size(480, 360);//new Size(640, 480);//
            videoSource.DesiredFrameRate = 29;
            videoSource.Start();

            if (timerUploadImage == null)
            {
                timerUploadImage = new System.Timers.Timer(700);
                timerUploadImage.Elapsed += new ElapsedEventHandler(timerUploadImage_Tick);
                timerUploadImage.Start();
            }
        }
Esempio n. 6
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     videoSourcePlayer.SignalToStop();
     videoSourcePlayer.WaitForStop();
     videoDevices = null;
     videoDevices = null;
 }
Esempio n. 7
0
        public Form1()
        {
            InitializeComponent();

            // show device list
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    devicesCombo.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                devicesCombo.Items.Add("No local capture devices");
                devicesCombo.Enabled = false;
                takePictureBtn.Enabled = false;
            }

            devicesCombo.SelectedIndex = 0;

            VideoCaptureDevice videoCaptureSource = new VideoCaptureDevice(videoDevices[devicesCombo.SelectedIndex].MonikerString);
            videoSourcePlayer.VideoSource = videoCaptureSource;
            videoSourcePlayer.Start();
        }
Esempio n. 8
0
        /// <summary>
        /// 获取摄像头列表
        /// </summary>
        /// <returns></returns>
        public List<string>GetCameraList()
        {
            List<string> lstReturn = new List<string>();

            try
            {
                VideoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (VideoDevices.Count == 0)
                {
                    throw new ApplicationException();
                }

                foreach (FilterInfo device in VideoDevices)
                {
                    lstReturn.Add(device.Name);
                }

            }
            catch (ApplicationException)
            {
                lstReturn.Add("未发现本地视频设备");
                VideoDevices = null;
            }
             return lstReturn;
        }
Esempio n. 9
0
        public Webcam(string ocu_ipAddress, CameraConfiguration config)
        {
            this.config = config;
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            if (videoDevices.Count < 1)
                throw new Exception("No video input devices available");
            if (!string.IsNullOrEmpty(config.DeviceName))
                videoSource = new VideoCaptureDevice(config.DeviceName);
                //videoSource = new VideoCaptureDevice(videoDevices[1].MonikerString);
            else
            {
                videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
            }

            updateWorker = new Timer();
            updateWorker.Elapsed += new ElapsedEventHandler(updateWorker_Elapsed);
            FrameRate = config.RCU_To_OCU_Framerate;
            JPEGQuality = config.JPEGQuality;
            isActive = false;
            jpegCodec = GetEncoderInfo("image/jpeg");
            videoSource.DesiredFrameSize = new Size(320, 240);
            videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
            udp_sender = new Comms.UDP_Sender(ocu_ipAddress, config.SendPort);
            raw_frame_queue = new Utility.UpdateQueue<byte[]>(-1);
        }
        public void execute()
        {
            LocationSourceManager.Instance.Shutdown();
            this.videoPlayer.SignalToStop();
            this.videoPlayer.WaitForStop();

            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[this.videoSourceCombo.SelectedIndex].MonikerString);

            int i = this.videoFormatCombo.SelectedIndex;
            videoSource.DesiredFrameSize = videoSource.VideoCapabilities[i].FrameSize;

            Size videoPlayerSize = videoSource.VideoCapabilities[i].FrameSize;
            videoPlayer.Size = videoPlayerSize;
            Size videoPlayerParentSize = videoPlayer.Parent.Size;
            videoPlayer.Location = new Point((videoPlayerParentSize.Width / 2) - (videoPlayerSize.Width / 2), (videoPlayerParentSize.Height / 2) - (videoPlayerSize.Height / 2));

            new UpdateMapSizeAndPosition(this.videoPlayer, MapOverlayForm.Instance).execute();

            Size mainFormMinSize = videoPlayerSize;
            mainFormMinSize.Width += 230;
            mainFormMinSize.Height += 50;
            if (mainFormMinSize.Height < 475)
                mainFormMinSize.Height = 475;
            this.mainForm.MinimumSize = mainFormMinSize;

            this.videoPlayer.VideoSource = videoSource;
            this.videoPlayer.Start();
        }
Esempio n. 11
0
        public VideoSource()
        {
            InitializeComponent();
            RenderResources();
            // show device list
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    devicesCombo.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                devicesCombo.Items.Add(LocRM.GetString("NoDevicesFound"));
                devicesCombo.Enabled = false;
                //okButton.Enabled = false;
            }
            ConfigureSnapshots = false;
        }
Esempio n. 12
0
		public InputForm()
		{
			InitializeComponent();
			// Disable panels at the beginning.
			pnlCamera.Enabled = false;
			pnlMjpeg.Enabled = false;
			pnlJpg.Enabled = false;
			try
			{
				filters = new FilterInfoCollection(FilterCategory.VideoInputDevice);

				if (filters.Count == 0)
					throw new ApplicationException();

				// add all devices to combo
				foreach (FilterInfo filter in filters)
				{
					deviceCombo.Items.Add(filter.Name);
				}
			}
			catch (ApplicationException)
			{
				deviceCombo.Items.Add("No local capture devices");
				deviceCombo.Enabled = false;
				rdoCaptureDevice.Enabled = false;
			}

			deviceCombo.SelectedIndex = 0;
		}
Esempio n. 13
0
        /// Initializes a new instance of the CamControl
        public CamControl()
        {
            Devices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            // by default select the first one
            SetCamera(0);
        }
Esempio n. 14
0
 public void CargarDispositive(FilterInfoCollection Dispositive)
 {
     for (int i = 0; i < Dispositive.Count; i++) {
         cboDispositive.Items.Add(Dispositive[i].Name.ToString());
         cboDispositive.Text = cboDispositive.Items[0].ToString();
     }
 }
Esempio n. 15
0
        // actions 

        private void setupVideoDevices()
        {
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                {
                    throw new Exception();
                }

                for (int i = 1, n = videoDevices.Count; i <= n; i++)
                {
                    string cameraName = i + " : " + videoDevices[i - 1].Name;
                    cbDevice.Items.Add(cameraName);
                }
                
                cbDevice.SelectedIndex = 0;
            }
            catch
            {
                cbDevice.Items.Add( "No cameras found" );
                cbDevice.SelectedIndex = 0;
                cbDevice.Enabled = false;
            }
        }
Esempio n. 16
0
        public Form1()
        {
            InitializeComponent();

            dm.setDeviceIndex(3);
            comboBox2.DataSource = Enum.GetValues(typeof(MODELO_TYPE));

            // 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);

            /*ax12_Rot = new AX_12_Motor();
            ax12_Dir = new AX_12_Motor();

            ax12_Dir.setDeviceID(3);
            ax12_Rot.setDeviceID(3);
            ax12_Dir.setBaudSpeed(BAUD_RATE.BAUD_1Mbps);
            ax12_Rot.setBaudSpeed(BAUD_RATE.BAUD_1Mbps);*/
            //button3_Click(null, null);
        }
Esempio n. 17
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;
        }
Esempio n. 18
0
        private CameraTriggerService()
        {
            SelectedDeviceIndex = -1;
            CaptureDevices = new List<string>();
            RegionOfInterestPoints = new List<System.Drawing.Point>();
            diffHistory = new CircularList<int>(MOVING_AVERAGE_FRAMES);
            FilterInfoCollection fc = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            for (int i = 0; i < fc.Count; i++)
            {
                CaptureDevices.Add(fc[i].Name);
            }
            // NOTE: We always use the first found capture device
            // In cases where we have an internal device (integrated webcam)
            // and an external device (which is the prefered device) we maybe
            // have to implement some logic that the prefered device is taken by default!
            SetCameraDevice(0);

            // NOTE: The default value of 10s should be a good enough default value
            TriggerBlockTimeMs = 10 * 1000;

            // NOTE: We specify a default ROI which is a rectangle in the middle of the
            // captured frame
            RegionOfInterestPoints.Add(new System.Drawing.Point(CAPTURE_FRAME_WIDTH / 2 - 20, 0));
            RegionOfInterestPoints.Add(new System.Drawing.Point(CAPTURE_FRAME_WIDTH / 2 + 20, 0));
            RegionOfInterestPoints.Add(new System.Drawing.Point(CAPTURE_FRAME_WIDTH / 2 + 20, CAPTURE_FRAME_HEIGHT));
            RegionOfInterestPoints.Add(new System.Drawing.Point(CAPTURE_FRAME_WIDTH / 2 - 20, CAPTURE_FRAME_HEIGHT));
        }
Esempio n. 19
0
        public VideoSourceForm()
        {
            InitializeComponent();
            RenderResources();

            // show device list
            try
            {
                // enumerate video devices
                _videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (_videoDevices.Count == 0)
                    throw new ApplicationException();

                // add all devices to combo
                foreach (FilterInfo device in _videoDevices)
                {
                    devicesCombo.Items.Add(device.Name);
                }
            }
            catch (Exception ex)
            {
                Log.Error("",ex);//MainForm.LogExceptionToFile(ex);
                devicesCombo.Items.Add(LocRm.GetString("NoCaptureDevices"));
                devicesCombo.Enabled = false;
                //okButton.Enabled = false;
            }
        }
Esempio n. 20
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (button2.Text == "Tomar 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, a) => pictureBox2.Image = (Bitmap)a.Frame.Clone();
             videosource.Start();
             button2.Text = "Capturar";
         }
     }
     else
     {
         pictureBox1.Image = pictureBox2.Image;
         if (videosource != null && videosource.IsRunning)
         {
             videosource.SignalToStop();
             videosource = null;
         }
         pictureBox2.Image = null;
         button2.Text      = "Tomar Foto";
     }
 }
Esempio n. 21
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="CaptureDeviceDialog"/> class.
        /// </summary>
        /// 
        public CaptureDeviceDialog()
        {
            InitializeComponent();


            try // show device list
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    noDevices();

                // add all devices to combo
                foreach (FilterInfo device in videoDevices)
                {
                    devicesCombo.Items.Add(device.Name);
                }
            }
            catch (ApplicationException)
            {
                noDevices();
            }

            devicesCombo.SelectedIndex = 0;
        }
Esempio n. 22
0
        /// <summary>
        /// Se cargan los dispositivos que hay en el pc  que sean camaras y se asignan al combox
        /// </summary>
        /// <param name="Dispositivos"></param>
        public void CargarDispositivos(FilterInfoCollection Dispositivos)
        {
            for (int i = 0; i < Dispositivos.Count; i++) ;

            cbxDispositivos.Items.Add(Dispositivos[0].Name.ToString());
            cbxDispositivos.Text = cbxDispositivos.Items[0].ToString();
        }
Esempio n. 23
0
        public void start()
        {
            Detector = Detector == null ? new Detector() : Detector;

            Detector.Detection += DetectorOnDetection;
            Dick = new Dick(Detector);
            if (!Detector.Detectors.Any())
            {
                for (int i = 0; i < 4; i++)
                {
                    Detector.Detectors.Add(new ColorDetector());
                }
            }
            Detector.Detectors.ForEach(x=> x.Detector = Detector);

            var cd = Detector.Detectors[0];
            Dick.DickParts.Add(new DickPart(PartName.Tip, cd));
            cd = Detector.Detectors[1];
            Dick.DickParts.Add(new DickPart(PartName.Medium, cd));
            cd = Detector.Detectors[2];
            Dick.DickParts.Add(new DickPart(PartName.Deep, cd));
            cd = Detector.Detectors[3];
            Dick.DickParts.Add(new DickPart(PartName.RealyDeep, cd));

            cmbDickPart.DataSource = Dick.DickParts;
            cmbDickPart.DisplayMember = "strName";

            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            Detector.Video = new VideoCaptureDevice(videoDevices[0].MonikerString);
            Detector.Start();
        }
Esempio n. 24
0
        public MainWindow()
        {
            InitializeComponent();

            ////////////////////Video Config - Start//////////////////////
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            string toPrint = "";
            foreach (FilterInfo vidDevice in videoDevices)
            {
                toPrint += vidDevice.MonikerString + "  \n  ";
            }
            MessageBox.Show("Found:\n\n" + toPrint);
            if (videoDevices.Count < 2)
            {
                MessageBox.Show("Not enough webcams detected, closing");
                Environment.Exit(0);
            }
            VideoCaptureDevice leftSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
            VideoCaptureDevice rightSource = new VideoCaptureDevice(videoDevices[1].MonikerString);

            leftSource.Start();
            rightSource.Start();

            leftPlayer.VideoSource = leftSource;
            rightPlayer.VideoSource = rightSource;

            leftHost.Child = leftPlayer;
            rightHost.Child = rightPlayer;

            leftPlayer.Start();
            rightPlayer.Start();
        }
Esempio n. 25
0
        private void Apagar()
        {
            try
            {
                btnSalvarFoto.Enabled = true;
                btnCapturar.Enabled   = false;

                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) => picWebCam.Image = (Bitmap)e.Frame.Clone();

                    videoSource.SetCameraProperty(
                        CameraControlProperty.Focus,
                        500,
                        CameraControlFlags.Manual);
                    videoSource.Start();
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 26
0
        //GetCamList
        public static void GetCamListCombobox(ComboBox c)
            
        {
            WebCamList = c;

            try
            {
                VideoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                WebCamList.Items.Clear();

                foreach (FilterInfo device in VideoDevices)
                {
                    WebCamList.Items.Add(device.Name);
                }

                if (Properties.Settings.Default.WebCamDevice == null)
                {
                    WebCamList.SelectedIndex = 0; //First cam found is default
                }
                else
                {
                    WebCamList.SelectedIndex = WebCamList.FindString(Properties.Settings.Default.WebCamDevice);
                }
            }
            catch (ApplicationException)
            {
                //DeviceExist = false;
                WebCamList.Items.Add("No capture device on your system");
            }
        }
Esempio n. 27
0
        public bool Init()
        {
            _WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            int num = 0;
            foreach (FilterInfo info in _WebcamDevices)
            {
                SWebcamDevice device = new SWebcamDevice {
                    ID = num,
                    Name = info.Name,
                    MonikerString = info.MonikerString,
                    Capabilities = new List<SCapabilities>()
                };
                num++;
                VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString);

                for (int i = 0; i < tmpdev.VideoCapabilities.Length; i++ )
                {
                    SCapabilities item = new SCapabilities
                    {
                        Framerate = tmpdev.VideoCapabilities[i].FrameRate,
                        Height = tmpdev.VideoCapabilities[i].FrameSize.Height,
                        Width = tmpdev.VideoCapabilities[i].FrameSize.Width
                    };
                    device.Capabilities.Add(item);
                }
                _Devices.Add(device);
            }
            return true;
        }
Esempio n. 28
0
        private void Form1_Load(object sender, EventArgs e)
        {
            devices = Camera.videodevices;
            if (devices == null)
            {
                MessageBox.Show("未找到摄像图设备!");
                return;
            }
            foreach (AForge.Video.DirectShow.FilterInfo fi in devices)
            {
                this.comboBox1.Items.Add(fi.Name);
            }
            comboBox1.SelectedIndex = 0;

            pixtureBox = new PictureBox();
            // pixtureBox.Size = new Size(372, 346);
            pixtureBox.Size     = new Size(640, 480);
            pixtureBox.Location = new Point(259, 19);

            this.Controls.Add(pixtureBox);

            string[] speed = new string[] { "1", "10", "20", "50", "100", "500" };
            this.comboBox2.Items.AddRange(speed);

            button3.Enabled = false;
            button2.Enabled = false;
            button4.Enabled = false;
        }
        public bool IsWebCamAvailible()
        {
            var device       = Configuration.GetDevice(DeviceType.WebCam);
            var videoDevices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice);

            //если запускаем в первый раз, то можно заодно сохранить первую попавшуюся камеру, если такая есть..
            if (device.Name == "")
            {
                if (videoDevices.Count != 0)
                {
                    Configuration.SaveDevice(new HWDeviceDesciption
                    {
                        Device   = DeviceType.WebCam,
                        Name     = videoDevices[0].Name,
                        DeviceId = videoDevices[0].MonikerString
                    });
                }
                return(true);
            }
            for (int i = 0; i < videoDevices.Count; i++)
            {
                if (device.Name == videoDevices[i].Name)
                {
                    if (device.DeviceId == videoDevices[i].MonikerString)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 30
0
        public SelectDevice()
        {
            InitializeComponent();
            this.cameraDeviceNum = 0;
            #region
            this.videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            
            if (this.videoDevices.Count != 0)
            {
                //リストクリア
                this.listDevices.Items.Clear();
                //デバイス追加
                foreach (FilterInfo device in videoDevices)
                {
                    this.listDevices.Items.Add(device.Name);
                    this.cameraDeviceNum++;
                }
                this.listDevices.Items.Add("kinect");
                this.listDevices.SelectedIndex = 0;
            }
            else
            {
                this.listDevices.Items.Clear();
                this.listDevices.Items.Add("Kinect");
                this.listDevices.SelectedIndex = 0;
            }
            #endregion
            this.Show();

        }
        public CameraDevice GetFirstCameraDevice()
        {
            CameraDevice cameraDevice = null;
            // enumerate video devices
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            if ((videoDevices != null) && (videoDevices.Count > 0))
            {
                // create video source
                VideoCaptureDevice videoDevice = new VideoCaptureDevice(videoDevices[0].MonikerString);
                List<CameraDevice> devicesData = _config.GetConfiguredCameraDevicesData().Where(a => a.ID == videoDevice.Source).ToList();
                if ((devicesData != null) && (devicesData.Count > 0))
                {
                    cameraDevice = devicesData[0];
                }
                else
                {
                    cameraDevice = new LocalCameraDevice();
                    cameraDevice.ID = videoDevice.Source;
                    cameraDevice.Name = "Camera";
                    _config.AddCameraDevice(cameraDevice);
                    _config.Save();
                }
                (cameraDevice as LocalCameraDevice).Init(videoDevice);

            }

            return cameraDevice;
        }
Esempio n. 32
0
        // Constructor
        public VideoCaptureDeviceForm( )
        {
            InitializeComponent( );

            // show device list
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection( FilterCategory.VideoInputDevice );

                if ( videoDevices.Count == 0 )
                    throw new ApplicationException( );

                // add all devices to combo
                foreach ( FilterInfo device in videoDevices )
                {
                    devicesCombo.Items.Add( device.Name );
                }
            }
            catch ( ApplicationException )
            {
                devicesCombo.Items.Add( "No local capture devices" );
                devicesCombo.Enabled = false;
                okButton.Enabled = false;
            }

            devicesCombo.SelectedIndex = 0;
        }
Esempio n. 33
0
        public IList<CameraDevice> GetAvailableDevices()
        {
            List<CameraDevice> cameraDevices = new List<CameraDevice>();
            try
            {
                FilterInfoCollection filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (filterInfoCollection.Count == 0)
                    return cameraDevices;

                foreach (FilterInfo device in filterInfoCollection)
                {
                    VideoCaptureDevice videoCaptureDevice = new VideoCaptureDevice(device.MonikerString);

                    // only add device if it has video capabilities
                    if (videoCaptureDevice.VideoCapabilities.Length > 0)
                    {
                        cameraDevices.Add(
                            new CameraDevice
                            {
                                Name = device.Name,
                                MonikerString = device.MonikerString
                            });
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);

                return cameraDevices;
            }

            return cameraDevices;
        }
Esempio n. 34
0
        public Aforge()
        {
            InitializeComponent();
            AForge.Video.DirectShow.FilterInfoCollection videoDevices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice);



            captureDevice = new VideoCaptureDeviceForm();

            FinalVideo           = new VideoCaptureDevice(videoDevices[0].MonikerString);
            FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
            FinalVideo.Start();


            string baseAddress = "http://localhost:9000/";

            // Start OWIN host
            WebApp.Start <Startup>(url: baseAddress);
            Console.WriteLine("Streaming start...");
            Console.ReadLine();



            // Start OWIN host
            // WebApp.Start<owin_Classes.Startup1>(url: baseAddress);
            // WebApp.Start<owin_Classes.Startup1>("http://*:8511");
            //Console.WriteLine("Streaming start...");
            //Console.ReadLine();


            // Start OWIN host
            //WebApp.Start<Startup>(url: baseAddress);
            //Console.WriteLine("Streaming start...");
            //Console.ReadLine();



            //MyUser myUser = new MyUser();
            //myUser.Id = 1;
            //myUser.Name = "AutomatedUITestUser";

            //var fakeHttpSessionState =
            //                     new FakeHttpSessionState(new SessionStateItemCollection());
            //fakeHttpSessionState.Add("__CurrentUser__", myUser);

            //mockControllerContext = Mock.Of<ControllerContext>(ctx =>
            //ctx.HttpContext.User.Identity.Name == myUser.Name &&
            //ctx.HttpContext.User.Identity.IsAuthenticated == true &&
            //ctx.HttpContext.Session == fakeHttpSessionState &&
            //ctx.HttpContext.Request.AcceptTypes ==
            //               new string[] { "MyFormsAuthentication" } &&
            //ctx.HttpContext.Request.IsAuthenticated == true &&
            //ctx.HttpContext.Request.Url == new Uri("http://127.0.0.1") &&
            //ctx.HttpContext.Response.ContentType == "video"
            //);
        }
Esempio n. 35
0
        public MainForm()
        {
            InitializeComponent();
            timerLapso.Stop();
            timerCaptura.Stop();
            buttonEmpezar.Focus();

            //TestSet testSet = TestSetDao.GetTestSet(defaultTestSet);

            VideoSources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice);
            if (VideoSources != null)
            {
                foreach (Screen screens1 in Screen.AllScreens)
                {
                    comboBoxPantallas.Items.Add(screens1.DeviceName);
                }

                screens2 = Screen.AllScreens;

                comboBoxPantallas.SelectedIndex = 0;

                foreach (FilterInfo VideoSource in VideoSources)
                {
                    comboBoxWebCam.Items.Add(VideoSource.Name);
                }

                VideoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(VideoSources[0].MonikerString);
                VideoSource.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
                VideoSource.Start();

                if (comboBoxWebCam.Items.Count > 0)
                {
                    comboBoxWebCam.SelectedIndex = 0;
                }
            }

            buttonTerminar.Enabled = false;

            try {
                Conexion.Open();

                SqlCommand    cmd = new SqlCommand("select max(SECCION) AS SECCION from [NEUROSKY_IMAGENES]", Conexion);
                SqlDataReader dr  = cmd.ExecuteReader();

                if (dr.Read())
                {
                    int.TryParse(Convert.ToString(dr["SECCION"]), out this.Seccion);
                    Seccion++;
                }
                Conexion.Close();
            } catch (Exception e) {
                Console.WriteLine("Fallo la conexion a la base");
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 36
0
        private void videoSourcePlayer2_Click(object sender, EventArgs e)
        {
            AForge.Video.DirectShow.FilterInfoCollection videoDevices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice);

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

            // foreach (AForge.Video.DirectShow.FilterInfo device in videoDevices)
            //  {
            VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);

            // videoSource.DesiredFrameSize = new Size(320, 240);
            // videoSource.DesiredFrameRate = 15;
            videoSourcePlayer2.VideoSource = videoSource;
            videoSourcePlayer2.Start();
            //   }
        }
Esempio n. 37
0
        public frmMain()
        {
            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 (picBoxVideo.Image != null)
            //        {
            //            picBoxVideo.Image.Dispose();
            //        }

            //        picBoxVideo.Image = (Bitmap)e.Frame.Clone();
            //    };
            //    videoSource.Start();
            //}
        }
Esempio n. 38
-1
        static void Main()
        {
            _path =  Path.GetTempPath();
            Console.WriteLine("Motion Detector");
            Console.WriteLine("Detects motion in the integrated laptop webcam");
            Console.WriteLine("Threshold level: " + _motionAlarmLevel);
            _motionDetector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());
            if (new FilterInfoCollection(FilterCategory.VideoInputDevice).Count > 0)
            {
                _path += "motions";

                if (!Directory.Exists(_path))
                {
                    Directory.CreateDirectory(_path);
                }
                else
                {
                    var dir = new DirectoryInfo(_path);
                    foreach (var fi in dir.GetFiles())
                    {
                        fi.Delete();
                    }
                }

                var videoDevice = new FilterInfoCollection(FilterCategory.VideoInputDevice)[0];
                var videoCaptureDevice = new VideoCaptureDevice(videoDevice.MonikerString);
                var videoSourcePlayer = new AForge.Controls.VideoSourcePlayer();
                videoSourcePlayer.NewFrame += VideoSourcePlayer_NewFrame;
                videoSourcePlayer.VideoSource = new AsyncVideoSource(videoCaptureDevice);
                videoSourcePlayer.Start();
            }
        }