简体   繁体   English

使用eBUS SDK和EmguCV在C#中从PvBuffer创建Mat

[英]Create a Mat from a PvBuffer in C# using eBUS SDK and EmguCV

I'm using EmguCV 3.4.1 and the eBUS SDK. 我正在使用EmguCV 3.4.1和eBUS SDK。 I have video coming in over GigE and I would like to convert the PvBuffer to a MAT so I can use OpenCV to create a display a histogram. 我有视频通过GigE传入,我想将PvBuffer转换为MAT,以便可以使用OpenCV创建直方图显示。

I followed a similar style to how you create a Mat in C++. 我遵循了与在C ++中创建Mat相似的样式。 Unfortunately this solution requires marking the project as unsafe. 不幸的是,此解决方案要求将项目标记为不安全。

    unsafe private Mat convertPvBufferToMat(PvBuffer aBuffer)
    {
        PvImage lImage = aBuffer.Image;
        lImage.Alloc(lImage.Width, lImage.Height, PvPixelType.Mono16);
        int[] sizes = new int[2] { (int)lImage.Height, (int)lImage.Width };
        Mat aMat = new Mat(sizes, DepthType.Cv16U, (IntPtr)lImage.DataPointer);

        return aMat;
    }

I'm taking images from an infared camera outputing 16 bit grayscale images. 我正在从红外摄像机拍摄输出16位灰度图像的图像。

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

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