0

我正在将一些 OpenCV 代码从 C++ 转换为由 EmguCV 包装的 C#。一直困扰着我的一件事是,在 Opencv 中,很多东西都是指针IplImage*CvCapture*等等,当我将它们翻译成 C# 时,它们都变得IntPtrsIntPtr Capture=CvInvoke.CvCreateCameraCapture(0)在这个特定的问题中,我在访问表格中的矩阵数据时遇到问题的IntPtr

原始代码如下所示:

CvMat* ObjectPoints = CvCreateMat(/*some parameters*/);//initialize the matrix header
float* TempPoints = new float[/*size of the array of the TempPoints*/];
//assign some values to TempPoints
*ObjectPoints = cvMat(rows, cols, type, TempPoints)//assign the changed TempPoints as the data of the ObjectPoint matrix. other irrelevant parameters are omitted.

当我用 C# 重写上面的部分时,它看起来像

IntPtr ObjectPoints = CvInvoke.CvCreateMat(/*some parameters*/);
float* TempPoints = new float[/*size of the array of the tempPoints*/];
//assign some value to TempPoints
//Then what? ObjectPoints is a pointer and EmguCV does not have a CvMat() method. So how can I achieve the effect as in the original code?

如果我可以在这个问题之外扩展一点,在其他情况下,比如我有IntPtr Frame = CvInoke.CvQueryImage(Capture);另一个函数需要一个Image<RGB, Byte>,我怎样才能将一个 IntPtr 转换为一个图像?我知道相反的很简单,只需使用 MyImage.Ptr。但是如何将 IntPtr 转换为 Image 呢?

4

0 回答 0