简体   繁体   English

如何在 EmguCV 中设置相机的属性

[英]How to Set Property of camera in EmguCV

Use _capture.SetCaptureProperty(CapProp.Exposure, x) no error, but can't function to my camera.Any idea for this to set exposure at Emgucv.使用_capture.SetCaptureProperty(CapProp.Exposure, x)没有错误,但不能将 function 用于我的相机。任何想法都可以在 Emgucv 设置曝光。

Camera model: Basler (acA1300-30gm)相机 model:Basler (acA1300-30gm)

No Change after i run the code.运行代码后没有变化。

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

Camera Property相机属性

I've also found with Basler cameras the capture properties can't be set, the way I coded my application instead was using the free Pylon runtime SDK to capture the frames to pass to Emgu CV.我还发现 Basler 相机无法设置捕获属性,我编写应用程序的方式是使用免费的 Pylon 运行时 SDK 来捕获要传递给 Emgu CV 的帧。 The following snippets from that project should get you started:该项目的以下片段应该可以帮助您入门:

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}");
    }
}

I've been using this code to process real-time video at 40fps from one of their Gigabit cameras and the performance seems good.我一直在使用这段代码来处理来自他们的一台千兆摄像机的 40fps 实时视频,性能似乎不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM