Quantcast
Viewing all articles
Browse latest Browse all 41027

C# SEH Exception cvGetSize

We are encountering SEH exceptions when calling cvGetSize for a CvMat. Here is small example: using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { internal struct _CvMat { public int type; public int step; public IntPtr refcount; public int hdr_refcount; public IntPtr data; public int rows; public int cols; } public struct Size { public int Width; public int Height; } unsafe class Program { [DllImport("opencv_world300", CallingConvention = CallingConvention.Cdecl)] internal static extern Size cvGetSize(_CvMat* arr); [DllImport("opencv_world300", CallingConvention = CallingConvention.Cdecl)] internal static extern _CvMat* cvCreateMat(int rows, int cols, int type); [DllImport("opencv_world300", CallingConvention = CallingConvention.Cdecl)] internal static extern void cvReleaseMat(ref _CvMat* mat); static void Main(string[] args) { var ptr = cvCreateMat(30, 30, 0); Size size = cvGetSize(ptr); // Causes SEH exception cvReleaseMat(ref ptr); } } } This problem seems to be existing in 2.4.x as well, as Emgu.CV (popular C# Wrapper) is not using a cvGetSize, instead directly using the CvMat rows and cols members with a comment that the call is not working. When doing the same in pure C the function calls are working as expected. In C# only this specific function is causing a problem. The calling convention is correct, the types seem to be correctly defined. When looking at the members of the CvMat when calling cvGetSize, type and step are set to 0 before the error occurs. Can anyone reproduce this? Anybody knows where this comes from?

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>