[ACCEPTED]-Accessing USB camera controls with AForge-aforge

Accepted answer
Score: 11

After some more thorough research I've found 4 the answer by myself.

If anyone else is searching 3 for this you can try the following;

VideoCaptureDevice Cam1;
FilterInfoCollection VideoCaptureDevices;

VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
Cam1 = new VideoCaptureDevice(VideoCaptureDevices[0].MonikerString);
Cam1.DisplayPropertyPage(IntPtr.Zero); //This will display a form with camera controls

It also 2 seems possible to control these items without 1 the form by using IAMVideoProcAmp

Score: 7

You can access camera setting directly without 1 call the method DisplayPropertyPage()

FilterInfoCollection videoDevices = 
    new FilterInfoCollection(FilterCategory.VideoInputDevice);

VideoCaptureDevice videoDevice = 
    new VideoCaptureDevice(videoDevices[camDevice].MonikerString);

videoDevice.SetCameraProperty(
    CameraControlProperty.Zoom,
    zoomValue,
    CameraControlFlags.Manual);

videoDevice.SetCameraProperty(
    CameraControlProperty.Focus,
    focusValue,
    CameraControlFlags.Manual);

videoDevice.SetCameraProperty(
    CameraControlProperty.Exposure,
    exposureValue,
    CameraControlFlags.Manual);
Score: 1

To access other camera properties like brightness, contrast 1 see IAMVideoProcAmp implementation

videoDevice.SetVideoProperty(
    VideoProcAmpProperty.Brightness,
    brightnessValue,
    VideoProcAmpFlags.Manual);

videoDevice.SetVideoProperty(
    VideoProcAmpProperty.Contrast,
    contrastValue,
    VideoProcAmpFlags.Manual);

videoDevice.SetVideoProperty(
    VideoProcAmpProperty.Saturation,
    saturationValue,
    VideoProcAmpFlags.Manual);

videoDevice.SetVideoProperty(
    VideoProcAmpProperty.Sharpness,
    sharpnessValue,
    VideoProcAmpFlags.Manual);

videoDevice.SetVideoProperty(
    VideoProcAmpProperty.WhiteBalance,
    whiteBalanceValue,
    VideoProcAmpFlags.Manual);

videoDevice.SetVideoProperty(
    VideoProcAmpProperty.BacklightCompensation,
    backlightCompensationValue,
    VideoProcAmpFlags.Manual);

More Related questions