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; }
/// Source variable MatOfPoint SrcMtx; /// New variable MatOfPoint2f NewMtx = new MatOfPoint2f( SrcMtx.toArray() );
MatOfPoint hullPoints = new MatOfPoint(); hullPoints.fromList(digits); Imgproc.convexHull(hullPoints, digitsHullIdx); List<Point> points = hullPoints.toList(); for (Integer i: digitsHullIdx.toList()) MatOfPoint digitsHullPoints = new MatOfPoint(); digitsHullPoints.fromList(digitsHullPointsList);
protected MatOfPoint(long addr) { super(addr); if( !empty() && checkVector(_channels, _depth) < 0 ) throw new IllegalArgumentException("Incompatible Mat"); //FIXME: do we need release() here? }
public MatOfPoint(Point...a) { super(); fromArray(a); }
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
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
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); }
protected MatOfPoint(long addr) { super(addr); if( !empty() && checkVector(_channels, _depth) < 0 ) throw new IllegalArgumentException("Incompatible Mat"); //FIXME: do we need release() here? }
public MatOfPoint(Point...a) { super(); fromArray(a); }
public static MatOfPoint fromNativeAddr(long addr) { return new MatOfPoint(addr); }
protected MatOfPoint(long addr) { super(addr); if( !empty() && checkVector(_channels, _depth) < 0 ) throw new IllegalArgumentException("Incompatible Mat"); //FIXME: do we need release() here? }