预览网络摄像头视频 [英] Preview web cam video

查看:148
本文介绍了预览网络摄像头视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我使用过directx,但我不知道如何以我的形式预览网络摄像头。

Hi,please help me ,i have used directx,but i cannot know how to preview webcam in my form.

推荐答案

有很多准备好的 - 作为CodeProject文章发布的使用解决方案: http://www.codeproject.com/search.aspx ?doctypeid = 1& q =(Web + camera+ OR ++ Webcam)+C%23 [ ^ ]。



-SA
There is good number of ready-to-use solution published as CodeProject articles: http://www.codeproject.com/search.aspx?doctypeid=1&q=("Web+camera"+OR++Webcam)+"C%23"[^].

—SA


public DirectX.Capture.Filter Camera;

       public DirectX.Capture.Capture CaptureInfo;

       public DirectX.Capture.Filters CamContainer;

       Image captureImage;







{
            CamContainer = new DirectX.Capture.Filters();


       try

       {

            int no_of_cam = CamContainer.VideoInputDevices.Count;



            for (int i = 0; i <no_of_cam; i++)

            {

                try

                {

                        // get the video input device

                        Camera = CamContainer.VideoInputDevices[i];



                        // initialize the Capture using the video input device

                        CaptureInfo = new DirectX.Capture.Capture(Camera, null);





                        // set the input video preview window

                        CaptureInfo.PreviewWindow = this.pictureBox1;



                        // Capturing complete event handler

                        CaptureInfo.FrameCaptureComplete += RefreshImage;



                        // Capture the frame from input device

                        CaptureInfo.CaptureFrame();



                        // if device found and initialize properly then exit without

                        // checking rest of input device

                        break;

                  }
                    catch (Exception ex) { }

            }

        }

        catch (Exception ex)

        {

                MessageBox.Show(this, "No Video Device Found", "Error");

         }

        }
        public void RefreshImage(PictureBox frame)
        {

            captureImage = frame.Image;


            this.pictureBox2.Image = captureImage;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            CaptureInfo.CaptureFrame();

        }
    }


这篇关于预览网络摄像头视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