IoU computation for convex polygons
Project description
tf-convex-polygon-iou
Convex Polygons Intersection over Union (IoU) computation for tensorflow.
This repository is a a generalization of https://github.com/lilanxiao/Rotated_IoU to convex polygons, and ported to tensorflow 2.
Approach
The algorithm here may not be optimal, but only uses available tensorflow operations.
The most complex parts are to compute the intersection of two convex polygon.
As for the original work, it is based on Livermore, Califf, 1977. which remarks:
- Intersection of two convex polygons is a convex polygon
- A vertex from a polygon that is contained in the other polygon is a vertex of the intersection shape.
- An edge from a polygon that is contained in the other polygon is an edge in the intersection shape.
- Edge intersections between two polygons are vertices in the intersection shape.
Therefore the algorithm here:
- Finds all vertices in a polygon that lies within the other, by computing the winding number.
- Finds all intersection between edge other edges of the two polygons.
- Sorts all vertices in trigonometric order arround a point inside the polygon (die to duplicates, it cannot be ensured that it is the centroid of the polygon).
To compute the IoU, one must finally compute the area of the intersection. The used formula is robust to duplicate vertices, if the order of vertices is right.
Requirements
tensorflow >= 2.8.0 # it may be lower, but it is not tested
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tf-convex-polygon-iou-atuleu-0.0.2.tar.gz
.
File metadata
- Download URL: tf-convex-polygon-iou-atuleu-0.0.2.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 203f0999cb4ad5ac64d9d7c359f98a4e382f897d85f28a2207691677030e1cf2 |
|
MD5 | 7a0b3a5eeba35421244206bb6c6f4572 |
|
BLAKE2b-256 | ced4b22fc899cf99b327bb5e8599ba5d382d0b5e406c79bea8bf198949859fe3 |
File details
Details for the file tf_convex_polygon_iou_atuleu-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: tf_convex_polygon_iou_atuleu-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46ebb7f852f9efab94f0e0d5b9c0ddcc9fa386a19476af6635ab0069582a7a6f |
|
MD5 | 021b50f7b62f786e5af4daf2dcbe4877 |
|
BLAKE2b-256 | 50f9944d287037405a9d4da1273a4b7070d97b9f75a4877e60934ddaf42a4e9a |