Wednesday, February 5, 2014

Make a simple Webcam in C #

This is a post I am related to C # (C sharp). In this post, I will explain the steps of making a webcam from C # application. Tutorial-making a simple webcam application is part of the C # application deployment-related images and processing. A Webcam can be used as input in addition to the new image using the Load image plain. Now it's time to direct the implementation of the program.
Starting from the simplest, though probably many of you already know very well about the programming language one, namely how to make a simple webcam of any type by using C #. In each implementation I use Microsoft Visual Studio 2012.
Please read:
1. the first step, open the C # program and create a new file by choosing File > > New Project (Ctrl + Shift + N) > > select Windows Application, and name the file according to your wishes (WebcamSederhana) and press OK. Next would come an empty form.

2. a Component used for this simple program is:
• SaveFileDialog
• ComboBox
• PictureBox
• Button
Click and put option component of the program which will be used as the image below:

3. Then double click on the "Start Camera" button and add the following code:


            cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
            cam.Start();

The purpose of the Start Camera button to select the file image is what you'd like displayed in the picture box. The desired file types can be specified via the syntax Filter (in the above example file.Filter), whereas if you want to directly refer to a particular directory can be used syntax InitialDirectory (in the above example file.InitialDirectory)

4. as for taking a picture file, double click on the button "Take a Photo" and add the following code:


             saveFileDialog1.InitialDirectory = @"D:\";
             if (saveFileDialog1.ShowDialog() == DialogResult.OK)
             {
                pictureBox1.Image.Save(saveFileDialog1.FileName);
             }

Add the source code below:


               private FilterInfoCollection webcam;
               private VideoCaptureDevice cam;

5. in the writing of the code is needed. dll from AForge. dll can be downloaded here.
Add the following code:


using AForge.Video;
using AForge.Video.DirectShow;


6. the application is complete, after adding the source code above, lives in the run course. And the results were as follows:



For more details on this please download program understanding program files and full-length project
download program files binary here
download full project here
download the exe only here
download the document here
download picture here
for more information contact on ardhamail@gmail.com

Guide to download: click on the download link above, after that it would appear adf.ly page, wait a few seconds until appears on the top right corner of the ad skip writing. Click the button, the page will appear after that ziddu, please click on the download button that appears on the page ziddu
NB: in this tutorial ditulisa program using the Visual studio IDE. with the target framework > 4.0. So at a minimum your computer must be installed or windows vista or windows xp with the .NET framework 4.0 to be able to run programs *. exe, while for open the project inevitably must install microsoft visual studio 2012

2 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in C SHARP, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on C SHARP. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Nitesh Kumar
    MaxMunus
    E-mail: nitesh@maxmunus.com
    Skype id: nitesh_maxmunus
    Ph:(+91) 8553912023
    http://www.maxmunus.com/




    ReplyDelete
  2. Great simple app. Need to close cam before closing the main form.

    ReplyDelete