使用 AForge 访问 USB 摄像头控件

发布于 2025-01-06 12:34:27 字数 210 浏览 1 评论 0原文

我有一个项目,需要使用 USB 摄像头来处理在非常近的范围内(5 毫米以下)获取的图像。由于可用空间很小,我无法使用辅助镜头。

我知道我可以在位图级别进行一些后期处理,但我想获得对相机级别的自动对焦或白平衡等属性的访问权限。

我正在使用 AForge 使用 C# 进行图像采集和后处理的开发,但我似乎无法找到在图像采集发生之前控制相机的方法。

你能帮助我吗?

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.

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.

Can you help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小伙你站住 2025-01-13 12:34:27

经过一些更彻底的研究,我找到了答案我自己。

如果其他人正在搜索此内容,您可以尝试以下操作;

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

使用 IAMVideoProcAmp 似乎也可以在没有表单的情况下控制这些项目

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

堇色安年 2025-01-13 12:34:27

您可以直接访问相机设置,无需调用方法 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);

You can access camera setting directly without 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);
时光是把杀猪刀 2025-01-13 12:34:27

要访问其他相机属性,例如亮度、对比度,请参阅
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);

To access other camera properties like 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文