我正在将一些OpenCV代码从C ++翻译成由EmguCV包装的C#。让我烦恼的一件事是,在Opencv中,很多东西都是指针IplImage*
,CvCapture*
等,当我将它们翻译成C#时,它们都变成IntPtrs
,就像{{1}在这个特定问题中,我遇到了以IntPtr Capture=CvInvoke.CvCreateCameraCapture(0)
原始代码如下:
IntPtr
当我在C#中重写上面的部分时,它看起来像
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.
如果我可以稍微扩展一下这个问题,在其他情况下,例如我有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);
,我怎样才能将IntPtr转换为图像?我知道反向的很简单,只需使用MyImage.Ptr。但是如何将IntPtr转换为图像?