Emgu OpenCV Intptr to IplImage?
I'm using the Emgu OpenCV C# wrapper, and 开发者_C百科I'm trying to convert the IntPtr(s) that its functions return and access the actual IplImage OpenCV objects. Any ideas? I'm new to C#, so any suggestion is welcome.
Cheers.
Well, got the solution, and posting it here -
IntPtr rgb32;
...
MIplImage rgb32Image = new MIplImage();
rgb32Image = (MIplImage)Marshal.PtrToStructure(rgb32, typeof(MIplImage));
Where, of course, rgb32Image is what's needed.
In the year 2020 version 4.2 you can use:
Emgu.CV.Image<TColor, TDepth>.FromIplImagePtr(System.IntPtr)
Note: Also recognize that from v4.2 on to convert a bitmap into a Image<,>, you now have to use the Bitmap extension method ToImage<,>() found in the Emgu.CV.runtime.windows Nuget package (see http://www.emgu.com/wiki/index.php/Version_History#Emgu.CV-4.2.0). That gave me some headache in the beginning.
精彩评论