List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    String filename = "cannystopa4.png";

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Mat rgbImage = Imgcodecs.imread("foto.jpg");
    Mat imageCny = new Mat();
    Imgproc.Canny(rgbImage, imageCny, 50, 150, 3, true);

    Imgproc.findContours(imageCny, contours , new Mat(), Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_NONE);

    int i;
    for(i = 0; i<contours.size(); i++) {
          System.out.println(contours.get(i));
    }

如何从ArraylistMatOfPoint获取笛卡尔坐标?

最佳答案

迭代轮廓列表,并为每个MatOfPoint迭代其包含的Point对象的列表。

for( MatOfPoint mop: contours ){
    for( Point p: mop.toList() ){
        ... p.x, p.y ... // another coordinate
    }
}

关于java - MatOfPoint笛卡尔坐标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33709854/

10-13 03:20