|
@@ -43,11 +43,12 @@ class BBox(namedtuple("BBox", "x0 y0 x1 y1")):
|
|
|
|
|
|
# enlarge to a square extent
|
|
|
if enlarge:
|
|
|
- h, w = int(self.h * H), int(self.h * W)
|
|
|
+ h, w = int(self.h * H), int(self.w * W)
|
|
|
size = max(h, w)
|
|
|
dw, dh = (size - w) / 2, (size - h) / 2
|
|
|
- x0, x1 = max(int(x0 - dw), 0), int(x0 - dw + size)
|
|
|
- y0, y1 = max(int(y0 - dh), 0), int(y0 - dh + size)
|
|
|
+ x0, y0 = max(int(x0 - dw), 0), max(int(y0 - dh), 0)
|
|
|
+ x1, y1 = int(x0 + size), int(y0 + size)
|
|
|
+
|
|
|
|
|
|
if im.ndim == 2:
|
|
|
return im[y0:y1, x0:x1]
|