• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DirectShow.VideoCaptureDevice类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetFirstCameraDevice

        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;
        }
开发者ID:ShlomyShivek,项目名称:HomeSecure,代码行数:28,代码来源:CameraDeviceFactory.cs


示例17: GetFrame

        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();
            // ...
            //}
        }
开发者ID:JollySwagman,项目名称:Super8,代码行数:27,代码来源:Form1.cs


示例18: videoSourcePlayer_Click

        private void videoSourcePlayer_Click(object sender, EventArgs e)
        {
            if (videoSourcePlayer.IsRunning)
            {
                videoSourcePlayer.SignalToStop();
                viewModel.IsWebcamEnabled = false;
                return;
            }

            using (CaptureDeviceDialog form = new CaptureDeviceDialog())
            {
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    // create video source
                    VideoCaptureDevice videoSource = new VideoCaptureDevice(form.VideoDevice);

                    // set busy cursor
                    this.Cursor = Cursors.WaitCursor;

                    stop();

                    // start new video source
                    videoSourcePlayer.VideoSource = new AsyncVideoSource(videoSource);
                    videoSourcePlayer.Start();

                    Cursor = Cursors.Default;
                    label1.Visible = false;
                    viewModel.IsWebcamEnabled = true;
                }
            }
        }
开发者ID:damy90,项目名称:Telerik-all,代码行数:31,代码来源:CameraForm.cs


示例19: execute

        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();
        }
开发者ID:kr1schan,项目名称:PresenceSimulator,代码行数:29,代码来源:ChangeVideoFormatCommand.cs


示例20: btnIniciar_Click

 private void btnIniciar_Click(object sender, EventArgs e)
 {
     if (btnIniciar.Text == "Start")
     {
         if (ExistenDispositive)
         {
             FuenteVideo = new VideoCaptureDevice(DispositiveVideo[cboDispositive.SelectedIndex].MonikerString);
             FuenteVideo.NewFrame += new NewFrameEventHandler(video_NuevoFrame);
             FuenteVideo.Start();
             Estado.Text = "Connection Complete";
             btnIniciar.Text = "Stop";
             cboDispositive.Enabled = false;
             groupBox1.Text = DispositiveVideo[cboDispositive.SelectedIndex].Name.ToString();
         }
         else
             Estado.Text = "Error: No matching device.";
     }
     else {
         if (FuenteVideo.IsRunning) {
             btnIniciar.Text = "Start";
             TerminarFuenteDeVideo();
             Estado.Text = "Dispositiveo detenio";
             cboDispositive.Enabled = true;
         }
     }
 }
开发者ID:zStyle,项目名称:GoRecorder,代码行数:26,代码来源:Form1.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Editor.RoomEditorState类代码示例发布时间:2022-05-24
下一篇:
C# DirectShow.FilterInfoCollection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap