List of usage examples for org.opencv.core Rect equals
@Override
public boolean equals(Object obj)
From source file:cv.recon.controller.OutputDisplayController.java
License:Open Source License
/** * Combine overlapping rectangles./*from w w w. j a v a2 s . co m*/ * @param rectangles A list of rectangles */ private void combineOverlappingRectangles(List<Rect> rectangles) { boolean stillOverlap; do { stillOverlap = false; for (int i = 0; i < rectangles.size(); i++) { Rect rectA = rectangles.get(i); for (int j = 0; j < rectangles.size(); j++) { Rect rectAClone = rectA.clone(); Rect rectB = rectangles.get(j); if (rectA.equals(rectB)) { continue; } if (isOverlap(rectA, rectB)) { rectA.x = Math.min(rectA.x, rectB.x); rectA.y = Math.min(rectA.y, rectB.y); rectA.width = Math.max(rectAClone.x + rectAClone.width, rectB.x + rectB.width); rectA.width -= rectA.x; rectA.height = Math.max(rectAClone.y + rectAClone.height, rectB.y + rectB.height); rectA.height -= rectA.y; rectangles.remove(rectB); stillOverlap = true; } } } } while (stillOverlap); }