n-fold-edge 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. n_fold_edge-1.0.0/.github/workflows/docs.yml +43 -0
  2. n_fold_edge-1.0.0/.github/workflows/publish_pypi.yml +156 -0
  3. n_fold_edge-1.0.0/.gitignore +62 -0
  4. n_fold_edge-1.0.0/.pre-commit-config.yaml +38 -0
  5. n_fold_edge-1.0.0/.python-version +1 -0
  6. n_fold_edge-1.0.0/LICENSE +27 -0
  7. n_fold_edge-1.0.0/PKG-INFO +52 -0
  8. n_fold_edge-1.0.0/README.md +39 -0
  9. n_fold_edge-1.0.0/docs/Makefile +23 -0
  10. n_fold_edge-1.0.0/docs/make.bat +35 -0
  11. n_fold_edge-1.0.0/docs/source/CLI.rst +18 -0
  12. n_fold_edge-1.0.0/docs/source/_static/markers-with-orientation.png +0 -0
  13. n_fold_edge-1.0.0/docs/source/_static/markers.png +0 -0
  14. n_fold_edge-1.0.0/docs/source/_static/notes/differentmarkerorders.png +0 -0
  15. n_fold_edge-1.0.0/docs/source/_static/notes/idealmarkerwaveform.png +0 -0
  16. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/finalmarker.png +0 -0
  17. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/markertrackerbendingstill1.png +0 -0
  18. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/markertrackerbendingstill121.png +0 -0
  19. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/markertrackerbendingstill181.png +0 -0
  20. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/markertrackerbendingstill241.png +0 -0
  21. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/markertrackerbendingstill300.png +0 -0
  22. n_fold_edge-1.0.0/docs/source/_static/notes/marker_bending/markertrackerbendingstill61.png +0 -0
  23. n_fold_edge-1.0.0/docs/source/_static/notes/marker_types/aruco_250x250.png +0 -0
  24. n_fold_edge-1.0.0/docs/source/_static/notes/marker_types/aruco_25x25.png +0 -0
  25. n_fold_edge-1.0.0/docs/source/_static/notes/marker_types/logspiral_21x21.png +0 -0
  26. n_fold_edge-1.0.0/docs/source/_static/notes/marker_types/logspiral_91x91.png +0 -0
  27. n_fold_edge-1.0.0/docs/source/_static/notes/marker_types/qr_code_230x230.png +0 -0
  28. n_fold_edge-1.0.0/docs/source/_static/notes/marker_types/qr_code_48x48.png +0 -0
  29. n_fold_edge-1.0.0/docs/source/_static/notes/markerwithindicatedorientation.png +0 -0
  30. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/hubsan_magnitude_response_inverted_n4_kernel.png +0 -0
  31. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/hubsan_merged_input_and_oriented_quality_template_oriented.png +0 -0
  32. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/hubsan_oriented_quality_template_oriented.png +0 -0
  33. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/hubsan_region_around_detected_marker.png +0 -0
  34. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/hubsanwithmarker_small.png +0 -0
  35. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/input/hubsanwithmarker.jpg +0 -0
  36. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/kernel_argument.png +0 -0
  37. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/kernel_imaginary_part.png +0 -0
  38. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/kernel_magnitude.png +0 -0
  39. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/kernel_real_part.png +0 -0
  40. n_fold_edge-1.0.0/docs/source/_static/notes/pythonpic/markertrackerillustrations.py +79 -0
  41. n_fold_edge-1.0.0/docs/source/_static/notes/squarewave.png +0 -0
  42. n_fold_edge-1.0.0/docs/source/_static/patterns.pdf +0 -0
  43. n_fold_edge-1.0.0/docs/source/_templates/autosummary/class.rst +34 -0
  44. n_fold_edge-1.0.0/docs/source/_templates/autosummary/module.rst +52 -0
  45. n_fold_edge-1.0.0/docs/source/conf.py +84 -0
  46. n_fold_edge-1.0.0/docs/source/contributing.rst +54 -0
  47. n_fold_edge-1.0.0/docs/source/index.rst +35 -0
  48. n_fold_edge-1.0.0/docs/source/installation.rst +32 -0
  49. n_fold_edge-1.0.0/docs/source/notes/marker_implementation.rst +171 -0
  50. n_fold_edge-1.0.0/docs/source/notes/marker_types.rst +58 -0
  51. n_fold_edge-1.0.0/docs/source/notes/notes_on_markers.rst +58 -0
  52. n_fold_edge-1.0.0/docs/source/notes.rst +10 -0
  53. n_fold_edge-1.0.0/docs/source/reference.rst +11 -0
  54. n_fold_edge-1.0.0/docs/source/tutorials/locate_marker_tutorial.rst +30 -0
  55. n_fold_edge-1.0.0/docs/source/tutorials/track_marker_tutorial.rst +53 -0
  56. n_fold_edge-1.0.0/patterns/patterns.tex +261 -0
  57. n_fold_edge-1.0.0/patterns/robolabmarkers.tex +95 -0
  58. n_fold_edge-1.0.0/pyproject.toml +127 -0
  59. n_fold_edge-1.0.0/src/n_fold_edge/__init__.py +6 -0
  60. n_fold_edge-1.0.0/src/n_fold_edge/__main__.py +110 -0
  61. n_fold_edge-1.0.0/src/n_fold_edge/marker_locator.py +161 -0
  62. n_fold_edge-1.0.0/src/n_fold_edge/marker_pose.py +24 -0
  63. n_fold_edge-1.0.0/src/n_fold_edge/marker_tracker.py +123 -0
  64. n_fold_edge-1.0.0/src/n_fold_edge/py.typed +0 -0
  65. n_fold_edge-1.0.0/uv.lock +940 -0
