我有一个问题,把我的凸面缺陷放在框架上。为了计算这些,我修改了C++源代码,这就是我存档:OpenCV Java凸面缺陷(计算机视觉)
mConvexityDefectsMatOfInt4 = new MatOfInt4();
if(contours.size() > 0 && convexHullMatOfInt.rows() > 0)
Imgproc.convexityDefects(contours.get(0), convexHullMatOfInt, mConvexityDefectsMatOfInt4);
然而,Imgproc.drawContours(...)方法需要传递给它的参数convexityDefects将ArrayList的。我不知道如何进行转换。我还与凸包类似的问题,但是我发现一个外观图释:
convexHullMatOfInt = new MatOfInt();
convexHullPointArrayList = new ArrayList<Point>();
convexHullMatOfPoint = new MatOfPoint();
convexHullMatOfPointArrayList = new ArrayList<MatOfPoint>();
//Calculate convex hulls
if(contours.size() > 0)
{
Imgproc.convexHull(contours.get(0), convexHullMatOfInt, false);
for(int j=0; j < convexHullMatOfInt.toList().size(); j++)
convexHullPointArrayList.add(contours.get(0).toList().get(convexHullMatOfInt.toList().get(j)));
convexHullMatOfPoint.fromList(convexHullPointArrayList);
convexHullMatOfPointArrayList.add(convexHullMatOfPoint);
}
为凸缺陷类似的解决方案是行不通的。有没有人有一个想法,我该如何解决这个问题?
如何将MatOfInt4()转换为ArrayList()以绘制凸度缺陷?