Monday, April 23, 2012

Webcam frame from Aforge always gray image

I am using Aforge .NET framework to get a webcam in my app but I always get an all gray image frame.

            this.videoSource = new VideoCaptureDevice(this.Moniker);
this.videoSource.DesiredFrameSize = GetHighestResolution(this.videoSource.VideoCapabilities);
this.videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);

The vent handler:

    private void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
this.outputBox.Image = (Bitmap)eventArgs.Frame.Clone();

This should do the trick. DesiredFrameSize is set to the highest value the cam can support.

Any hints why the image is always gray? Even when writing it do disk...

No comments:

Post a Comment