使用Aforge.net或c#获取或设置相机属性(如曝光时间)

时间:2022-05-11 16:00:26

I'm currently looking for some libraries .dll that allow me to interfere with the web camera to set or get the camera parameters, although the Microsoft Lifecam (the webcam) already provided an API preinstalled, I want to write the code the set these properties in my own windows form program. Appreciate any idea!

我目前正在寻找一些库。dll允许我干扰网络摄像头来设置或获取相机参数,尽管微软的生命周期(webcam)已经提供了一个API预安装,我想在我自己的windows窗体程序中编写这些属性的代码。欣赏任何想法!

Using Aforge.net or C# to get or set camera properties ( e.g. exposure time)

使用Aforge.net或c#获取或设置相机属性(如曝光时间)

1 个解决方案

#1


4  

Yea, by using the library (dll) of AForge, you can do that.
Here I put a snippet of the code for setting the exposure value.

是的,通过使用AForge的库(dll),你可以做到。这里,我将代码片段设置为设置曝光值。

You might get an example project here: CameraPrefs - example

您可能会在这里得到一个示例项目:CameraPrefs—示例。

public VideoCaptureDevice source;
private IAMCameraControl cameraControls;

...

// Match specified camera name to device
FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
for (int i = 0, n = videoDevices.Count; i < n; i++)
{
    if (name == videoDevices[i].Name)
    {
        moniker = videoDevices[i].MonikerString;
        break;
    }
}

source = new VideoCaptureDevice(moniker);
cameraControls = (IAMCameraControl)source.SourceObject;

cameraControls.Set(CameraControlProperty.Exposure, -11, CameraControlFlags.Manual);

I hope this might help others as well; in case if you already figure out the way to do this. =)

我希望这对其他人也有帮助;如果你已经知道怎么做了。=)

#1


4  

Yea, by using the library (dll) of AForge, you can do that.
Here I put a snippet of the code for setting the exposure value.

是的,通过使用AForge的库(dll),你可以做到。这里,我将代码片段设置为设置曝光值。

You might get an example project here: CameraPrefs - example

您可能会在这里得到一个示例项目:CameraPrefs—示例。

public VideoCaptureDevice source;
private IAMCameraControl cameraControls;

...

// Match specified camera name to device
FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
for (int i = 0, n = videoDevices.Count; i < n; i++)
{
    if (name == videoDevices[i].Name)
    {
        moniker = videoDevices[i].MonikerString;
        break;
    }
}

source = new VideoCaptureDevice(moniker);
cameraControls = (IAMCameraControl)source.SourceObject;

cameraControls.Set(CameraControlProperty.Exposure, -11, CameraControlFlags.Manual);

I hope this might help others as well; in case if you already figure out the way to do this. =)

我希望这对其他人也有帮助;如果你已经知道怎么做了。=)