cpr = _ConcavePolygonRecoverer()
points = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(points, random_state=np.random.RandomState(0))
// doing this without the list(.) wrappers fails on python2.7
assert list(points_fit) == list(sm.xrange(len(points)))
// square-like, but top line has one point in its center which"s
// y-coordinate is below the bottom line
points = [(0.0, 0.0), (0.45, 0.0), (0.5, 1.5), (0.55, 0.0), (1.0, 0.0),
(1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(points, random_state=np.random.RandomState(0))
_assert_ids_match(points_fit, [0, 1, 3, 4, 5, 2, 6])
assert ia.Polygon([points[idx] for idx in points_fit]).is_valid
// |--| |--|
// | | | |
// | | | |
// |--|--|--|
// | |
// ----
// the intersection points on the bottom line are not provided,
// hence the result is expected to have triangles at the bottom left
// and right
points = [(0.0, 0), (0.25, 0), (0.25, 1.25),
(0.75, 1.25), (0.75, 0), (1.0, 0),
(1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(points, random_state=np.random.RandomState(0))
_assert_ids_match(points_fit, [0, 1, 4, 5, 6, 3, 2, 7])
poly_observed = ia.Polygon([points[idx] for idx in points_fit])
assert poly_observed.is_valid
// same as above, but intersection points at the bottom line are provided
// without oversampling, i.e. incorporating these points would lead to an
// invalid polygon
points = [(0.0, 0), (0.25, 0), (0.25, 1.0), (0.25, 1.25),
(0.75, 1.25), (0.75, 1.0), (0.75, 0), (1.0, 0),
(1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(points, random_state=np.random.RandomState(0))
assert len(points_fit) >= len(points) - 2 // TODO add IoU check here
poly_observed = ia.Polygon([points[idx] for idx in points_fit])
assert poly_observed.is_valid
After Change
"count mismatch: %d vs %d" % (max_count, len(expected)))
cpr = _ConcavePolygonRecoverer()
rng = iarandom.RNG(0)
points = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(
points, random_state=rng.copy())
// doing this without the list(.) wrappers fails on python2.7
assert list(points_fit) == list(sm.xrange(len(points)))
// square-like, but top line has one point in its center which"s
// y-coordinate is below the bottom line
points = [(0.0, 0.0), (0.45, 0.0), (0.5, 1.5), (0.55, 0.0), (1.0, 0.0),
(1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(
points, random_state=rng.copy())
_assert_ids_match(points_fit, [0, 1, 3, 4, 5, 2, 6])
assert ia.Polygon([points[idx] for idx in points_fit]).is_valid
// |--| |--|
// | | | |
// | | | |
// |--|--|--|
// | |
// ----
// the intersection points on the bottom line are not provided,
// hence the result is expected to have triangles at the bottom left
// and right
points = [(0.0, 0), (0.25, 0), (0.25, 1.25),
(0.75, 1.25), (0.75, 0), (1.0, 0),
(1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(
points, random_state=rng.copy())
_assert_ids_match(points_fit, [0, 1, 4, 5, 6, 3, 2, 7])
poly_observed = ia.Polygon([points[idx] for idx in points_fit])
assert poly_observed.is_valid
// same as above, but intersection points at the bottom line are
// provided without oversampling, i.e. incorporating these points
// would lead to an invalid polygon
points = [(0.0, 0), (0.25, 0), (0.25, 1.0), (0.25, 1.25),
(0.75, 1.25), (0.75, 1.0), (0.75, 0), (1.0, 0),
(1.0, 1.0), (0.0, 1.0)]
points_fit = cpr._fit_best_valid_polygon(
points, random_state=rng.copy())
assert len(points_fit) >= len(points) - 2 // TODO add IoU check here
poly_observed = ia.Polygon([points[idx] for idx in points_fit])
assert poly_observed.is_valid