Click here to Skip to main content
13,199,852 members (66,830 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi,please help me ,i have used directx,but i cannot know how to preview webcam in my form.
Posted 8-Jan-13 18:28pm
Updated 8-Jan-13 19:22pm
__TR__29K
v3
Comments
Christian Graus 9-Jan-13 0:31am
   
Try posting code to help us understand what you want
Christian Graus 9-Jan-13 0:31am
   
If you just mean your local web cam, there's tons of articles on this site. If you mean one over the web, there's probably still articles you can use
   
System.Windows.Forms? Tag it!
—SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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();
 
        }
    }
 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 29 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100