@@ -0,0 +1,43 @@
1
+ name: Generate Docs and upload to pages.
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ # Build job
15
+ build:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v7
22
+ - name: Install the project
23
+ run: uv sync --locked --all-extras --dev
24
+ - name: Build docs
25
+ id: build
26
+ run: uv run make -C docs html
27
+ - name: Upload doc build as artifact
28
+ id: deployment
29
+ uses: actions/upload-pages-artifact@v3
30
+ with:
31
+ path: docs/build/html
32
+
33
+ # Deployment job
34
+ deploy:
35
+ environment:
36
+ name: github-pages
37
+ url: ${{ steps.deployment.outputs.page_url }}
38
+ runs-on: ubuntu-latest
39
+ needs: build
40
+ steps:
41
+ - name: Deploy to GitHub Pages
42
+ id: deployment
43
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,156 @@
1
+ name: Publish Python distribution to PyPI and TestPyPI. Create Release and upload docs.
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build:
7
+ name: Build distribution
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ with:
13
+ persist-credentials: false
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.x"
18
+ - name: Install pypa/build
19
+ run: >-
20
+ python3 -m
21
+ pip install
22
+ build
23
+ --user
24
+ - name: Build a binary wheel and a source tarball
25
+ run: python3 -m build
26
+ - name: Store the distribution packages
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: python-package-distributions
30
+ path: dist/
31
+
32
+ publish-to-pypi:
33
+ name: >-
34
+ Publish Python distribution to PyPI
35
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
36
+ needs:
37
+ - build
38
+ runs-on: ubuntu-latest
39
+ environment:
40
+ name: pypi
41
+ url: https://pypi.org/p/CDC # Replace <package-name> with your PyPI project name
42
+ permissions:
43
+ id-token: write # IMPORTANT: mandatory for trusted publishing
44
+
45
+ steps:
46
+ - name: Download all the dists
47
+ uses: actions/download-artifact@v4
48
+ with:
49
+ name: python-package-distributions
50
+ path: dist/
51
+ - name: Publish distribution to PyPI
52
+ uses: pypa/gh-action-pypi-publish@release/v1
53
+
54
+ github-release:
55
+ name: >-
56
+ Sign the Python distribution with Sigstore
57
+ and upload them to GitHub Release
58
+ needs:
59
+ - publish-to-pypi
60
+ runs-on: ubuntu-latest
61
+
62
+ permissions:
63
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
64
+ id-token: write # IMPORTANT: mandatory for sigstore
65
+
66
+ steps:
67
+ - name: Download all the dists
68
+ uses: actions/download-artifact@v4
69
+ with:
70
+ name: python-package-distributions
71
+ path: dist/
72
+ - name: Sign the dists with Sigstore
73
+ uses: sigstore/gh-action-sigstore-python@v3.0.0
74
+ with:
75
+ inputs: >-
76
+ ./dist/*.tar.gz
77
+ ./dist/*.whl
78
+ - name: Create GitHub Release
79
+ env:
80
+ GITHUB_TOKEN: ${{ github.token }}
81
+ run: >-
82
+ gh release create
83
+ "$GITHUB_REF_NAME"
84
+ --repo "$GITHUB_REPOSITORY"
85
+ --generate-notes
86
+ - name: Upload artifact signatures to GitHub Release
87
+ env:
88
+ GITHUB_TOKEN: ${{ github.token }}
89
+ # Upload to GitHub Release using the `gh` CLI.
90
+ # `dist/` contains the built packages, and the
91
+ # sigstore-produced signatures and certificates.
92
+ run: >-
93
+ gh release upload
94
+ "$GITHUB_REF_NAME" dist/**
95
+ --repo "$GITHUB_REPOSITORY"
96
+
97
+ publish-to-testpypi:
98
+ name: Publish Python distribution to TestPyPI
99
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
100
+ needs:
101
+ - build
102
+ runs-on: ubuntu-latest
103
+
104
+ environment:
105
+ name: testpypi
106
+ url: https://test.pypi.org/p/CDC
107
+
108
+ permissions:
109
+ id-token: write # IMPORTANT: mandatory for trusted publishing
110
+
111
+ steps:
112
+ - name: Download all the dists
113
+ uses: actions/download-artifact@v4
114
+ with:
115
+ name: python-package-distributions
116
+ path: dist/
117
+ - name: Publish distribution to TestPyPI
118
+ uses: pypa/gh-action-pypi-publish@release/v1
119
+ with:
120
+ repository-url: https://test.pypi.org/legacy/
121
+
122
+ # Build docs job
123
+ build_docs:
124
+ needs: github-release
125
+ runs-on: ubuntu-latest
126
+ steps:
127
+ - name: Checkout
128
+ uses: actions/checkout@v4
129
+ - name: Install uv
130
+ uses: astral-sh/setup-uv@v7
131
+ - name: Install the project
132
+ run: uv sync --locked --all-extras --dev
133
+ - name: Build docs
134
+ id: build
135
+ run: uv run make -C docs html
136
+ - name: Upload doc build as artifact
137
+ id: deployment
138
+ uses: actions/upload-pages-artifact@v3
139
+ with:
140
+ path: docs/build/html
141
+
142
+ # Deployment job
143
+ deploy_docs:
144
+ environment:
145
+ name: github-pages
146
+ url: ${{ steps.deployment.outputs.page_url }}
147
+ permissions:
148
+ contents: read
149
+ pages: write
150
+ id-token: write
151
+ runs-on: ubuntu-latest
152
+ needs: build_docs
153
+ steps:
154
+ - name: Deploy to GitHub Pages
155
+ id: deployment
156
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,62 @@
1
+ patterns/patterns.pdf
2
+ patterns/robolabmarkers.pdf
3
+ test_data/
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+
8
+ # Distribution / packaging
9
+ .Python
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ pip-wheel-metadata/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # pytest
30
+ test_coverage/
31
+ .coverage
32
+ .pytest_cache
33
+
34
+ # Sphinx documentation
35
+ docs/_build/
36
+ docs/build/
37
+ docs/source/_autosummary/
38
+ docs/source/reference/
39
+ docs/source/_build/
40
+
41
+ # Environments
42
+ .env
43
+ .venv
44
+ env/
45
+ venv/
46
+ ENV/
47
+ env.bak/
48
+ venv.bak/
49
+
50
+ # mypy
51
+ .mypy_cache/
52
+
53
+ # ruff
54
+ .ruff_cache/
55
+
56
+ # MISC
57
+ *.pyc
58
+ *.bak
59
+ .DS_Store
60
+ .vscode
61
+ output/
62
+ .zed
@@ -0,0 +1,38 @@
1
+ default_stages: [pre-commit, pre-push]
2
+ default_install_hook_types: [pre-commit, pre-push]
3
+ fail_fast: false
4
+ repos:
5
+ - repo: https://github.com/pre-commit/pre-commit-hooks
6
+ rev: v6.0.0
7
+ hooks:
8
+ - id: check-ast
9
+ name: Validate Python
10
+ - id: trailing-whitespace
11
+ - id: mixed-line-ending
12
+ - id: end-of-file-fixer
13
+ - id: check-toml
14
+ name: Validate pyproject.toml
15
+
16
+ - repo: https://github.com/astral-sh/ruff-pre-commit
17
+ rev: v0.15.9
18
+ hooks:
19
+ - id: ruff
20
+ name: ruff lint
21
+ types_or: [python, pyi, pyproject]
22
+ args: [--exit-non-zero-on-fix]
23
+ - id: ruff-format
24
+ types: [python, pyi, pyproject]
25
+
26
+ - repo: https://github.com/codespell-project/codespell
27
+ rev: v2.4.2
28
+ hooks:
29
+ - id: codespell
30
+ files: ^.*\.(py|md|rst)$
31
+ additional_dependencies:
32
+ - tomli
33
+
34
+ - repo: https://github.com/pre-commit/mirrors-mypy
35
+ rev: v1.20.0
36
+ hooks:
37
+ - id: mypy
38
+ args: [--strict, --ignore-missing-imports]
@@ -0,0 +1 @@
1
+ 3.14
@@ -0,0 +1,27 @@
1
+ Copyright 2014 Henrik Skov Midtiby, hemi@mmmi.sdu.du, University of Southern Denmark
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: n-fold-edge
3
+ Version: 1.0.0
4
+ Summary: Marker detector using n-fold-edge on rotational symmetric patterns
5
+ Project-URL: Homepage, https://github.com/SDU-UAS-Center/n-fold-edge
6
+ Project-URL: Issues, https://github.com/SDU-UAS-Center/n-fold-edge/issues
7
+ Author-email: Henrik Skov Midtiby <hemi@mmmi.sdu.dk>
8
+ Maintainer-email: Henrik Skov Midtiby <hemi@mmmi.sdu.dk>, Henrik Dyrberg Egemose <hde@mmmi.sdu.dk>
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.12
11
+ Requires-Dist: opencv-python>=4.13.0.92
12
+ Description-Content-Type: text/markdown
13
+
14
+ # N-fold-edge Marker locator and tracker
15
+
16
+ N-fold-edge is a marker locator and tracker. It can locate the following types of markers with high accuracy and speed.
17
+
18
+ ![Image](docs/source/_static/markers.png)
19
+
20
+ ## Table of contents:
21
+
22
+ - [Installation](#installation)
23
+ - [Usage](#usage)
24
+ - [Documentation](#documentation)
25
+ - [Contributing](#contributing)
26
+ - [License](#license)
27
+
28
+ ## Installation
29
+
30
+ N-fold-edge is a python package and can be installed with pip, uv etc.
31
+
32
+ ```
33
+ pip install CDC
34
+ ```
35
+
36
+ For more advanced installation, please visit the [Documentation]() for more information.
37
+
38
+ ## Usage
39
+
40
+ When install n-fold-edge can be used as cli. See [CLI]() for more information.
41
+
42
+ ## Documentation
43
+
44
+ For a full list of command line arguments see [CLI](). For a reference manual, please visit [Reference Manual]()
45
+
46
+ ## Contributing
47
+
48
+ For contribution guidelines, please see the [Documentation]().
49
+
50
+ ## License
51
+
52
+ The software is licensed under the BSD-3-Clause license, see [License](LICENSE).
@@ -0,0 +1,39 @@
1
+ # N-fold-edge Marker locator and tracker
2
+
3
+ N-fold-edge is a marker locator and tracker. It can locate the following types of markers with high accuracy and speed.
4
+
5
+ ![Image](docs/source/_static/markers.png)
6
+
7
+ ## Table of contents:
8
+
9
+ - [Installation](#installation)
10
+ - [Usage](#usage)
11
+ - [Documentation](#documentation)
12
+ - [Contributing](#contributing)
13
+ - [License](#license)
14
+
15
+ ## Installation
16
+
17
+ N-fold-edge is a python package and can be installed with pip, uv etc.
18
+
19
+ ```
20
+ pip install CDC
21
+ ```
22
+
23
+ For more advanced installation, please visit the [Documentation]() for more information.
24
+
25
+ ## Usage
26
+
27
+ When install n-fold-edge can be used as cli. See [CLI]() for more information.
28
+
29
+ ## Documentation
30
+
31
+ For a full list of command line arguments see [CLI](). For a reference manual, please visit [Reference Manual]()
32
+
33
+ ## Contributing
34
+
35
+ For contribution guidelines, please see the [Documentation]().
36
+
37
+ ## License
38
+
39
+ The software is licensed under the BSD-3-Clause license, see [License](LICENSE).
@@ -0,0 +1,23 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ cleanall: clean
18
+ @rm source/reference/*
19
+
20
+ # Catch-all target: route all unknown targets to Sphinx using the new
21
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
22
+ %: Makefile
23
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,18 @@
1
+ CLI
2
+ ===
3
+
4
+ marker-locator
5
+ --------------
6
+
7
+ .. argparse::
8
+ :module: n_fold_edge.__main__
9
+ :func: get_locate_markers_arg_parse
10
+ :prog: marker-locator
11
+
12
+ marker-tracker
13
+ --------------
14
+
15
+ .. argparse::
16
+ :module: n_fold_edge.__main__
17
+ :func: get_track_markers_arg_parser
18
+ :prog: marker-tracker
@@ -0,0 +1,79 @@
1
+ import cv2
2
+ import numpy as np
3
+
4
+ from n_fold_edge.marker_locator import MarkerLocator
5
+
6
+
7
+ def main() -> None:
8
+ image_of_real_and_imag_part_of_kernel()
9
+ image_of_quality_templates()
10
+ hubsan_image = cv2.imread("input/hubsanwithmarker.jpg")
11
+ hubsan_image_small = cv2.resize(hubsan_image, None, fx=0.1, fy=0.1)
12
+ cv2.imwrite("hubsanwithmarker_small.png", hubsan_image_small)
13
+ tracker = MarkerLocator(order=4, kernel_size=91, scale_factor=0.01)
14
+ tracker.track_marker_with_missing_black_leg = False
15
+ gray_scale_image = cv2.cvtColor(hubsan_image_small, cv2.COLOR_BGR2GRAY)
16
+ marker_location = tracker.locate_marker(gray_scale_image)
17
+ magnitude = np.sqrt(tracker.frame_sum_squared)
18
+ argument = np.arctan2(tracker.frame_imag, tracker.frame_real)
19
+ maximum_magnitude = np.max(magnitude)
20
+ cv2.imwrite("hubsan_magnitude_response_n4_kernel.png", magnitude / maximum_magnitude * 255)
21
+ cv2.imwrite("hubsan_magnitude_response_inverted_n4_kernel.png", (1 - magnitude / maximum_magnitude) * 255)
22
+ cv2.imwrite("hubsan_argument_response_n4_kernel.png", (3.1415 + argument) / 7 * 255)
23
+
24
+ hue = (argument + 3.1415) / (np.pi) * 180
25
+ saturation = 1 + 0 * magnitude / maximum_magnitude
26
+ value = np.sqrt(magnitude / maximum_magnitude) * 255
27
+ hsv_image = cv2.merge((hue, saturation, value))
28
+ rgb_image = cv2.cvtColor(hsv_image, cv2.COLOR_HSV2BGR)
29
+ cv2.imwrite("hubsan_magnutude_and_argument_as_hsv_n4_kernel.png", rgb_image)
30
+
31
+ region_around_detected_marker = tracker.extract_window_around_maker_location(
32
+ gray_scale_image, (int(marker_location.x), int(marker_location.y))
33
+ )
34
+ cv2.imwrite("hubsan_region_around_detected_marker.png", region_around_detected_marker)
35
+
36
+ (bright_regions, dark_regions) = tracker.generate_template_for_quality_estimator(marker_location.theta)
37
+ quality_template = 0.5 + bright_regions - dark_regions
38
+ cv2.imwrite("hubsan_oriented_quality_template_oriented.png", quality_template * 255)
39
+
40
+ merged_input_and_quality_template = cv2.addWeighted(
41
+ region_around_detected_marker.astype("float64"), 0.5, quality_template * 255, 0.5, 1
42
+ )
43
+ cv2.imwrite("hubsan_merged_input_and_oriented_quality_template_oriented.png", merged_input_and_quality_template)
44
+
45
+
46
+ def image_of_real_and_imag_part_of_kernel() -> None:
47
+ tracker = MarkerLocator(order=4, kernel_size=101, scale_factor=1)
48
+ maximum_value = np.max(tracker.mat_real)
49
+ real_part_of_kernel = 0.5 * tracker.mat_real / maximum_value + 0.5
50
+ imaginary_part_of_kernel = 0.5 * tracker.mat_imag / maximum_value + 0.5
51
+ kernel_magnitude = np.absolute(tracker.kernelComplex) / maximum_value
52
+ kernel_argument = np.angle(tracker.kernelComplex).astype("float32")
53
+ kernel_argument_hsv = np.dstack(
54
+ (kernel_argument * 180 / 3.1415926535 + 180, kernel_argument * 0 + 1, kernel_argument * 0 + 255.0)
55
+ )
56
+ kernel_argument_rgb = cv2.cvtColor(kernel_argument_hsv, cv2.COLOR_HSV2BGR)
57
+ print(np.max(kernel_argument_rgb))
58
+ cv2.imwrite("kernel_real_part.png", real_part_of_kernel * 255)
59
+ cv2.imwrite("kernel_imaginary_part.png", imaginary_part_of_kernel * 255)
60
+ cv2.imwrite("kernel_magnitude.png", kernel_magnitude * 255)
61
+ cv2.imwrite("kernel_argument.png", kernel_argument_rgb)
62
+
63
+
64
+ def image_of_quality_templates() -> None:
65
+ tracker = MarkerLocator(order=4, kernel_size=101, scale_factor=0.01)
66
+ # Set orientation of the marker
67
+ (bright_regions, dark_regions) = tracker.generate_template_for_quality_estimator(0.5)
68
+ cv2.imwrite("quality_template_oriented_white_regions.png", bright_regions * 255)
69
+ cv2.imwrite("quality_template_oriented.png", (0.5 + bright_regions - dark_regions) * 255)
70
+ cv2.imwrite("quality_template_oriented_black_regions.png", dark_regions * 255)
71
+ # Set orientation of the marker
72
+ tracker.track_marker_with_missing_black_leg = False
73
+ (bright_regions, dark_regions) = tracker.generate_template_for_quality_estimator(0.5)
74
+ cv2.imwrite("quality_template_plain_white_regions.png", bright_regions * 255)
75
+ cv2.imwrite("quality_template_plain.png", (0.5 + bright_regions - dark_regions) * 255)
76
+ cv2.imwrite("quality_template_plain_black_regions.png", dark_regions * 255)
77
+
78
+
79
+ main()