fix are calc for polygon
parent
895d44bc39
commit
3728183276
|
@ -84,11 +84,12 @@ class MakeShrinkMap(object):
|
||||||
return polygons, ignore_tags
|
return polygons, ignore_tags
|
||||||
|
|
||||||
def polygon_area(self, polygon):
|
def polygon_area(self, polygon):
|
||||||
# return cv2.contourArea(polygon.astype(np.float32))
|
"""
|
||||||
edge = 0
|
compute polygon area
|
||||||
for i in range(polygon.shape[0]):
|
"""
|
||||||
next_index = (i + 1) % polygon.shape[0]
|
area = 0
|
||||||
edge += (polygon[next_index, 0] - polygon[i, 0]) * (
|
q = polygon[-1]
|
||||||
polygon[next_index, 1] - polygon[i, 1])
|
for p in polygon:
|
||||||
|
area += p[0] * q[1] - p[1] * q[0]
|
||||||
return edge / 2.
|
q = p
|
||||||
|
return area / 2.0
|
||||||
|
|
Loading…
Reference in New Issue