private List<MatOfPoint> elementToPoints(Element element) { List<Point> points = new ArrayList<>(); points.add(new Point(element.x, element.y)); points.add(new Point(element.x + element.w, element.y)); points.add(new Point(element.x + element.w, element.y + element.h)); points.add(new Point(element.x, element.y + element.h)); MatOfPoint mPoints = new MatOfPoint(); mPoints.fromList(points); List<MatOfPoint> finalPoints = new ArrayList<MatOfPoint>(); finalPoints.add(mPoints); return finalPoints; }
MatOfPoint hullPoints = new MatOfPoint(); hullPoints.fromList(digits); Imgproc.convexHull(hullPoints, digitsHullIdx); MatOfPoint digitsHullPoints = new MatOfPoint(); digitsHullPoints.fromList(digitsHullPointsList);
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
MatOfPoint mop = new MatOfPoint(); mop.fromList(contour); Moments moments = Imgproc.moments(mop); Point centroid = new Point(); centroid.x = moments.get_m10() / moments.get_m00(); centroid.y = moments.get_m01() / moments.get_m00();
MatOfPoint approxf1 = new MatOfPoint(); ... Imgproc.approxPolyDP(newMtx, approx, 0.02*peri, true); approx.convertTo(approxf1, CvType.CV_32S); List<MatOfPoint> contourTemp = new ArrayList<>(); contourTemp.add(approxf1); Imgproc.drawContours(img, contourTemp, 0, new Scalar(0, 255, 0), 2);
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); } }
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); } }
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); } }
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); } }
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); } }
public FluentCv getContourMaxRects(List<MatOfPoint> contours, List<RotatedRect> rect) { List<Point> contoursCombined = new ArrayList<>(); for (MatOfPoint mp : contours) { List<Point> points = new ArrayList<>(); Converters.Mat_to_vector_Point(mp, points); for (Point point : points) { contoursCombined.add(point); } } contours.clear(); MatOfPoint points = new MatOfPoint(); points.fromList(contoursCombined); return getContourRects(Collections.singletonList(points), rect); }
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); mi.release(); } mats.clear(); }
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) { if (pts == null) throw new java.lang.IllegalArgumentException("Output List can't be null"); if (m == null) throw new java.lang.IllegalArgumentException("Input Mat can't be null"); List<Mat> mats = new ArrayList<Mat>(m.rows()); Mat_to_vector_Mat(m, mats); for (Mat mi : mats) { MatOfPoint pt = new MatOfPoint(mi); pts.add(pt); mi.release(); } mats.clear(); }
Rect r1 = new Rect(10,10,20,20); Rect r2 = new Rect(11,11,20,20); Point[] rects_pts = new Point[4]; rects_pts[0] = r1.tl(); rects_pts[1] = r1.br(); rects_pts[2] = r2.tl(); rects_pts[3] = r2.br(); MatOfPoint mof = new MatOfPoint(); mof.fromArray(rects_pts); Rect union = Imgproc.boundingRect(mof); System.out.print( union);
public static boolean isContourSquare(MatOfPoint thisContour) { Rect ret = null; MatOfPoint2f thisContour2f = new MatOfPoint2f(); MatOfPoint approxContour = new MatOfPoint(); MatOfPoint2f approxContour2f = new MatOfPoint2f(); thisContour.convertTo(thisContour2f, CvType.CV_32FC2); Imgproc.approxPolyDP(thisContour2f, approxContour2f, 2, true); approxContour2f.convertTo(approxContour, CvType.CV_32S); if (approxContour.size().height == 4) { ret = Imgproc.boundingRect(approxContour); } return (ret != null); }
MatOfPoint mopIn = ... MatOfInt hull = new MatOfInt(); Imgproc.convexHull(mopIn, hull, false); MatOfPoint mopOut = new MatOfPoint(); mopOut.create((int)hull.size().height,1,CvType.CV_32SC2); for(int i = 0; i < hull.size().height ; i++) { int index = (int)hull.get(i, 0)[0]; double[] point = new double[] { mopIn.get(index, 0)[0], mopIn.get(index, 0)[1] }; mopOut.put(i, 0, point); } // do something interesting with mopOut