简体   繁体   中英

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

I'm using EmguCV 3.4.1 and the 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.

I followed a similar style to how you create a Mat in C++. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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