2017-12-29 30 views
0

C++ OpenCVコードをC#Emgucvに変換しようとしています。私はいくつかの行を変換しましたが、私は1行についています。C#EmguCV Mat.Ptr

Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr<float>()); 

私は

Mat detectionMat = new Mat(detection.SizeOfDimemsion[2], detection.SizeOfDimemsion[3], Emgu.CV.CvEnum.DepthType.Cv32F, detection.Ptr.ToPointer()); 

上記のように変換さしかし、私はdetection.Ptr.ToPointer(の問題を抱えている知っている)私は変換できませんでした。前もって感謝します。

caffe.PopulateNet(net); 

     Mat prob; 
     Mat img2 = new Mat(300,300,img.Depth,img.NumberOfChannels); 
     Emgu.CV.CvInvoke.Resize(img, img2, new Size(300, 300)); 

     //Mat inputBlob = DnnInvoke.BlobFromImage(img2,0.007843, new Size(300, 300), new MCvScalar(127.5,127.5,127.5), true); // ?? 
     Mat inputBlob = DnnInvoke.BlobFromImage(img, 0.007843, mean: new MCvScalar(127.5, 127.5, 127.5), swapRB: false); 
     net.SetInput(inputBlob, "data"); 

     Mat detection = net.Forward("detection_out"); 
     Mat detectionMat = new Mat(detection.SizeOfDimemsion[2], detection.SizeOfDimemsion[3], Emgu.CV.CvEnum.DepthType.Cv32F, detection.ptr<float>()); 

     double confidenceThreshold = 0.2; 

答えて

0

@Musa、Emgu CVのどのバージョンを使用していますか。最近、指定したパラメータを持つMatコンストラクタはありません。あなたは次のいずれかを選択できます:

Mat Constructor (Int32, Int32, DepthType, Int32) 
Mat Constructor (Int32[], DepthType, IntPtr,IntPtr[]) 
Mat Constructor (Size, DepthType, Int32, IntPtr, Int32) 
Mat Constructor (Int32, Int32, DepthType, Int32, IntPtr, Int32) 

最後のものを使用することを意味すると思います。もしそうなら、これはあなたのデータに対するIntPtrです。しかし、データが何であるか分からず、私はあまり助けにならない。検出が何であるか、完全なコードスニペットを知ることは非常に役に立ちます。

EDIT: Musa、私はEmguCVのDNNの部分で作業していないが、あなたがしようとしていることを見ていると思う。 net.Forward()呼び出しの結果としてMatオブジェクトがあります。私は、あなたが次のことを試してみて、それが助けかどうかもしれないと思う:

Mat detectionMat = new Mat(detection.SizeOfDimemsion[2], detection.SizeOfDimemsion[3], Emgu.CV.CvEnum.DepthType.Cv32F, detection.NumberOfChannels, detection.DataPointer, detection.Step); 

ダグ

返信用
+0

おかげで、私はバージョン3.3.0 EmguCVを使用しています。また、すべてのコード行で質問を編集します。注目に感謝 – Musa

+0

私はコードを編集しました – Musa

+0

私は最後のスタンドについてもお知らせします。あなたの興味に感謝します – Musa

関連する問題