EmguCV でラップされた OpenCV コードを C++ から C# に変換しています。継続的に私を悩ませていることの 1 つは、Opencv では、多くのものが 、 などのポインターIplImage*
でCvCapture*
あり、それらを C# に変換すると、すべてが次IntPtrs
のようになるIntPtr 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 を Image に変換できますか? 逆の方法は簡単です。MyImage.Ptr を使用するだけです。しかし、IntPtr を Image に変換する方法は?