当前位置: 首页>>代码示例>>C#>>正文


C# DirectShow.VideoCaptureDevice类代码示例

本文整理汇总了C#中AForge.Video.DirectShow.VideoCaptureDevice的典型用法代码示例。如果您正苦于以下问题:C# VideoCaptureDevice类的具体用法?C# VideoCaptureDevice怎么用?C# VideoCaptureDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VideoCaptureDevice类属于AForge.Video.DirectShow命名空间,在下文中一共展示了VideoCaptureDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connect

        public bool Connect()
        {
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices.Count == 0)
            {
                return false;
            }
            // create video source
            currentDevice = new VideoCaptureDevice(videoDevices[0].MonikerString);
            videoSourcePlayer1.VideoSource = currentDevice;
            var videoCapabilities = currentDevice.VideoCapabilities;
            //foreach (var video in videoCapabilities)
            //{
            //    LogHelper.Info("预览分辨率->" + video.FrameSize.Width + "*" + video.FrameSize.Height);
            //}
            if (videoCapabilities.Count() > 0)
                currentDevice.VideoResolution = currentDevice.VideoCapabilities.Last();

            var snapVabalities = currentDevice.SnapshotCapabilities;
            //foreach (var snap in snapVabalities)
            //{
            //    LogHelper.Info("抓拍分辨率->" + snap.FrameSize.Width + "*" + snap.FrameSize.Height);
            //}
            if (snapVabalities.Count() > 0)
                currentDevice.SnapshotResolution = currentDevice.SnapshotCapabilities.Last();

            currentDevice.Start();

            return true;
        }
开发者ID:ysjr-2002,项目名称:QuickDoor,代码行数:31,代码来源:ucUsbCamera.cs

示例2: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            cam = new VideoCaptureDevice(webcams[comboBox1.SelectedIndex].MonikerString);
            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);

            cam.Start();
        }
开发者ID:Rohail1,项目名称:OOP-Project,代码行数:7,代码来源:Form1.cs

示例3: minero_class

        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;
        }
开发者ID:kill4n,项目名称:Kuro_ACM,代码行数:33,代码来源:minero_class.cs

示例4: StartVideo

        public void StartVideo()
        {
            if (filterInfoCollection != null)
            {
                videoCaptureDevice = new VideoCaptureDevice(filterInfoCollection[1].MonikerString);
                try
                {
                    if (videoCaptureDevice.VideoCapabilities.Length > 0)
                    {
                        string highestSolution = "0;0";

                        for (int i = 0; i < videoCaptureDevice.VideoCapabilities.Length; i++)
                        {
                            highestSolution = videoCaptureDevice.VideoCapabilities[i].FrameSize.Width.ToString() +';'
                            +i.ToString();
                        }

                        videoCaptureDevice.VideoResolution =
                            videoCaptureDevice.VideoCapabilities[Convert.ToInt32(highestSolution.Split(';')[1])];

                    }

                }
                catch (Exception e)
                {

                }

                videoCaptureDevice.NewFrame += newFrameEventHandler;

                videoCaptureDevice.Start();
            }
        }
开发者ID:3dprintscanner,项目名称:PedestrianDetectorDemo,代码行数:33,代码来源:WebcamManager.cs

示例5: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     timer1.Enabled = true;
     Video = new VideoCaptureDevice(Dispositivos[comboBox1.SelectedIndex].MonikerString);
     videoSourcePlayer1.VideoSource = Video;
     videoSourcePlayer1.Start();
 }
开发者ID:Ewertton,项目名称:Read-Write-Qr,代码行数:7,代码来源:FrmReadQr.cs

示例6: GetCamSettingsCombobox

        //GetCamSettings
        public static void GetCamSettingsCombobox(ComboBox c)
        {
            WebCamSettings = c;

            try
            {
                videoSource = new VideoCaptureDevice(VideoDevices[WebCamList.SelectedIndex].MonikerString);
                WebCamSettings.Items.Clear();
                //DeviceExist = true;
                foreach (var capability in videoSource.VideoCapabilities)
                {
                    WebCamSettings.Items.Add(capability.FrameSize.Width.ToString() + " x " + capability.FrameSize.Height.ToString() + "  " + capability.AverageFrameRate.ToString() + " fps");
                }

                if (Properties.Settings.Default.WebCamResolution == null || Properties.Settings.Default.WebCamDevice != Convert.ToString(WebCamList.SelectedItem))
                {
                    WebCamSettings.SelectedIndex = 0;
                }
                else
                {
                    WebCamSettings.SelectedIndex = WebCamSettings.FindString(Properties.Settings.Default.WebCamResolution);
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                //DeviceExist = false;
                WebCamSettings.Items.Add("No capture device on your system");
            }
        }
开发者ID:Enursha,项目名称:WebCamPassport,代码行数:30,代码来源:WebCam.cs

示例7: GetAvailableDevices

        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;
        }
开发者ID:brucedog,项目名称:homesecurityviewer,代码行数:35,代码来源:CameraService.cs

示例8: Form1

        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);
        }
开发者ID:kill4n,项目名称:Kuro_ACM,代码行数:25,代码来源:Form1.cs

示例9: Form1_Load

        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);
            }
        }
开发者ID:lev2048,项目名称:C_Sharp,代码行数:30,代码来源:Form1.cs

示例10: Start

        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();
            }
        }
开发者ID:solsetmary,项目名称:Makhzan,代码行数:35,代码来源:WebcamDBService.cs

示例11: Form1

        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();
        }
开发者ID:Reddine,项目名称:Webcam-Capture-AForge.Net,代码行数:32,代码来源:Form1.cs

示例12: Webcam

        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);
        }
开发者ID:jlucas9,项目名称:WVU-Lunabotics,代码行数:25,代码来源:Webcam.cs

示例13: VideoCaptureDevice

 private void btnComeçar_Click(object sender, RoutedEventArgs e)
 {
     //Iniciar a camera e mostrar no picture Box[form control] por meio do evento
     cam = new VideoCaptureDevice(webcam[cmbDevices.SelectedIndex].MonikerString);
     cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
     cam.Start();
 }
开发者ID:GeoOjacob,项目名称:sppdi,代码行数:7,代码来源:WebcamWindow.xaml.cs

示例14: Cameraint

 public static void Cameraint(int i)
 {
     videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString);
      videoSource.DesiredFrameSize = new Size(2048, 1536);
      videoSource.DesiredFrameRate = 1;
      videoSource.Start();
 }
开发者ID:jacean,项目名称:RingsII,代码行数:7,代码来源:Clscamera.cs

示例15: Init

        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;
        }
开发者ID:HansMaiser,项目名称:Vocaluxe,代码行数:29,代码来源:CAForgeNet.cs


注:本文中的AForge.Video.DirectShow.VideoCaptureDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。