pycvcam 1.3.4__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 (95) hide show
  1. pycvcam-1.3.4/.bumpver.toml +9 -0
  2. pycvcam-1.3.4/.github/workflows/sphinx.yml +41 -0
  3. pycvcam-1.3.4/.gitignore +30 -0
  4. pycvcam-1.3.4/.gitlab-ci.yml +12 -0
  5. pycvcam-1.3.4/LICENSE +13 -0
  6. pycvcam-1.3.4/Makefile +60 -0
  7. pycvcam-1.3.4/PKG-INFO +167 -0
  8. pycvcam-1.3.4/README.md +122 -0
  9. pycvcam-1.3.4/docs/source/api.rst +83 -0
  10. pycvcam-1.3.4/docs/source/api_doc/compute_rays.rst +5 -0
  11. pycvcam-1.3.4/docs/source/api_doc/cv2_distortion.rst +8 -0
  12. pycvcam-1.3.4/docs/source/api_doc/cv2_extrinsic.rst +8 -0
  13. pycvcam-1.3.4/docs/source/api_doc/cv2_intrinsic.rst +8 -0
  14. pycvcam-1.3.4/docs/source/api_doc/distort_image.rst +4 -0
  15. pycvcam-1.3.4/docs/source/api_doc/distortion.rst +10 -0
  16. pycvcam-1.3.4/docs/source/api_doc/extrinsic.rst +10 -0
  17. pycvcam-1.3.4/docs/source/api_doc/intrinsic.rst +10 -0
  18. pycvcam-1.3.4/docs/source/api_doc/no_distortion.rst +8 -0
  19. pycvcam-1.3.4/docs/source/api_doc/no_extrinsic.rst +8 -0
  20. pycvcam-1.3.4/docs/source/api_doc/no_intrinsic.rst +8 -0
  21. pycvcam-1.3.4/docs/source/api_doc/optimize_input_points.rst +4 -0
  22. pycvcam-1.3.4/docs/source/api_doc/optimize_parameters.rst +4 -0
  23. pycvcam-1.3.4/docs/source/api_doc/package.rst +8 -0
  24. pycvcam-1.3.4/docs/source/api_doc/project_points.rst +5 -0
  25. pycvcam-1.3.4/docs/source/api_doc/rays.rst +8 -0
  26. pycvcam-1.3.4/docs/source/api_doc/read_transform.rst +4 -0
  27. pycvcam-1.3.4/docs/source/api_doc/skew_intrinsic.rst +8 -0
  28. pycvcam-1.3.4/docs/source/api_doc/transform.rst +10 -0
  29. pycvcam-1.3.4/docs/source/api_doc/transform_result.rst +8 -0
  30. pycvcam-1.3.4/docs/source/api_doc/undistort_image.rst +4 -0
  31. pycvcam-1.3.4/docs/source/api_doc/undistort_points.rst +4 -0
  32. pycvcam-1.3.4/docs/source/api_doc/write_transform.rst +4 -0
  33. pycvcam-1.3.4/docs/source/api_doc/zernike_distortion.rst +8 -0
  34. pycvcam-1.3.4/docs/source/conf.py +57 -0
  35. pycvcam-1.3.4/docs/source/index.rst +45 -0
  36. pycvcam-1.3.4/docs/source/installation.rst +31 -0
  37. pycvcam-1.3.4/docs/source/usage.rst +31 -0
  38. pycvcam-1.3.4/examples/compute_rays.py +32 -0
  39. pycvcam-1.3.4/examples/distort_image.py +21 -0
  40. pycvcam-1.3.4/examples/distorted_image.png +0 -0
  41. pycvcam-1.3.4/examples/image.png +0 -0
  42. pycvcam-1.3.4/examples/project_points.py +29 -0
  43. pycvcam-1.3.4/examples/undistort_image.py +21 -0
  44. pycvcam-1.3.4/examples/undistort_points.py +26 -0
  45. pycvcam-1.3.4/examples/undistorted_image.png +0 -0
  46. pycvcam-1.3.4/examples/zernike_transform.json +85 -0
  47. pycvcam-1.3.4/pycvcam/__init__.py +48 -0
  48. pycvcam-1.3.4/pycvcam/__main__.py +39 -0
  49. pycvcam-1.3.4/pycvcam/__version__.py +1 -0
  50. pycvcam-1.3.4/pycvcam/compute_rays.py +202 -0
  51. pycvcam-1.3.4/pycvcam/core/__init__.py +39 -0
  52. pycvcam-1.3.4/pycvcam/core/distortion.py +167 -0
  53. pycvcam-1.3.4/pycvcam/core/extrinsic.py +286 -0
  54. pycvcam-1.3.4/pycvcam/core/intrinsic.py +172 -0
  55. pycvcam-1.3.4/pycvcam/core/package.py +98 -0
  56. pycvcam-1.3.4/pycvcam/core/rays.py +82 -0
  57. pycvcam-1.3.4/pycvcam/core/transform.py +834 -0
  58. pycvcam-1.3.4/pycvcam/core/transform_result.py +186 -0
  59. pycvcam-1.3.4/pycvcam/distort_image.py +358 -0
  60. pycvcam-1.3.4/pycvcam/distortion_objects/__init__.py +13 -0
  61. pycvcam-1.3.4/pycvcam/distortion_objects/cv2_distortion.py +1881 -0
  62. pycvcam-1.3.4/pycvcam/distortion_objects/no_distortion.py +163 -0
  63. pycvcam-1.3.4/pycvcam/distortion_objects/zernike_distortion.py +1059 -0
  64. pycvcam-1.3.4/pycvcam/extrinsic_objects/__init__.py +13 -0
  65. pycvcam-1.3.4/pycvcam/extrinsic_objects/cv2_extrinsic.py +808 -0
  66. pycvcam-1.3.4/pycvcam/extrinsic_objects/no_extrinsic.py +204 -0
  67. pycvcam-1.3.4/pycvcam/intrinsic_objects/__init__.py +13 -0
  68. pycvcam-1.3.4/pycvcam/intrinsic_objects/cv2_intrinsic.py +771 -0
  69. pycvcam-1.3.4/pycvcam/intrinsic_objects/no_intrinsic.py +164 -0
  70. pycvcam-1.3.4/pycvcam/intrinsic_objects/skew_intrinsic.py +820 -0
  71. pycvcam-1.3.4/pycvcam/optimize/__init__.py +20 -0
  72. pycvcam-1.3.4/pycvcam/optimize/optimize_input_points.py +252 -0
  73. pycvcam-1.3.4/pycvcam/optimize/optimize_parameters.py +369 -0
  74. pycvcam-1.3.4/pycvcam/project_points.py +299 -0
  75. pycvcam-1.3.4/pycvcam/read_transform.py +72 -0
  76. pycvcam-1.3.4/pycvcam/resources/__init__.py +13 -0
  77. pycvcam-1.3.4/pycvcam/resources/definition.png +0 -0
  78. pycvcam-1.3.4/pycvcam/resources/definition.rst +35 -0
  79. pycvcam-1.3.4/pycvcam/undistort_image.py +247 -0
  80. pycvcam-1.3.4/pycvcam/undistort_points.py +219 -0
  81. pycvcam-1.3.4/pycvcam/write_transform.py +81 -0
  82. pycvcam-1.3.4/pycvcam.egg-info/PKG-INFO +167 -0
  83. pycvcam-1.3.4/pycvcam.egg-info/SOURCES.txt +93 -0
  84. pycvcam-1.3.4/pycvcam.egg-info/dependency_links.txt +1 -0
  85. pycvcam-1.3.4/pycvcam.egg-info/requires.txt +16 -0
  86. pycvcam-1.3.4/pycvcam.egg-info/top_level.txt +1 -0
  87. pycvcam-1.3.4/pyproject.toml +66 -0
  88. pycvcam-1.3.4/setup.cfg +4 -0
  89. pycvcam-1.3.4/tests/__init__.py +0 -0
  90. pycvcam-1.3.4/tests/test_cv2_distortion.py +101 -0
  91. pycvcam-1.3.4/tests/test_cv2_extrinsic.py +166 -0
  92. pycvcam-1.3.4/tests/test_cv2_intrinsic.py +131 -0
  93. pycvcam-1.3.4/tests/test_package.py +21 -0
  94. pycvcam-1.3.4/tests/test_skew_intrinsic.py +121 -0
  95. pycvcam-1.3.4/tests/test_zernike_distortion.py +151 -0
