I have a project where i need to work with a USB camera to process images aquired at a very close range (under 5mm). Because the space available is very short, I can't use auxiliary lens.
我有一个项目,我需要使用USB摄像头来处理非常近距离(小于5毫米)的图像。因为可用的空间很短,我不能使用辅助镜头。
I know I can do some post processing at bitmap level, but I would like to gain access to properties like auto-focus or white balancing at camera level.
我知道我可以在位图级别上进行一些后期处理,但是我希望能够访问自动对焦或相机级别的白平衡等属性。
I'm developing in C# with AForge for image aquisition and post processing, but I can't seem to find a way to control the camera before the image aquisition takes place.
我正在c#与AForge一起开发图像采集和后期处理,但是在图像采集之前我似乎找不到一个方法来控制摄像机。
Can you help me?
你能帮我吗?
3 个解决方案
#1
7
After some more thorough research I've found the answer by myself.
经过更深入的研究,我自己找到了答案。
If anyone else is searching 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 control these items without the form by using IAMVideoProcAmp
使用IAMVideoProcAmp似乎也可以在不使用表单的情况下控制这些物品
#2
6
You can access camera setting directly without call the method DisplayPropertyPage()
您可以直接访问相机设置,而无需调用方法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);
#3
1
To access other camera properties like brightness, contrast see IAMVideoProcAmp implementation
要访问其他相机属性,如亮度,请参阅IAMVideoProcAmp实现
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
7
After some more thorough research I've found the answer by myself.
经过更深入的研究,我自己找到了答案。
If anyone else is searching 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 control these items without the form by using IAMVideoProcAmp
使用IAMVideoProcAmp似乎也可以在不使用表单的情况下控制这些物品
#2
6
You can access camera setting directly without call the method DisplayPropertyPage()
您可以直接访问相机设置,而无需调用方法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);
#3
1
To access other camera properties like brightness, contrast see IAMVideoProcAmp implementation
要访问其他相机属性,如亮度,请参阅IAMVideoProcAmp实现
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);