-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from v7labs/simplify-polygon
Simplify polygons
- Loading branch information
Showing
8 changed files
with
5,090 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import numpy as np | ||
|
||
from upolygon import simplify_polygon | ||
|
||
|
||
def test_empty_path(): | ||
assert len(simplify_polygon([], 1)) == 0 | ||
|
||
|
||
def test_empty_sub_path(): | ||
assert len(simplify_polygon([[]], 1)) == 1 | ||
|
||
|
||
def test_removes_linear_points(): | ||
path = [0, 0, 0, 5, 0, 10, 0, 15] | ||
assert simplify_polygon([path], 0) == [[0, 0, 0, 15]] | ||
|
||
|
||
def test_keeps_non_linear_points(): | ||
path = [0, 0, 0, 5, 0, 7, 10, 10, 0, 15] | ||
assert simplify_polygon([path], 1) == [[0, 0, 0, 7, 10, 10, 0, 15]] | ||
|
||
|
||
def test_respects_epsilon(): | ||
path = [0, 0, 1, 1, 0, 10] | ||
assert simplify_polygon([path], 1) == [[0, 0, 0, 10]] | ||
assert simplify_polygon([path], 0.1) == [[0, 0, 1, 1, 0, 10]] | ||
|
||
|
||
def test_handles_repeats(): | ||
path = [0, 0, 0, 0, 0, 0, 1, 1] | ||
assert simplify_polygon([path], 1) == [[0, 0, 1, 1]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from draw_polygon import draw_polygon # noqa | ||
from find_contours import find_contours # noqa | ||
from simplify_polygon import simplify_polygon # noqa |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.