List of usage examples for org.opencv.core MatOfPoint height
public int height()
From source file:qupath.opencv.DetectCytokeratinCV.java
License:Open Source License
public static void updateArea(final List<MatOfPoint> contours, final Mat hierarchy, final Area area, int row, int depth) { while (row >= 0) { int[] data = new int[4]; hierarchy.get(0, row, data);//w ww.ja va 2s . com MatOfPoint contour = contours.get(row); // Don't include isolated pixels - otherwise add or remove, as required if (contour.height() > 2) { Path2D path = getContour(contour); if (depth % 2 == 0) area.add(new Area(path)); else area.subtract(new Area(path)); } // Deal with any sub-contours if (data[2] >= 0) updateArea(contours, hierarchy, area, data[2], depth + 1); // Move to next contour in this hierarchy level row = data[0]; } }
From source file:simeav.Utils.java
public static ArrayList<Point> detectarVertices(Mat original) { MatOfPoint corners = new MatOfPoint(); Imgproc.goodFeaturesToTrack(original, corners, 100, 0.01, 0, new Mat(), 2, false, 0.04); Mat vertices = Mat.zeros(original.size(), CvType.CV_8UC3); for (int i = 0; i < corners.height(); i++) { Core.circle(vertices, new Point(corners.get(i, 0)), 8, new Scalar(180, 170, 5), -1); }/*from ww w. jav a 2 s . c o m*/ Mat imGrises = new Mat(); Mat bw = new Mat(); Imgproc.cvtColor(vertices, imGrises, Imgproc.COLOR_BGR2GRAY); Imgproc.Canny(imGrises, bw, 100, 150, 5, true); Mat jerarquia = new Mat(); ArrayList<MatOfPoint> contornos = new ArrayList<>(); Imgproc.findContours(bw.clone(), contornos, jerarquia, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); ArrayList<Point> mc = Utils.getCentros(contornos); Mat resultado = Mat.zeros(original.size(), CvType.CV_8UC3); for (int i = 0; i < contornos.size(); i++) { Scalar color = new Scalar(180, 170, 5); // Imgproc.drawContours(resultado, contornos, i, color, 2, 8, jerarquia, 0, new Point()); Core.circle(resultado, mc.get(i), 4, color, -1, 8, 0); } return mc; }