Click here to Skip to main content
15,881,898 members
Articles / Programming Languages / C#

WebCam Fast Image Capture Service using WIA

Rate me:
Please Sign up or sign in to vote.
4.57/5 (57 votes)
17 Aug 2006CPOL4 min read 728.5K   83.9K   222  
Grab frames from any webcam, transfer frames using WebServices, super easy and super fast
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "www.codeproject.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebCamService : System.Web.Services.WebService
{

    private WebCamLibrary.WebCam cam;

    public WebCamService()
    {
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 

        //Please Choose one of these two ways to grab frames. You cannot use both at the same time.
        //use WebCamLibrary.WebCam.NewWebCamDirectX(); if your camera doesnt work with WIA.
        cam = WebCamLibrary.WebCam.NewWebCamWIA();
        // cam = WebCamLibrary.WebCam.NewWebCamDirectX();
        cam.Initialize();                          
    }

    [WebMethod]
    public byte[] GrabFrame() {
        return cam.GrabFrame(); 
    }
    [WebMethod]
    public string[] GetConnectedCameras()
    {
        return cam.GetDevices();
    }
  

    
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Engineer TECO GROUP - Jundi Electrical Industry
United States United States
if you have any questions please send an email :

ojundi @ [%s].info

Oz [Jundi]

Comments and Discussions