-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve get_area() for polygons through Shoelace formula #1507
Improve get_area() for polygons through Shoelace formula #1507
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## releases/1.7.0 #1507 +/- ##
=================================================
Coverage ? 80.77%
=================================================
Files ? 275
Lines ? 31514
Branches ? 6358
=================================================
Hits ? 25456
Misses ? 4644
Partials ? 1414
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -812,11 +812,12 @@ def __attrs_post_init__(self): | |||
) | |||
|
|||
def get_area(self): | |||
import pycocotools.mask as mask_utils | |||
# import pycocotools.mask as mask_utils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# import pycocotools.mask as mask_utils |
# x, y, w, h = self.get_bbox() | ||
# rle = mask_utils.frPyObjects([self.points], y + h, x + w) | ||
# area = mask_utils.area(rle)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# x, y, w, h = self.get_bbox() | |
# rle = mask_utils.frPyObjects([self.points], y + h, x + w) | |
# area = mask_utils.area(rle)[0] |
@@ -842,6 +843,21 @@ def __eq__(self, other): | |||
inter_area = self_polygon.intersection(other_polygon).area | |||
return abs(self_polygon.area - inter_area) < CHECK_POLYGON_EQ_EPSILONE | |||
|
|||
def _get_shoelace_area(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sooahleex
If you are still interested in Rust, porting this Python function into Rust would be a good starting point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Summary
about 25 times faster computation compared to previous RLE mask based area computation
How to test
Checklist
License
Feel free to contact the maintainers if that's a concern.