how to use the integrated webcam in dot net c#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amol kumar
    New Member
    • Sep 2010
    • 1

    how to use the integrated webcam in dot net c#?

    actually my project is that i wanna make a software that enable to capture a picture automatically by webcam.
    the software should have the capability to start the web cam automatically and capture the object whenever it observe a new object.
  • luis adrian

    #2
    //*******THIS IS JUST FOR MONODEVELOP IN LINUX *****///
    #First we need to install the Emgu.CV dll (that makes almost #all the magic)
    #I made i little example, we need two controls a Gtk.Image #control and a Gdk.PixBuf and also the System.IO; and #System.Drawing ;

    //Ok here is the example in Gtk.Window
    Code:
    using System;
    using Gtk;
    using Emgu.CV;
    using Emgu.CV.UI;
    using Emgu.CV.Structure;
    using System.IO;
    using System.Drawing;
    using System.Drawing.Imaging;
    
    #i declared global variables
     Gdk.Pixbuf pix;
     Emgu.CV.UI.ImageViewer viewer = new ImageViewer(); //create an image viewer	        
     Emgu.CV.Capture capture = new Capture ();
     System.Drawing.Bitmap bitmap = null;
    
    #When we start the form we are gona use a timer for mono
    public MainWindow () : base(Gtk.WindowType.Toplevel)
    {
    GLib.Timeout.Add (180, new GLib.TimeoutHandler (update_status));	
    
    ##This is the event
    private  bool update_status ()
    {
     Image<Bgr, Byte> Photo=capture.QueryFrame(); 	 	
     viewer.Image = Photo;
     bitmap =  viewer.Image.Bitmap;
     MemoryStream memor = new MemoryStream ();
     bitmap.Save(memor,ImageFormat.Png);
     pix = new Gdk.Pixbuf(memor.ToArray());
     this.image2.Pixbuf = pix;
     memor.Dispose();
     return true;
    }

    Comment

    Working...