Convert k points to 1 polygon. Args: points (ndarray or list): A ndarray or a list of shape (2k) that indicates k points. Returns: polygon (Polygon): A polygon object.
(points)
| 3 | |
| 4 | |
| 5 | def points2polygon(points): |
| 6 | """Convert k points to 1 polygon. |
| 7 | |
| 8 | Args: |
| 9 | points (ndarray or list): A ndarray or a list of shape (2k) |
| 10 | that indicates k points. |
| 11 | |
| 12 | Returns: |
| 13 | polygon (Polygon): A polygon object. |
| 14 | """ |
| 15 | if isinstance(points, list): |
| 16 | points = np.array(points) |
| 17 | |
| 18 | assert isinstance(points, np.ndarray) |
| 19 | assert (points.size % 2 == 0) and (points.size >= 8) |
| 20 | |
| 21 | point_mat = points.reshape([-1, 2]) |
| 22 | return Polygon(point_mat) |
| 23 | |
| 24 | |
| 25 | def poly_intersection(poly_det, poly_gt, buffer=0.0001): |