Код: Выделить всё
unsigned char * rectifyImage(unsigned char *pimg, int rows, int cols)
Код: Выделить всё
[DllImport("mex_rectify_image.dll")]
unsafe public static extern IntPtr rectifyImage(
byte[] data, int rows, int columns);
Код: Выделить всё
byte[] imageData = new byte[img.Height * img.Width * 3];
// ... populate imageData
IntPtr rectifiedImagePtr = rectifyImage(imageData, img.Height, img.Width);
Byte[] rectifiedImage = new Byte[img.Width * img.Height * 3];
Marshal.Copy(rectifiedImagePtr, rectifiedImage, 0, 3 * img.Width * img.Height);
Исключение первого шанса типа System.AccessViolationException произошел в xxx.dll
Попытка чтения или записи в защищенную память. Это часто указывает на то, что другая память повреждена.
Мне просто интересно, кроется ли ошибка в том, как я маршалирую свои данные, или в моем импортированном файле DLL. ... у кого-нибудь есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/342 ... array-in-c