public Mat getResizedMat(double factor) { Mat newMat = getContent(); if (isValid()) { newMat = getNewMat(); Size newS = new Size(w * factor, h * factor); Imgproc.resize(getContent(), newMat, newS, 0, 0, Imgproc.INTER_AREA); } return newMat; }
public RotatedRect(Point c, Size s, double a) { this.center = c.clone(); this.size = s.clone(); this.angle = a; }
for (double factor : resizeLevels) { rfactor = factor * imgFactor; sizeBase = new Size(this.mBase.cols() / rfactor, this.mBase.rows() / rfactor); sizePattern = new Size(target.getContent().cols() / rfactor, target.getContent().rows() / rfactor); Imgproc.resize(this.mBase, mBase, sizeBase, 0, 0, Imgproc.INTER_AREA); Imgproc.resize(target.getContentBGR(), mPattern, sizePattern, 0, 0, Imgproc.INTER_AREA); if (mBase.size().equals(target.getContent().size())) {
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
public static Mat detectEdges(Mat mSource) { Mat mSourceGray = Element.getNewMat(); Mat mDetectedEdges = Element.getNewMat(); int edgeThresh = 1; int lowThreshold = 100; int ratio = 3; int kernelSize = 5; int blurFilterSize = 3; if (mSource.channels() == 1) { mSourceGray = mSource; } else { Imgproc.cvtColor(mSource, mSourceGray, toGray); } Imgproc.blur(mSourceGray, mDetectedEdges, new Size(blurFilterSize, blurFilterSize)); Imgproc.Canny(mDetectedEdges, mDetectedEdges, lowThreshold, lowThreshold * ratio, kernelSize, false); return mDetectedEdges; } //</editor-fold>
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
public RotatedRect(Point c, Size s, double a) { this.center = c.clone(); this.size = s.clone(); this.angle = a; }
public static List<Element> detectChanges(Mat base, Mat mChanged) { int PIXEL_DIFF_THRESHOLD = 3; int IMAGE_DIFF_THRESHOLD = 5; Mat mBaseGray = Element.getNewMat(); Mat mChangedGray = Element.getNewMat(); Mat mDiffAbs = Element.getNewMat(); Mat mDiffTresh = Element.getNewMat(); Mat mChanges = Element.getNewMat(); List<Element> rectangles = new ArrayList<>(); Imgproc.cvtColor(base, mBaseGray, toGray); Imgproc.cvtColor(mChanged, mChangedGray, toGray); Core.absdiff(mBaseGray, mChangedGray, mDiffAbs); Imgproc.threshold(mDiffAbs, mDiffTresh, PIXEL_DIFF_THRESHOLD, 0.0, Imgproc.THRESH_TOZERO); if (Core.countNonZero(mDiffTresh) > IMAGE_DIFF_THRESHOLD) { Imgproc.threshold(mDiffAbs, mDiffAbs, PIXEL_DIFF_THRESHOLD, 255, Imgproc.THRESH_BINARY); Imgproc.dilate(mDiffAbs, mDiffAbs, Element.getNewMat()); Mat se = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, new Size(5, 5)); Imgproc.morphologyEx(mDiffAbs, mDiffAbs, Imgproc.MORPH_CLOSE, se); List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); Mat mHierarchy = Element.getNewMat(); Imgproc.findContours(mDiffAbs, contours, mHierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); rectangles = contoursToRectangle(contours); Core.subtract(mDiffAbs, mDiffAbs, mChanges); Imgproc.drawContours(mChanges, contours, -1, new Scalar(255)); //logShow(mDiffAbs); } return rectangles; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
public RotatedRect(Point c, Size s, double a) { this.center = c.clone(); this.size = s.clone(); this.angle = a; }
public Size size() { Size retVal = new Size(n_size(nativeObj)); return retVal; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
public RotatedRect(Point c, Size s, double a) { this.center = c.clone(); this.size = s.clone(); this.angle = a; }
public Size get_blockSize() { Size retVal = new Size(get_blockSize_0(nativeObj)); return retVal; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
public RotatedRect(Point c, Size s, double a) { this.center = c.clone(); this.size = s.clone(); this.angle = a; }
public RotatedRect() { this.center = new Point(); this.size = new Size(); this.angle = 0; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof RotatedRect)) return false; RotatedRect it = (RotatedRect) obj; return center.equals(it.center) && size.equals(it.size) && angle == it.angle; }
public RotatedRect(Point c, Size s, double a) { this.center = c.clone(); this.size = s.clone(); this.angle = a; }