2012-06-09 20 views
7

オープン-CV 2.4のAndroid-Javaの:アンドロイドJavaのOpenCVの2.4凸包convexdefect

私はこのような輪郭(MatofPointのリスト)で検索しました:

Imgproc.findContours(roi_mat, contours, hierarchy, cfg.retMode, cfg.apxMode); 

、その後凸包を(持っています

for (int k=0; k < contours.size(); k++){ 

    Imgproc.convexHull(contours.get(k), hull.get(k)); 
} 

)MatofIntのリストであることを凸包はMatofIntが、目を望んでいますdrawcontoursはMatofPointを望んでいます。だから何をするのですか?以下のよう

convexHull(MatOfPoint points, MatOfPoint hull); 

:事前に

Thxを...


編集:OpenCVのJava APIには、別の凸包()署名が欠けているようにOpenCV4Android

for (int k=0; k < contours.size(); k++){ 
    Imgproc.convexHull(contours.get(k), hullInt); 

    for(int j=0; j < hullInt.toList().size(); j++){ 
     hullPointList.add(contours.get(k).toList().get(hullInt.toList().get(j))); 
    } 

    hullPointMat.fromList(hullPointList); 
    hullPoints.add(hullPointMat); 
} 

Imgproc.drawContours(mROI, hullPoints, -1, new Scalar(255,0,0, 255), 1); 

答えて

4

@が見えますC++を呼び出すことは可能です。

我々はそれを追加していないが、手動で船体でMatOfPointフォーマットを作成する必要があります取得するMatOfInt::toArray()またはMatOfInt::toList()を使用

  • 輪郭のポイントを得るために

    • 使用MatOfPoint::toArray()またはMatOfPoint::toList()を船体の指数
    • 新規作成Point[]またはList<Point>船体の点のみ
    • MatOfPoint
    • MatOfPoint::fromArray()経由または MatOfPoint::fromList()コール Core.drawContours()
  • +0

    輪郭のための追加リスト・ポイントの前に、[OK] THXを明確hullPointListを必要としています。私はそれを試してみよう。.. – ddd

    +0

    よく質問してみたが、このように試したことがある。 私はその正当な理由がわからない。 img .. – ddd

    +0

    を横切っている赤い凸包線がたくさんあるのですが、これはfindcontourのためです(findcontourの前にcannyやthresholdとgaussフィルターを試しました) – ddd

    0

    に変換し、我々は

    hullPointList .clear(); 
    for(int j=0; j < hullInt.toList().size(); j++){ 
         hullPointList.add(contours.get(k).toList().get(hullInt.toList().get(j))); 
        } 
    
    関連する問題