Access USB cameras with AForge

I have a project where I need to work with a USB camera to process images obtained in a very close range (up to 5 mm). Since the available space is very short, I cannot use the auxiliary lens.

I know that I can do some post-processing at the bitmap level, but I would like to access properties such as autofocus or white balance at the camera level.

I am developing in C # with AForge for image acquisition and post-processing, but I cannot find a way to control the camera before image capture occurs.

Can you help me?

+7
source share
3 answers

After more thorough research, I found it myself.

If someone else is looking 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 seems possible to manage these formless elements using IAMVideoProcAmp

+7
source

You can directly access the camera settings without calling the DisplayPropertyPage () method

 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); 
+6
source

To access other camera features, such as brightness, contrast, 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); 
+1
source

All Articles