@@ -0,0 +1,9 @@
1
+ [bumpver]
2
+ current_version = "1.3.4"
3
+ version_pattern = "MAJOR.MINOR.PATCH"
4
+ default_level = "patch"
5
+
6
+ [bumpver.file_patterns]
7
+ "pycvcam/__version__.py" = [
8
+ '__version__ = "{version}"'
9
+ ]
@@ -0,0 +1,41 @@
1
+ name: Deploy Documentation to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ permissions:
9
+ contents: write
10
+ pages: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ deploy:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - name: Checkout the repository
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v4
23
+ with:
24
+ python-version: "3.10"
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install sphinx pydata-sphinx-theme
30
+ pip install .
31
+
32
+ - name: Build documentation
33
+ run: sphinx-build -b html docs/source/ public/
34
+
35
+ - name: Deploy to GitHub Pages
36
+ uses: JamesIves/github-pages-deploy-action@v4
37
+
38
+ with:
39
+ branch: gh-pages
40
+ folder: public
41
+ clean: true
@@ -0,0 +1,30 @@
1
+ # Python cache files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+
7
+ # Virtual environment
8
+ env/
9
+ venv/
10
+ *_pyvenv.cfg
11
+ *.egg-info/
12
+
13
+ # Laboratory
14
+ laboratory/
15
+
16
+ # Sphinx documentation
17
+ build/
18
+
19
+ # Distribution / packaging
20
+ dist/
21
+ *.egg
22
+
23
+ # Jupyter Notebook checkpoints
24
+ .ipynb_checkpoints/
25
+
26
+ # IDE files
27
+ .idea/
28
+ .vscode/
29
+ *.sublime-project
30
+ *.sublime-workspace
@@ -0,0 +1,12 @@
1
+ image: python:3.9
2
+
3
+ before_script:
4
+ - pip install -r requirements.txt
5
+ - pip install sphinx pydata-sphinx-theme
6
+
7
+ pages:
8
+ script:
9
+ - sphinx-build -b html docs/source/ public/
10
+ artifacts:
11
+ paths:
12
+ - public/
pycvcam-1.3.4/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2025 Artezaru
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
pycvcam-1.3.4/Makefile ADDED
@@ -0,0 +1,60 @@
1
+ # 0. Setting default
2
+ SPHINXOPTS ?=
3
+ SPHINXBUILD ?= sphinx-build
4
+ SOURCEDIR = docs/source
5
+ BUILDDIR = docs/build
6
+
7
+ message ?= Default-commit-message
8
+ level ?= patch
9
+
10
+ # 1. Default help command to list available Sphinx options
11
+ help:
12
+ @echo "Available commands:"
13
+ @echo " help - Show this help message"
14
+ @echo " html - Generate HTML documentation with sphinx-build (output at docs/build/html/)"
15
+ @echo " latexpdf - Generate LaTeX PDF documentation with Sphinx sphinx-build (output at docs/build/latex/)"
16
+ @echo " clean - Clean the documentation build directory docs/build/"
17
+ @echo " bump - Update the version of the package (default: patch, use level=major/minor/patch)"
18
+ @echo " git - Commit and push changes to master (use message='Your commit message')"
19
+ @echo " app - Build the application with PyInstaller (output at dist/)"
20
+ @echo " test - Run the tests of the package with pytest"
21
+
22
+ .PHONY: help Makefile
23
+
24
+ # 2. Generate HTML documentation
25
+ html:
26
+ $(SPHINXBUILD) -b html $(SOURCEDIR) $(BUILDDIR)/html
27
+
28
+ # 3. Generate LaTeX PDF documentation
29
+ latexpdf:
30
+ $(SPHINXBUILD) -b latex $(SOURCEDIR) $(BUILDDIR)/latex
31
+ cd $(BUILDDIR)/latex && pdflatex pycvcam.tex && pdflatex pycvcam.tex
32
+
33
+ # 4. Clean the documentation
34
+ clean:
35
+ @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O);
36
+ cd $(BUILDDIR); mkdir -p html; mkdir -p latex
37
+
38
+ # 5. Update the version of the package
39
+ bump:
40
+ bumpver update --$(level) --no-fetch
41
+
42
+ # 6. Git Push origin Master
43
+ git:
44
+ git checkout master
45
+ git add -A .
46
+ git commit -m "$(message)"
47
+ git push origin master
48
+
49
+ # 7. Create the application
50
+ app:
51
+ echo "from pycvcam.__main__ import __main_gui__" > run_gui.py
52
+ echo "__main_gui__()" >> run_gui.py
53
+ pyinstaller --name pycvcam --onefile --windowed run_gui.py
54
+ rm run_gui.py
55
+ rm -rf build
56
+ rm run_gui.spec
57
+
58
+ # 8. Tests the package
59
+ test:
60
+ pytest tests
pycvcam-1.3.4/PKG-INFO ADDED
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: pycvcam
3
+ Version: 1.3.4
4
+ Summary: Python Computer Vision Cameras Operations and Models
5
+ Author-email: Artezaru <artezaru.github@proton.me>
6
+ License: Copyright 2025 Artezaru
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+ Project-URL: Homepage, https://github.com/Artezaru/pycvcam
20
+ Project-URL: Documentation, https://Artezaru.github.io/pycvcam
21
+ Project-URL: Source, https://github.com/Artezaru/pycvcam
22
+ Project-URL: Tracker, https://github.com/Artezaru/pycvcam/issues
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: License :: OSI Approved :: Apache Software License
25
+ Classifier: Operating System :: OS Independent
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: numpy>=1.26
30
+ Requires-Dist: opencv-python-headless>=4.9
31
+ Requires-Dist: scipy>=1.12
32
+ Requires-Dist: pyzernike-polynomials>=2.0.5
33
+ Requires-Dist: py3dframe>=0.2.1
34
+ Provides-Extra: dev
35
+ Requires-Dist: sphinx; extra == "dev"
36
+ Requires-Dist: pydata-sphinx-theme; extra == "dev"
37
+ Requires-Dist: numpydoc; extra == "dev"
38
+ Requires-Dist: pytest; extra == "dev"
39
+ Requires-Dist: pytest-cov; extra == "dev"
40
+ Requires-Dist: bumpver; extra == "dev"
41
+ Requires-Dist: twine; extra == "dev"
42
+ Requires-Dist: wheel; extra == "dev"
43
+ Requires-Dist: build; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # pycvcam
47
+
48
+ ## Description
49
+
50
+ Python Computer Vision Cameras transformations and models.
51
+
52
+ A computer vision camera is modeled by three main components:
53
+
54
+ 1. **Extrinsic**: The transformation from the world coordinate system to the normalized camera coordinate system (`world_points` to `normalized_points`)
55
+ 2. **Distortion**: The transformation from the normalized camera coordinate system to the distorted camera coordinate system (`normalized_points` to `distorted_points`)
56
+ 3. **Intrinsic**: The transformation from the distorted camera coordinate system to the image coordinate system (`distorted_points` to `image_points`)
57
+
58
+ As described in the figure below, the package `pycvcam` uses the following notation:
59
+
60
+ - `world_points`: The 3-D points **X_w** (`(..., 3)`) expressed in the world coordinate system *(Ex, Ey, Ez)*.
61
+ - `normalized_points`: The 2-D points **x_n** (`(..., 2)`) expressed in the normalized camera coordinate system *(I, J)* with a unit distance along the optical axis *(K)*.
62
+ - `distorted_points`: The distorted 2-D points **x_d** (`(..., 2)`) expressed in the normalized camera coordinate system *(I, J)* with a unit distance along the optical axis *(K)*.
63
+ - `image_points`: The 2-D points **x_i** (`(..., 2)`) expressed in the image coordinate system *(ex, ey)* in the sensor plane.
64
+ - `pixel_points`: The 2-D points **x_p** (`(..., 2)`) expressed in the pixel coordinate system *(u, v)* in the matrix of pixels.
65
+
66
+ ![Definition of quantities in pycvcam](./pycvcam/resources/definition.png)
67
+
68
+ To convert the `image_points` to the `pixel_points`, a simple switch of coordinate system can be performed.
69
+
70
+ The package provides several models and extrinsic, distortion, and intrinsic transformations.
71
+
72
+ The functions `project_points`, `compute_rays`, ... can be used to easily process transformations from the 3D world frame of reference to the image plane.
73
+
74
+ ## Examples
75
+
76
+ Create a simple example to project 3D points to 2D image points using the intrinsic and extrinsic parameters of the camera.
77
+
78
+ ```python
79
+ import numpy
80
+ from pycvcam import project_points, Cv2Distortion, Cv2Extrinsic, Cv2Intrinsic
81
+
82
+ # Define the 3D points in the world coordinate system
83
+ world_points = numpy.array([[0.0, 0.0, 5.0],
84
+ [0.1, -0.1, 5.0],
85
+ [-0.1, 0.2, 5.0],
86
+ [0.2, 0.1, 5.0],
87
+ [-0.2, -0.2, 5.0]]) # shape (5, 3)
88
+
89
+ # Define the rotation vector and translation vector
90
+ rvec = numpy.array([0.01, 0.02, 0.03]) # small rotation
91
+ tvec = numpy.array([0.1, -0.1, 0.2]) # small translation
92
+ extrinsic = Cv2Extrinsic.from_rt(rvec, tvec)
93
+
94
+ # Define the intrinsic camera matrix
95
+ K = numpy.array([[1000.0, 0.0, 320.0],
96
+ [0.0, 1000.0, 240.0],
97
+ [0.0, 0.0, 1.0]])
98
+
99
+ intrinsic = Cv2Intrinsic.from_matrix(K)
100
+
101
+ # Define the distortion model (optional)
102
+ distortion = Cv2Distortion(parameters=[0.1, 0.2, 0.3, 0.4, 0.5])
103
+
104
+ # Project the 3D points to 2D image points
105
+ result = project_points(world_points, intrinsic=intrinsic, distortion=distortion, extrinsic=extrinsic)
106
+ print("Projected image points:")
107
+ print(result.image_points) # shape (5, 2)
108
+ ```
109
+
110
+ You can also compute the Jacobians of the image points with respect to the input 3D world points and the projection parameters by setting the **dx** and **dp** parameters to True.
111
+
112
+ ```python
113
+ # Project the 3D points to 2D image points with Jacobians
114
+ result = project_points(world_points, intrinsic=intrinsic, distortion=distortion, extrinsic=extrinsic, dx=True, dp=True)
115
+
116
+ print("Jacobian with respect to 3D points:")
117
+ print(result.jacobian_dx) # shape (5, 2, 3)
118
+
119
+ print("Jacobian with respect to projection parameters:")
120
+ print(result.jacobian_dp) # shape (5, 2, Nparams)
121
+
122
+ print("Jacobian with respect to extrinsic parameters:")
123
+ print(result.jacobian_dextrinsic) # shape (5, 2, Nextrinsic)
124
+
125
+ print("Jacobian with respect to distortion parameters:")
126
+ print(result.jacobian_ddistortion) # shape (5, 2, Ndistortion)
127
+
128
+ print("Jacobian with respect to intrinsic parameters:")
129
+ print(result.jacobian_dintrinsic) # shape (5, 2, Nintrinsic)
130
+ ```
131
+
132
+ ## Authors
133
+
134
+ - Artezaru <artezaru.github@proton.me>
135
+
136
+ - **Git Plateform**: https://github.com/Artezaru/pycvcam.git
137
+ - **Online Documentation**: https://Artezaru.github.io/pycvcam
138
+
139
+ ## Installation
140
+
141
+ Install with pip
142
+
143
+ ```
144
+ pip install git+https://github.com/Artezaru/pycvcam.git
145
+ ```
146
+
147
+ Clone with git
148
+
149
+ ```
150
+ git clone https://github.com/Artezaru/pycvcam.git
151
+ ```
152
+
153
+ ## License
154
+
155
+ Copyright 2025 Artezaru
156
+
157
+ Licensed under the Apache License, Version 2.0 (the "License");
158
+ you may not use this file except in compliance with the License.
159
+ You may obtain a copy of the License at
160
+
161
+ http://www.apache.org/licenses/LICENSE-2.0
162
+
163
+ Unless required by applicable law or agreed to in writing, software
164
+ distributed under the License is distributed on an "AS IS" BASIS,
165
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166
+ See the License for the specific language governing permissions and
167
+ limitations under the License.
@@ -0,0 +1,122 @@
1
+ # pycvcam
2
+
3
+ ## Description
4
+
5
+ Python Computer Vision Cameras transformations and models.
6
+
7
+ A computer vision camera is modeled by three main components:
8
+
9
+ 1. **Extrinsic**: The transformation from the world coordinate system to the normalized camera coordinate system (`world_points` to `normalized_points`)
10
+ 2. **Distortion**: The transformation from the normalized camera coordinate system to the distorted camera coordinate system (`normalized_points` to `distorted_points`)
11
+ 3. **Intrinsic**: The transformation from the distorted camera coordinate system to the image coordinate system (`distorted_points` to `image_points`)
12
+
13
+ As described in the figure below, the package `pycvcam` uses the following notation:
14
+
15
+ - `world_points`: The 3-D points **X_w** (`(..., 3)`) expressed in the world coordinate system *(Ex, Ey, Ez)*.
16
+ - `normalized_points`: The 2-D points **x_n** (`(..., 2)`) expressed in the normalized camera coordinate system *(I, J)* with a unit distance along the optical axis *(K)*.
17
+ - `distorted_points`: The distorted 2-D points **x_d** (`(..., 2)`) expressed in the normalized camera coordinate system *(I, J)* with a unit distance along the optical axis *(K)*.
18
+ - `image_points`: The 2-D points **x_i** (`(..., 2)`) expressed in the image coordinate system *(ex, ey)* in the sensor plane.
19
+ - `pixel_points`: The 2-D points **x_p** (`(..., 2)`) expressed in the pixel coordinate system *(u, v)* in the matrix of pixels.
20
+
21
+ ![Definition of quantities in pycvcam](./pycvcam/resources/definition.png)
22
+
23
+ To convert the `image_points` to the `pixel_points`, a simple switch of coordinate system can be performed.
24
+
25
+ The package provides several models and extrinsic, distortion, and intrinsic transformations.
26
+
27
+ The functions `project_points`, `compute_rays`, ... can be used to easily process transformations from the 3D world frame of reference to the image plane.
28
+
29
+ ## Examples
30
+
31
+ Create a simple example to project 3D points to 2D image points using the intrinsic and extrinsic parameters of the camera.
32
+
33
+ ```python
34
+ import numpy
35
+ from pycvcam import project_points, Cv2Distortion, Cv2Extrinsic, Cv2Intrinsic
36
+
37
+ # Define the 3D points in the world coordinate system
38
+ world_points = numpy.array([[0.0, 0.0, 5.0],
39
+ [0.1, -0.1, 5.0],
40
+ [-0.1, 0.2, 5.0],
41
+ [0.2, 0.1, 5.0],
42
+ [-0.2, -0.2, 5.0]]) # shape (5, 3)
43
+
44
+ # Define the rotation vector and translation vector
45
+ rvec = numpy.array([0.01, 0.02, 0.03]) # small rotation
46
+ tvec = numpy.array([0.1, -0.1, 0.2]) # small translation
47
+ extrinsic = Cv2Extrinsic.from_rt(rvec, tvec)
48
+
49
+ # Define the intrinsic camera matrix
50
+ K = numpy.array([[1000.0, 0.0, 320.0],
51
+ [0.0, 1000.0, 240.0],
52
+ [0.0, 0.0, 1.0]])
53
+
54
+ intrinsic = Cv2Intrinsic.from_matrix(K)
55
+
56
+ # Define the distortion model (optional)
57
+ distortion = Cv2Distortion(parameters=[0.1, 0.2, 0.3, 0.4, 0.5])
58
+
59
+ # Project the 3D points to 2D image points
60
+ result = project_points(world_points, intrinsic=intrinsic, distortion=distortion, extrinsic=extrinsic)
61
+ print("Projected image points:")
62
+ print(result.image_points) # shape (5, 2)
63
+ ```
64
+
65
+ You can also compute the Jacobians of the image points with respect to the input 3D world points and the projection parameters by setting the **dx** and **dp** parameters to True.
66
+
67
+ ```python
68
+ # Project the 3D points to 2D image points with Jacobians
69
+ result = project_points(world_points, intrinsic=intrinsic, distortion=distortion, extrinsic=extrinsic, dx=True, dp=True)
70
+
71
+ print("Jacobian with respect to 3D points:")
72
+ print(result.jacobian_dx) # shape (5, 2, 3)
73
+
74
+ print("Jacobian with respect to projection parameters:")
75
+ print(result.jacobian_dp) # shape (5, 2, Nparams)
76
+
77
+ print("Jacobian with respect to extrinsic parameters:")
78
+ print(result.jacobian_dextrinsic) # shape (5, 2, Nextrinsic)
79
+
80
+ print("Jacobian with respect to distortion parameters:")
81
+ print(result.jacobian_ddistortion) # shape (5, 2, Ndistortion)
82
+
83
+ print("Jacobian with respect to intrinsic parameters:")
84
+ print(result.jacobian_dintrinsic) # shape (5, 2, Nintrinsic)
85
+ ```
86
+
87
+ ## Authors
88
+
89
+ - Artezaru <artezaru.github@proton.me>
90
+
91
+ - **Git Plateform**: https://github.com/Artezaru/pycvcam.git
92
+ - **Online Documentation**: https://Artezaru.github.io/pycvcam
93
+
94
+ ## Installation
95
+
96
+ Install with pip
97
+
98
+ ```
99
+ pip install git+https://github.com/Artezaru/pycvcam.git
100
+ ```
101
+
102
+ Clone with git
103
+
104
+ ```
105
+ git clone https://github.com/Artezaru/pycvcam.git
106
+ ```
107
+
108
+ ## License
109
+
110
+ Copyright 2025 Artezaru
111
+
112
+ Licensed under the Apache License, Version 2.0 (the "License");
113
+ you may not use this file except in compliance with the License.
114
+ You may obtain a copy of the License at
115
+
116
+ http://www.apache.org/licenses/LICENSE-2.0
117
+
118
+ Unless required by applicable law or agreed to in writing, software
119
+ distributed under the License is distributed on an "AS IS" BASIS,
120
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121
+ See the License for the specific language governing permissions and
122
+ limitations under the License.
@@ -0,0 +1,83 @@
1
+ API Reference
2
+ ==============
3
+
4
+ To set the type of the arrays in the package use the :class:`pycvcam.core.Package` class.
5
+
6
+ Transformations
7
+ ----------------
8
+
9
+ The package provides a set of transformations that can be applied to process the transformation from the ``world_points`` to the ``image_points``.
10
+ The structure of objects is given by the abstract classes stored in the ``pycvcam.core`` module.
11
+
12
+ .. toctree::
13
+ :maxdepth: 1
14
+ :caption: pycvcam.core:
15
+
16
+ ./api_doc/package.rst
17
+ ./api_doc/transform.rst
18
+ ./api_doc/transform_result.rst
19
+ ./api_doc/intrinsic.rst
20
+ ./api_doc/distortion.rst
21
+ ./api_doc/extrinsic.rst
22
+ ./api_doc/rays.rst
23
+
24
+ Some default ``Extrinsic``, ``Intrinsic``, and ``Distortion`` objects are provided in the package.
25
+
26
+ .. toctree::
27
+ :maxdepth: 1
28
+ :caption: Extrinsic Models:
29
+
30
+ ./api_doc/cv2_extrinsic.rst
31
+ ./api_doc/no_extrinsic.rst
32
+
33
+ .. toctree::
34
+ :maxdepth: 1
35
+ :caption: Intrinsic Models:
36
+
37
+ ./api_doc/cv2_intrinsic.rst
38
+ ./api_doc/skew_intrinsic.rst
39
+ ./api_doc/no_intrinsic.rst
40
+
41
+ .. toctree::
42
+ :maxdepth: 1
43
+ :caption: Distortion Models:
44
+
45
+ ./api_doc/cv2_distortion.rst
46
+ ./api_doc/zernike_distortion.rst
47
+ ./api_doc/no_distortion.rst
48
+
49
+
50
+
51
+ Transformation processes
52
+ -------------------------
53
+
54
+ The package provides a set of transformation processes that can be used to apply the transformations to the points.
55
+
56
+ .. toctree::
57
+ :maxdepth: 1
58
+ :caption: Transformation Processes:
59
+
60
+ ./api_doc/undistort_image.rst
61
+ ./api_doc/undistort_points.rst
62
+ ./api_doc/project_points.rst
63
+ ./api_doc/compute_rays.rst
64
+ ./api_doc/distort_image.rst
65
+ ./api_doc/read_transform.rst
66
+ ./api_doc/write_transform.rst
67
+
68
+
69
+ Optimisation processes
70
+ ----------------------
71
+
72
+ The package provides a set of optimisation processes that can be used to estimate the parameters of the transformations.
73
+ The optimisations are located in the ``pycvcam.optimize`` module.
74
+
75
+ .. toctree::
76
+ :maxdepth: 1
77
+ :caption: Optimisation Processes:
78
+
79
+ ./api_doc/optimize_parameters.rst
80
+ ./api_doc/optimize_input_points.rst
81
+
82
+
83
+
@@ -0,0 +1,5 @@
1
+ pycvcam.compute_rays
2
+ =================================
3
+
4
+
5
+ .. autofunction:: pycvcam.compute_rays
@@ -0,0 +1,8 @@
1
+ pycvcam.Cv2Distortion
2
+ ========================
3
+
4
+ .. autoclass:: pycvcam.Cv2Distortion
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
@@ -0,0 +1,8 @@
1
+ pycvcam.Cv2Extrinsic
2
+ =============================
3
+
4
+ .. autoclass:: pycvcam.Cv2Extrinsic
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
@@ -0,0 +1,8 @@
1
+ pycvcam.Cv2Intrinsic
2
+ =====================
3
+
4
+ .. autoclass:: pycvcam.Cv2Intrinsic
5
+ :members:
6
+ :private-members:
7
+ :undoc-members:
8
+ :show-inheritance:
@@ -0,0 +1,4 @@
1
+ pycvcam.distort_image
2
+ ==================================
3
+
4
+ .. autofunction:: pycvcam.distort_image
@@ -0,0 +1,10 @@
1
+ pycvcam.core.Distortion
2
+ =============================
3
+
4
+ .. autoclass:: pycvcam.core.Distortion
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
9
+
10
+
@@ -0,0 +1,10 @@
1
+ pycvcam.core.Extrinsic
2
+ =============================
3
+
4
+ .. autoclass:: pycvcam.core.Extrinsic
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
9
+
10
+
@@ -0,0 +1,10 @@
1
+ pycvcam.core.Intrinsic
2
+ =============================
3
+
4
+ .. autoclass:: pycvcam.core.Intrinsic
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
9
+
10
+
@@ -0,0 +1,8 @@
1
+ pycvcam.NoDistortion
2
+ ========================
3
+
4
+ .. autoclass:: pycvcam.NoDistortion
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
@@ -0,0 +1,8 @@
1
+ pycvcam.NoExtrinsic
2
+ =============================
3
+
4
+ .. autoclass:: pycvcam.NoExtrinsic
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
@@ -0,0 +1,8 @@
1
+ pycvcam.NoIntrinsic
2
+ =====================
3
+
4
+ .. autoclass:: pycvcam.NoIntrinsic
5
+ :members:
6
+ :private-members:
7
+ :undoc-members:
8
+ :show-inheritance:
@@ -0,0 +1,4 @@
1
+ pycvcam.optimize.optimize_input_points
2
+ =============================================
3
+
4
+ .. autofunction:: pycvcam.optimize.optimize_input_points.optimize_input_points
@@ -0,0 +1,4 @@
1
+ pycvcam.optimize.optimize_parameters
2
+ =============================================
3
+
4
+ .. autofunction:: pycvcam.optimize.optimize_parameters.optimize_parameters
@@ -0,0 +1,8 @@
1
+ pycvcam.core.Package
2
+ =============================
3
+
4
+ .. autoclass:: pycvcam.core.Package
5
+ :members:
6
+ :undoc-members:
7
+ :private-members:
8
+ :show-inheritance:
@@ -0,0 +1,5 @@
1
+ pycvcam.project_points
2
+ ==========================
3
+
4
+ .. autofunction:: pycvcam.project_points
5
+