2
votes

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);
            this.videoSource.Start();

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...

Edit: To add: The same problem occurs with the sample application SimplePlayer from Aforge samples. My webcam is a Logitech QuickCam Pro 9000.

Edit2: The same goes for small DesiredFramesizes.

1
Out of interest have you tried a smaller VideoSource.DesiredFrameSize ?TomP89
Yes, updated question. Did not try everyone but 160x120 e.g.ZoolWay
hmm very strange. Do you have another webcam to test with the same code? Also I presume this camera works in full colour with one of the logitech applications? I would also suggest (if you haven't already) leaving a post on the aforge forums as I have found them pretty helpfulTomP89
The cam works fine with Logitech Apps, Skype and others. I guess there must be some config missing for that type. Also I was not able to post at the aforge forums because they miss the "register" button as far as I see :DZoolWay
Yes just checked and they seem to have messed that up lol. Does sound like the camera isn't fully supported by aforge. Not sure if its any help but Emgu CV (.NET wrapper for OpenCV) also have webcam support friism.com/webcam-face-detection-in-c-using-emgu-cvTomP89

1 Answers

0
votes

maybe the camera isnt wrapped around directshow (some sort of directx stuff). some camera's come with their own driver, or different inner working. I have some highspeed industrial camera's, with simmilar issues. I had to retrieve the raw images from them using diffrent methods, then do aforge stuff on those images.

Maybe check your code using older cheap USB2 camera's