【问题标题】:How to Set Property of camera in EmguCV如何在 EmguCV 中设置相机的属性
【发布时间】:2019-11-07 08:05:55
【问题描述】:

使用_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

【问题讨论】:

  • 究竟是什么“不起作用”?
  • 程序可以运行但相机参数不变

标签: c# emgucv


【解决方案1】:

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

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 实时视频,性能似乎不错。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    • 2017-04-24
    • 2011-03-04
    相关资源
    最近更新 更多