ddd*_*ddd 7 java android opencv convex-hull
Open-CV 2.4 Android-Java:
我搜索了等高线(MatofPoint列表),如下所示:
Imgproc.findContours(roi_mat, contours, hierarchy, cfg.retMode, cfg.apxMode);
Run Code Online (Sandbox Code Playgroud)
然后是凸壳(必须是MatofInt的列表)
for (int k=0; k < contours.size(); k++){
Imgproc.convexHull(contours.get(k), hull.get(k));
}
Run Code Online (Sandbox Code Playgroud)
凸壳需要一个MatofInt,但是drawcontours想要一个MatofPoint ..那么该怎么办?
Thx提前..
编辑:@ 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);
Run Code Online (Sandbox Code Playgroud)
小智 4
看起来 OpenCV Java API 缺少另一个凸包()签名:
convexHull(MatOfPoint points, MatOfPoint hull);
Run Code Online (Sandbox Code Playgroud)
就像可以在 C++ 中调用一样。
虽然我们还没有添加它,但您需要手动创建 MatOfPoint 格式的船体:
MatOfPoint::toArray()
或MatOfPoint::toList()
获取轮廓点MatOfInt::toArray()
或MatOfInt::toList()
获取船体索引Point[]
或List<Point>
仅使用船体的点MatOfPoint
通过MatOfPoint::fromArray()
或MatOfPoint::fromList()
Core.drawContours()
归档时间: |
|
查看次数: |
3445 次 |
最近记录: |