C++ 做了视频识别的DLL动态库,导出函数
extern "C" __declspec(dllexport)float Recognition(Mat frame,int type);
C#主程序调用C++的视频识别动态库
[DllImport(@"Recognition.dll", EntryPoint = "Recognition", CallingConvention = CallingConvention.Cdecl)]
public extern static float Recognition(Mat frame, int iType);
C#调用内容如下:
Bitmap bmp = cameraControl1.TakeSnapshot();
Image<Bgr, byte> image = new Image<Bgr, byte>(bmp);
//Image<Bgr, byte>转Mat
Mat mat = image.Mat;
Mat Graymat = mat.Clone();
float Value = Recognition(Graymat, 1);
运行到float Value = Recognition( Graymat, 1);行,查看 Graymat 变量内容正常;
按F11 调试到C++工程;查看传入的Mat 变量 frame 宽度、高度、数据均不正常;不知道原因,改成参数引用传递也不行。调试信息如图
哪位大神急救下!
![图片说明](https://img-ask.csdn.net/upload/201908/20/1566271847_310078.png)![图片说明](https://img-ask.csdn.net/upload/201908/20/1566271855_169575.png)