Finding simple geometric shapes quickly using RANSAC-based algorithms
Project description
fast-shape-finder
Finding simple geometric shapes quickly using RANSAC-based algorithms
Aim of the project
This is an attempt to apply RANSAC to find geometric shapes in images. The ultimate goal of this project is to find arbitrary shapes on any surface and to acquiring both the position and attitude information, while also being efficient as possible. The project is currently in its early stages, and the algorithms are not yet fully developed.
Motivation
While there are many algorithms that can be applied to solve this problem, they generally require a lot of computational resources. This is excepted since many of them are not designed nor optimized to detect geometric or simple shapes. With this in mind, I have decided to design and implement an algorithm exclusively for this problem.
Details of the algorithm and implementation
In the first step, the edge features are extracted from the image by applying inequalities derived from HSV to RGB conversion formulas. This step is equivalent to converting images to HSV space, thresholding the individual pixels, and applying edge detection. However, this approach is generally quite slow since it involves extensive use of floating-point arithmetic operations like division. In my approach, all of them are applied in a single pass on the image. It also does not involve any floating-point arithmetic or even integer division. The "edge detection" method used is quite primitive. It is simple thresholding across the horizontal or vertical axis and recording the color change points. Yet, it works pretty reliably, given that the HSV filter is working reasonably. In this way, cache misses are minimized. It should be noted that this step does not scan the complete image. It uses the Halton sequence to select rows or columns in a Monte Carlo manner.
A simple "noise reduction" algorithm is applied to acquired edge points in the second step. This step is optional, but it generally significantly improves the third step's efficiency. It checks the pixel-wise distance between edge points in the same row or column. If some portions are close to each other, this step merges them. If some portions are small enough, it eliminates them.
In the third step, the RANSAC algorithm is applied to fit shapes. While only circles and ellipses are allowed at this point, the plan is to use vertices and edges to acquire the 2D perspective transformation of the shape. In this way, it will be possible to find arbitrary shapes under perspective transformation. Later, that transformation will be combined with the known properties of the used camera, which will result in the exact relative position and attitude.
Ellipse fit utilizes the general conic equation and a custom linear equation solver. Then, some checks are performed to decide whether or not the found conic equation corresponds to an ellipse.
Current state of the implementation
The implementation is available as a Python package, and it does not depend on any external libraries. It is currently written in Cython. However, it will be migrated to C soon since it is possible to convert the code almost line by line. A more Pythonic wrapper is also planned.
Performance
While I have not published any benchmarks yet, The code is optimized for branch and cache misses. On Ryzen 4800H processor, it takes only ~500 microseconds to find a red ellipse in a 1920x1080 photo, which includes an extensive amount of noise with the same color. Proper benchmarking will be published once the code is converted to C.
Installation
Install via pip:
pip install git+https://github.com/shadymeowy/fast-shape-finder
or clone the repository and run the setup script:
git clone https://github.com/shadymeowy/fast-shape-finder
cd fast-shape-finder
python setup.py install
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 Distributions
Hashes for fast-shape-finder-1.0.0a1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d6fbacc79e0291bbcaffa903e11acf99eee5662857e5b5d29213931486758ab |
|
MD5 | 224100828ffbb140e139ad70fcbf4989 |
|
BLAKE2b-256 | 4b2a1fd59a5b00c419d0aec70b13f2539be3bb5ff7c2a96cbc6a69b4444b309e |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 050f6108123a4015560cb4725917343a6a9a7efffa953741e707bd3a73f85e3e |
|
MD5 | 2af61ceec9b5d63c4cb9f14130c0c92c |
|
BLAKE2b-256 | d0d214730c06d8a911b93dc9f18c37633b8731c43614560868f204f62b43f500 |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9764106b5a4db97f524142dfaf7ca1afd2597329cf0fcbba73103097ae142a1 |
|
MD5 | 44f2c59e52ee4c99b09dc1a3b910a3e9 |
|
BLAKE2b-256 | 4d4f4a33a2bf3e4803b607d8e2d8eae26fe3ec9cdf36a755c1850f506f30e60a |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a255775e6c0698ea494ef4f05942e687eabc0beb3b7ddd483ed7db97642be7b4 |
|
MD5 | 7a9c99d8d225ba2cceeba8299a717db7 |
|
BLAKE2b-256 | e4a51c0a55a98da07a3635a7e584493702b9b5fc0f621471e332aa57bebba9ca |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01cffde505fbfb01f63b8b12170170e8b8e0001d596005d66d7f98f6733b2e13 |
|
MD5 | 16da3958e88f4bdd04f0ccd0d853e5ad |
|
BLAKE2b-256 | 052cce5c2632eed215f58869bce0eeecc21304dce68f8e2384ae0bab920dbcab |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77aad19f5646129a446d52367dd3bcbccb6bcbc18c52055e9dd3bd464ca64030 |
|
MD5 | 4fcc7fe4a9bd0bc2ab6441535354ccf6 |
|
BLAKE2b-256 | 77e724f94016b008f5bb562fdc73d206142ee8aa1a004a5380b8bce08ebf9eff |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58407c7652ea62d4226a3a29d18f93baa25e7653bfad3f69ebf2fe1611bb6c99 |
|
MD5 | 1e8b0d171d3dbe592a0023ab2d5cced2 |
|
BLAKE2b-256 | d7870fc53da470379e2fe82b92da7370984a1a570c748e4f8a3176413e8a6edd |
Hashes for fast_shape_finder-1.0.0a1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78bf30c69f6e4daa296e34655237dd32865bfc25d47a997b6ac1cf7e1fd590e7 |
|
MD5 | dcaadaa890cdd0df9eacc8539d203a97 |
|
BLAKE2b-256 | aee186c677c0554db0b0ca7fe9a6e3f611b3d5579274089a7d42626b2b52298a |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d66003bda802857d9a6f702167ee965ecf99aebc9eeeb13c0304670bab8e08c2 |
|
MD5 | d1aff23e0d9e8cee6cfa50235848dc3a |
|
BLAKE2b-256 | 480404c0f7a83e54130a2b40250d4339f8bd61e69daf4623204d86d46dfac63f |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3adfd3992e253ca2ea7cbbe79a6fbba14a7dcb2193814f4dc865b7e2a673122b |
|
MD5 | d5aa390fa9045f1cc6fce2ff7c3187f0 |
|
BLAKE2b-256 | 9490e660ab027972abf37be949a88a07a3a60e40f3c3415cd663f02e6167aa11 |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a758a6b8edd79a049140a10c620b851840074b4e849a54928a3526d3eda26b7 |
|
MD5 | a3aaec2fb211ff6372f9bfa0ecdb8dde |
|
BLAKE2b-256 | 471b7415d47bfcd62b591f0622971f1aece2bea88d1934494fcbc5fe89657494 |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61cea19a8e8f12d0e6226ae6ca7dfabc8def5cf7a5136f424821eb687faee695 |
|
MD5 | f7d44ca74cdab53f3ad4b5828b848761 |
|
BLAKE2b-256 | 27f64c4cbe28ff0e4feb173237acc748ab40f342c21e3d427c659633d8cc5ecb |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e687ad1b4b167968593816688e4a4bba91b472ad6aaed3bac83f875bc09f447 |
|
MD5 | 0f4af458bb92caae8766a1dd86c7404a |
|
BLAKE2b-256 | 2dde8a52aceb2f624fa20238832088bd47b5ff1e37b787662f8a1dc7d7305fce |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c913bb476aa2560867e098cc197385669965ff09fcae9383569f986cfe2476e |
|
MD5 | 5f2ed6d8e91c0d14c4867dd3531d08ba |
|
BLAKE2b-256 | 22f060886f1efc78e6dfb5b825d86676b4e224968d06a445b0f74b742aa5f2f9 |
Hashes for fast_shape_finder-1.0.0a1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 033bf0e29c0b8c4edb7e20790a62ab9540894b2eec84a5fe2250e8269dc368c3 |
|
MD5 | e757a7f79e41f0ce74c929b749ba5f3c |
|
BLAKE2b-256 | 302623ff8f88977724b3c20fd48af8c206cf46bccd39c164eb3c470de6355640 |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd1a0f926215548e2d6cfcf7cd6a1aa68f5f388c619a7b30422f626d04244e75 |
|
MD5 | 41fcc4d4d02549a28762ecea6766ec91 |
|
BLAKE2b-256 | eae9894adb9f5b29f8e6a8bd31c73c78574e99b7dbd7e73a83d4afe17b6eaf86 |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a235c6d09837b21ce7478bb86f6173c87ae1d21ff1c87853668ae706b67ac9a2 |
|
MD5 | 6eff73a83ae4abb0e0299c31eff0dc9b |
|
BLAKE2b-256 | 92325c869b02fc276092f1e4b27d2440dd3474fa71f88b701f8e4adebb033841 |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1933299f6f464176f626affe20191f83fb7a818d7085287625bd3c24cf904db0 |
|
MD5 | 1f385ef43b47e46390d1ff66584ba072 |
|
BLAKE2b-256 | 1efdec40e825280522bf267e09b821aeead5a0408950c362ab1014ab3fae3afc |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12597558765dcc5be5468ab0a0a29eda656951a013c6be8866131924ee077e2e |
|
MD5 | b3cf943fbb8a8081d81cb060406301a1 |
|
BLAKE2b-256 | 23ba65e43a7ce6e4f12b38fb719a455bd6af994a67e847edaf26a4b43b6b0e07 |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c26f5349dbd20007e710031800d5c52de21e49d1e664a4ea557235e48cccce3 |
|
MD5 | 12f182729f4cd2db7d0031105900f928 |
|
BLAKE2b-256 | 727e75cad4a0eef3063e890a5f779ddd4f0836713bfafe48e619595ea02501fe |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aadcee28a15ffd8c02aa50ed2f541bf1a3456b7adf251e91c3e31a019b8ff4a4 |
|
MD5 | f3408a01dc506dd4f0597ca3603ef31f |
|
BLAKE2b-256 | 0a875682281f16f945a2c7faed2633a1f918baee7f3a6a888b83c7d6241f1df8 |
Hashes for fast_shape_finder-1.0.0a1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b66f6597e58ef76935146c72691d1e3e274e734fb6e5f41a7b7460e74ea4203d |
|
MD5 | cc295c34b72c51dc226ee29ed6e9fdb5 |
|
BLAKE2b-256 | 763a0b24844952d20a314b7dce482c1dc00c08ee3a314fd1caa0ec18ce7cade2 |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51a8430aee28d079bb91b842e2acf007b3cd3946c517e8e9bdbd94719ffc83da |
|
MD5 | 076e4a034dc6a2181c298f9dbb722783 |
|
BLAKE2b-256 | f6c253fbafe894d15f410f5cf55b78ba35878884cba81ba0fdd5c92dd98a99b9 |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6625244e940e519da607057025a1c9e17092329485528672fd6b27a82771f514 |
|
MD5 | 6b5354019ae5c7a942cbf12a29243646 |
|
BLAKE2b-256 | 20bb65c1e4a999749c7293e94812b660f36e0fba4487133d3750efbd35ff5cd3 |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98924f1c99bc08d66f246ce1a4f6bc5e3f7445a473924b740654673dbb16b3b4 |
|
MD5 | 08c23ea2bd1ea7e780ec76c8101fdb85 |
|
BLAKE2b-256 | ff5b2d30ffdce9aeb2d3bc8abb21252b589fc660500f2600330879101fe14740 |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acdd038a3dfc124feb1fe7b2160712f0a1ecd48bf2eef2fc4739406aec0df895 |
|
MD5 | 4d540e48122604e5673bd8876a40a5f5 |
|
BLAKE2b-256 | a2fa440d279b85a99e32cedc383adbe81a0e41886e5aa1e76d12e30bacbf26ab |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 399dc6538764aa5bb6b02f5f7555c53c6e8d64669e30a63db052e98224f743ea |
|
MD5 | 16d5456461d291aba384a866506fe0d2 |
|
BLAKE2b-256 | 1970cda48fa2806e0bd4b9359312f5823ad1bfac62340592f3db480541bf9443 |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d741ff635c1409ceb6fc2be229541e7e6b0b0f3d55c231d9c54f4149a138b84 |
|
MD5 | 628a589fcad9136e50c01bceee64cc54 |
|
BLAKE2b-256 | 2725392e77d72e959f1421d95dc560b7fd2b9ee4d42f8d881b47870b5ec4c896 |
Hashes for fast_shape_finder-1.0.0a1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f708153503fa141c19686f2db6285fab5da96394058dcfd5ac81b343112ffe7 |
|
MD5 | ce71def02fd2630f72f50bda2c56b784 |
|
BLAKE2b-256 | 7ba51c239ae30ce357f847f650d2bcd9ec79ba38fa9f3dc84dd7673503a26792 |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cfe2b746260a9fa43d17be0507fc1d9df1372df5d762cec2b54ff212618ac14 |
|
MD5 | fd6477954ef72255407dd6ae3294e871 |
|
BLAKE2b-256 | 4d3933a7e07fa22e42efd7752e02160a469cd235c573c1fffe51d2332fa109cc |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd440b9ed52f8739c9902e56a35bfe8a025126d502b8a741dd7851e67464abc |
|
MD5 | 720f153cfb6c1f17679fa332f166cc40 |
|
BLAKE2b-256 | 2d761f275aa012476f9134f7650badd29b04d55db9ce4bf6366d1bcc73df7572 |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42abf63691166c6907bf32470a6a6b8f5085a5165b81be98cc952e48da3b1cd3 |
|
MD5 | 46cea9d1574f8b27a6a293489145ed30 |
|
BLAKE2b-256 | d566db9b289a893087d5d4d29d84b153be445bf0382c673e5b4a8feaa8d382a3 |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dd1a0a9f6f2bd46344b1a8b182458f51d517c21bbbfd5f7eccdcc5af4ba81ad |
|
MD5 | 787eb8abd7e059359f45e03a84853d84 |
|
BLAKE2b-256 | cd6121208219863cc270921f3310d752504b2b4f92999db45620ef9d0ac6ef7f |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_28_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c39c3aed15eea48c3910510153bab3c08b8b2d1f59a1b9e53c927dc1a88d04c2 |
|
MD5 | aaea601c69106685592e08a52c7770a6 |
|
BLAKE2b-256 | e76365f08202c827df84af8ba396ff88534ca16ddc707cec69f029bc976d3fd9 |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 882f3f6e8db5c7291dcd0deec00498a4f64c08771117341d8600c50486e95d1e |
|
MD5 | b7b0dff60f5d1f08019bcd67dd45f811 |
|
BLAKE2b-256 | ee1e37e399ea1ed0d66fd41cc68da0f0f2eb8c078546a03e66ee27849ed02a55 |
Hashes for fast_shape_finder-1.0.0a1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3833715b327d6eda1cf421669a0cf23f8a036c6e96c7dc73bf80e719b3dd5aeb |
|
MD5 | e6360aeba800fbbe535f0c4c6c47327e |
|
BLAKE2b-256 | fea844e01d60ed78839d68a7ab58afcdfff9b184883dccb637b8106ec230e067 |