Det
Det

Reputation: 39

Cannot display webcam Using Aforge.NET in C#

I am currently working on a project where I need to simply display the users webcam on a asp.image object. I am using the Aforge frame work and have gotten it to work on a windows app. In the windows app I would set up the video source variable equal to the image property of a picture box
In other words:

samplepicturebox1.image = videosource

The problem is, for asp there is only a asp:image object and the only property is .imageurl

imgSource.imageurl = ???

How would I go forth and link a video stream object to the image url or what other object would I use to display the stream? I have looked into putting an output on a seperate aspx.cs file so I could just use that as a imageurl but had no luck.
Here is my code to specify:

//using AForge.Video;
//using AForge.Video.DirectShow;
//using System.Drawing.Imaging;


public partial class WebForm1 : System.Web.UI.Page
{
    private FilterInfoCollection VideoCaptureDevices;
    private VideoCaptureDevice FinalVideo;
    protected void Page_Load(object sender, EventArgs e)
    {
        drpSource.Items.Clear();
        VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
        foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices) 
        {
            drpSource.Items.Add(VideoCaptureDevice.Name);
        }
        drpSource.SelectedIndex = 0;
    }

    protected void btnStart_Click(object sender, EventArgs e)
    {
        FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[drpSource.SelectedIndex].MonikerString);
        FinalVideo.NewFrame +=new NewFrameEventHandler(FinalVideo_NewFrame);
        FinalVideo.Start();
    }
    void FinalVideo_NewFrame(object sender, NewFrameEventArgs deventArgs)
    {
        imgSource.ImageUrl=(FinalVideo.ToString());
    }
}

I have also populated a combo box with the user's different video source. That also displays correctly

I really appreciate any help. This will translate into communications. I want to be able to stream between users just like Omegle and Chatroulette. If anyone would recommend a better framework to look into I'm open, I've only looked into Aforge and Touchless as two C# frameworks that support video streaming.

I've seen many use flash and I do know a bit of ActionScript, but to be completely honest, I'd rather not mess too much with flash as ActionScript is quite the pain and from my opinion in some aspects, flash slowly withering and dieing.

Upvotes: 0

Views: 3031

Answers (1)

jgauffin
jgauffin

Reputation: 101150

@KeithNicholas is correct. A web application is not the same as a client/winforms application. A web app is run in the webserver and not in the web browser.

It got no access to the user's webcam. You need to use a client side technology like flash or silverlight to be able to use the webcamera from the server.

Upvotes: 1

Related Questions