public static Mat drawContours(List<MatOfPoint> contours, Mat mBase) { Mat mResult = Element.getNewMat(); Core.subtract(mBase, mBase, mResult); Imgproc.drawContours(mResult, contours, -1, new Scalar(255)); return mResult; }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public static Mat getNewMat(Size size, int type, int fill) { SX.loadNative(SX.NATIVES.OPENCV); switch (type) { case 1: type = CvType.CV_8UC1; break; case 3: type = CvType.CV_8UC3; break; case 4: type = CvType.CV_8UC4; break; default: type = -1; } if (type < 0) { return new Mat(); } Mat result; if (fill < 0) { result = new Mat(size, type); } else { result = new Mat(size, type, new Scalar(fill)); } return result; }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public static Mat drawContoursInImage(List<MatOfPoint> contours, Mat mBase) { Mat mResult = Element.getNewMat(); Mat mWork = new Mat(); Imgproc.cvtColor(mBase, mWork, toGray); Imgproc.cvtColor(mWork, mResult, toColor); Imgproc.drawContours(mResult, contours, -1, new Scalar(0, 0, 255)); return mResult; }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public Element next() { Element match = null; if (hasNext()) { match = new Element(new Element(currentX + offX, currentY + offY, target.w, target.h), currentScore); int margin = getPurgeMargin(); Range rangeX = new Range(Math.max(currentX - margin, 0), currentX + 1); Range rangeY = new Range(Math.max(currentY - margin, 0), currentY + 1); result.colRange(rangeX).rowRange(rangeY).setTo(new Scalar(0f)); } return match; }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
mMask = new Mat(shot.getContent().size(), CvType.CV_8UC1); if (!maskingToggle) { mMask.setTo(new Scalar(0)); Imgproc.fillPoly(mMask, elementToPoints(mask), new Scalar(255)); innerMask = true; } else { mMask.setTo(new Scalar(255)); Imgproc.fillPoly(mMask, elementToPoints(mask), new Scalar(0)); innerMask = false;
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public HueSaturationValueRange(double minHue, double maxHue, double minSaturation, double maxSaturation, double minValue, double maxValue) { this.minHue = minHue; this.minSaturation = minSaturation; this.minValue = minValue; this.maxHue = maxHue; this.maxSaturation = maxSaturation; this.maxValue = maxValue; min = new Scalar(minHue, minSaturation, minValue); max = new Scalar(maxHue, maxSaturation, maxValue); }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public HueSaturationValueRange(double minHue, double maxHue, double minSaturation, double maxSaturation, double minValue, double maxValue) { this.minHue = minHue; this.minSaturation = minSaturation; this.minValue = minValue; this.maxHue = maxHue; this.maxSaturation = maxSaturation; this.maxValue = maxValue; min = new Scalar(minHue, minSaturation, minValue); max = new Scalar(maxHue, maxSaturation, maxValue); }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public Scalar mul(Scalar it, double scale) { return new Scalar(val[0] * it.val[0] * scale, val[1] * it.val[1] * scale, val[2] * it.val[2] * scale, val[3] * it.val[3] * scale); }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
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; }
public Scalar(double[] vals) { if (vals != null && vals.length == 4) val = vals.clone(); else { val = new double[4]; set(vals); } }
public static Scalar sumElems(Mat src) { Scalar retVal = new Scalar(sumElems_0(src.nativeObj)); return retVal; }