gpt4 book ai didi

c# - 如何在 EmguCV 中设置相机属性

转载 作者:太空宇宙 更新时间:2023-11-03 14:38:43 25 4
gpt4 key购买 nike

使用 _capture.SetCaptureProperty(CapProp.Exposure, x) 没有错误,但不能对我的相机起作用。任何关于在 Emgucv 设置曝光的想法。

相机型号:Basler (acA1300-30gm)

运行代码后没有变化。

_capture.SetCaptureProperty(CapProp.XiExposure, 30000.0);
_capture.SetCaptureProperty(CapProp.Exposure, 30000.0);
_capture.SetCaptureProperty(CapProp.XiExposureBurstCount, 30000.0);

Camera Property

最佳答案

我还发现 Basler 相机无法设置捕获属性,我编写应用程序的方式是使用免费的 Pylon 运行时 SDK 来捕获要传递给 Emgu CV 的帧。该项目的以下片段应该可以帮助您入门:

using Basler.Pylon; // You'll need to add a reference to Basler.Pylon.DLL as well

var cam = new Camera();
cam.Open();
Console.WriteLine("Using camera {0}.", cam.CameraInfo[CameraInfoKey.SerialNumber]);
cam.Parameters[PLCamera.ExposureTimeAbs].SetValue(1000, FloatValueCorrection.ClipToRange);
cam.StreamGrabber.ImageGrabbed += OnImageGrabbed1;
cam.StreamGrabber.Start(GrabStrategy.OneByOne, GrabLoop.ProvidedByStreamGrabber);

private void OnImageGrabbed1(object sender, ImageGrabbedEventArgs e)
{
IGrabResult grabResult = e.GrabResult;
if (grabResult.GrabSucceeded)
{
using (Bitmap bm = new Bitmap(grabResult.Width, grabResult.Height, PixelFormat.Format32bppRgb))
{
BitmapData bmpData = bm.LockBits(new Rectangle(0, 0, bm.Width, bm.Height), ImageLockMode.ReadWrite, bm.PixelFormat);
converter.OutputPixelFormat = PixelType.BGRA8packed;
IntPtr ptrBmp = bmpData.Scan0;
converter.Convert(ptrBmp, bmpData.Stride * bm.Height, grabResult);
bm.UnlockBits(bmpData);
using (Image<Bgr, byte> imageCV = new Image<Bgr, byte>(bm))
{
// Example Emgu CV function
double mean = CvInvoke.Mean(imageCV.Mat).V0;
}
}
}
else
{
LogMessage($"Camera 1 error: {grabResult.ErrorCode} {grabResult.ErrorDescription}");
}
}

我一直在使用此代码以 40fps 的速度从他们的一台千兆摄像机处理实时视频,性能似乎不错。

关于c# - 如何在 EmguCV 中设置相机属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58744355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com