camera-client 0.1.2__tar.gz → 0.2.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.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camera-client
3
- Version: 0.1.2
4
- Summary: Python SDK for camera calibration projection data - transform between distorted, corrected, and world coordinates.
3
+ Version: 0.2.0
4
+ Summary: Python SDK for camera calibration and projection transformations - handle lens distortion, coordinate transformations, and 3D ray casting with symbolic expressions.
5
5
  Author-email: Alexander Abramov <extremal.ru@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/avabr/camera-client
8
8
  Project-URL: Repository, https://github.com/avabr/camera-client
9
9
  Project-URL: Issues, https://github.com/avabr/camera-client/issues
10
- Keywords: camera,calibration,projection,3d,mathematics
10
+ Keywords: camera,calibration,projection,3d,ray-casting,computer-vision,lens-distortion,coordinate-transformation,sympy
11
11
  Classifier: Development Status :: 3 - Alpha
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Intended Audience :: Science/Research
@@ -25,6 +25,7 @@ Requires-Python: >=3.7
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
27
  Requires-Dist: numpy>=1.20.0
28
+ Requires-Dist: sympy>=1.10.0
28
29
  Dynamic: license-file
29
30
 
30
31
  # camera-client
@@ -37,6 +38,8 @@ Python SDK for camera calibration and projection transformations. Transform coor
37
38
  - **Multiple coordinate systems** - Transform between source (distorted), corrected, and ground (3D world) coordinates
38
39
  - **Lens distortion handling** - Correct for camera lens distortion using calibration lookup tables
39
40
  - **Ground plane projection** - Project image coordinates to 3D world coordinates and vice versa
41
+ - **Ray casting** - Generate 3D rays from image coordinates for ray tracing and 3D reconstruction
42
+ - **Sympy-based transformations** - Fast compiled symbolic expressions for mathematical transformations
40
43
  - **NumPy-based** - Fast array operations with minimal dependencies
41
44
 
42
45
  ## Installation
@@ -56,12 +59,13 @@ from camera_client import CameraProjection
56
59
  # Load camera calibration data from NPZ archive
57
60
  camera = CameraProjection.load("camera_calibration.npz")
58
61
 
59
- # Transform single or multiple points (vectorized operations)
62
+ # Transform multiple points (vectorized operations)
63
+ # Note: All methods require (N, 2) or (N, 3) shaped arrays
60
64
  source_points = np.array([
61
65
  [100, 200],
62
66
  [300, 400],
63
67
  [500, 600]
64
- ])
68
+ ]) # Shape: (3, 2)
65
69
 
66
70
  # Remove lens distortion
67
71
  corrected_points = camera.src_to_ctd(source_points)
@@ -158,6 +162,28 @@ corrected = camera.src_to_ctd(random_points)
158
162
  ground = camera.src_to_gnd(random_points, h=0)
159
163
  ```
160
164
 
165
+ ### Ray Casting (3D Reconstruction)
166
+
167
+ ```python
168
+ # Get 3D rays from image points (useful for ray tracing, 3D reconstruction)
169
+ src_points = np.array([[640, 480], [800, 600]])
170
+
171
+ # Get ray directions from source (distorted) coordinates
172
+ rays = camera.src_to_ray(src_points)
173
+ print(rays.shape) # (2, 3) - normalized direction vectors
174
+
175
+ # Or from corrected coordinates
176
+ ctd_points = camera.src_to_ctd(src_points)
177
+ rays = camera.ctd_to_ray(ctd_points)
178
+
179
+ # Get camera position in world space (ray origin)
180
+ key_point = camera.get_key_point()
181
+ print(key_point.shape) # (3, 1) - [x, y, z] camera position
182
+
183
+ # Ray equation: point_on_ray = key_point + t * ray_direction
184
+ # All rays are normalized to unit length
185
+ ```
186
+
161
187
  ### Accessing Camera Properties
162
188
 
163
189
  ```python
@@ -186,10 +212,12 @@ Load camera calibration from NPZ file.
186
212
  Transform from source (distorted) to corrected coordinates.
187
213
 
188
214
  **Parameters:**
189
- - `points` (np.ndarray): Shape (N, 2) array of [x, y] coordinates
215
+ - `points` (np.ndarray): Shape **(N, 2)** array of [x, y] coordinates
190
216
 
191
217
  **Returns:**
192
- - `np.ndarray`: Shape (N, 2) corrected coordinates
218
+ - `np.ndarray`: Shape **(N, 2)** corrected coordinates
219
+
220
+ **Note:** Input must be 2D array. For single point use `np.array([[x, y]])`
193
221
 
194
222
  ---
195
223
 
@@ -253,21 +281,67 @@ Transform from 3D ground coordinates to corrected coordinates.
253
281
  **Returns:**
254
282
  - `np.ndarray`: Shape (N, 2) corrected coordinates
255
283
 
284
+ ---
285
+
286
+ ### `src_to_ray(points)`
287
+
288
+ Generate 3D ray directions from source (distorted) image coordinates.
289
+
290
+ **Parameters:**
291
+ - `points` (np.ndarray): Shape (N, 2) array of [x, y] coordinates
292
+
293
+ **Returns:**
294
+ - `np.ndarray`: Shape (N, 3) normalized ray direction vectors
295
+
296
+ **Note:** All rays originate from the camera key-point (use `get_key_point()`)
297
+
298
+ ---
299
+
300
+ ### `ctd_to_ray(points)`
301
+
302
+ Generate 3D ray directions from corrected (undistorted) image coordinates.
303
+
304
+ **Parameters:**
305
+ - `points` (np.ndarray): Shape (N, 2) array of [x, y] coordinates
306
+
307
+ **Returns:**
308
+ - `np.ndarray`: Shape (N, 3) normalized ray direction vectors
309
+
310
+ ---
311
+
312
+ ### `get_key_point()`
313
+
314
+ Get the camera position (key-point) in world space.
315
+
316
+ **Returns:**
317
+ - `np.ndarray`: Shape (3, 1) array with [x, y, z] camera position
318
+
256
319
  ## Calibration File Format
257
320
 
258
321
  The calibration file is a NumPy `.npz` archive containing:
259
322
 
260
- - `src2ctd`: Lookup table for source to corrected transformation (H x W x 2)
261
- - `ctd2src`: Lookup table for corrected to source transformation (H x W x 2)
262
- - `x_gnd`, `y_gnd`, `z_gnd`: Expression strings for corrected to ground transformation
263
- - `x_im`, `y_im`: Expression strings for ground to corrected transformation
264
- - `im_width`, `im_height`: Image dimensions
265
- - `plan_scale`: Scale factor for ground plane
323
+ ### Lookup Tables
324
+ - `src2ctd`: Source to corrected coordinate map (H x W x 2)
325
+ - `ctd2src`: Corrected to source coordinate map (H x W x 2)
326
+ - `map_scale_h`: Height scale values (H x W)
327
+ - `map_scale_w`: Width scale values (H x W)
328
+ - `map_scale_vang`: Vertical angle values (H x W)
329
+
330
+ ### Symbolic Expressions (stored as strings, parsed with SymPy)
331
+ - `exp_im2gnd`: Image to ground coordinate transformation
332
+ - `exp_gnd2im`: Ground to image coordinate transformation
333
+ - `exp_key_point`: Camera key-point (position) in world space
334
+ - `exp_im2ray`: Image to ray direction transformation
335
+
336
+ ### Metadata
337
+ - `im_width`, `im_height`: Image dimensions in pixels
338
+ - `plan_scale`: Scale factor for ground plane coordinates (pixels per meter)
266
339
 
267
340
  ## Requirements
268
341
 
269
342
  - Python >= 3.7
270
343
  - NumPy >= 1.20.0
344
+ - SymPy >= 1.10.0
271
345
 
272
346
  ## Links
273
347
 
@@ -282,3 +356,8 @@ MIT License - see [LICENSE](LICENSE) file for details.
282
356
  ## Author
283
357
 
284
358
  Alexander Abramov ([extremal.ru@gmail.com](mailto:extremal.ru@gmail.com))
359
+
360
+ ## Upload PyPi
361
+
362
+ rm dist/* && python -m build && python -m twine upload dist/*
363
+
@@ -8,6 +8,8 @@ Python SDK for camera calibration and projection transformations. Transform coor
8
8
  - **Multiple coordinate systems** - Transform between source (distorted), corrected, and ground (3D world) coordinates
9
9
  - **Lens distortion handling** - Correct for camera lens distortion using calibration lookup tables
10
10
  - **Ground plane projection** - Project image coordinates to 3D world coordinates and vice versa
11
+ - **Ray casting** - Generate 3D rays from image coordinates for ray tracing and 3D reconstruction
12
+ - **Sympy-based transformations** - Fast compiled symbolic expressions for mathematical transformations
11
13
  - **NumPy-based** - Fast array operations with minimal dependencies
12
14
 
13
15
  ## Installation
@@ -27,12 +29,13 @@ from camera_client import CameraProjection
27
29
  # Load camera calibration data from NPZ archive
28
30
  camera = CameraProjection.load("camera_calibration.npz")
29
31
 
30
- # Transform single or multiple points (vectorized operations)
32
+ # Transform multiple points (vectorized operations)
33
+ # Note: All methods require (N, 2) or (N, 3) shaped arrays
31
34
  source_points = np.array([
32
35
  [100, 200],
33
36
  [300, 400],
34
37
  [500, 600]
35
- ])
38
+ ]) # Shape: (3, 2)
36
39
 
37
40
  # Remove lens distortion
38
41
  corrected_points = camera.src_to_ctd(source_points)
@@ -129,6 +132,28 @@ corrected = camera.src_to_ctd(random_points)
129
132
  ground = camera.src_to_gnd(random_points, h=0)
130
133
  ```
131
134
 
135
+ ### Ray Casting (3D Reconstruction)
136
+
137
+ ```python
138
+ # Get 3D rays from image points (useful for ray tracing, 3D reconstruction)
139
+ src_points = np.array([[640, 480], [800, 600]])
140
+
141
+ # Get ray directions from source (distorted) coordinates
142
+ rays = camera.src_to_ray(src_points)
143
+ print(rays.shape) # (2, 3) - normalized direction vectors
144
+
145
+ # Or from corrected coordinates
146
+ ctd_points = camera.src_to_ctd(src_points)
147
+ rays = camera.ctd_to_ray(ctd_points)
148
+
149
+ # Get camera position in world space (ray origin)
150
+ key_point = camera.get_key_point()
151
+ print(key_point.shape) # (3, 1) - [x, y, z] camera position
152
+
153
+ # Ray equation: point_on_ray = key_point + t * ray_direction
154
+ # All rays are normalized to unit length
155
+ ```
156
+
132
157
  ### Accessing Camera Properties
133
158
 
134
159
  ```python
@@ -157,10 +182,12 @@ Load camera calibration from NPZ file.
157
182
  Transform from source (distorted) to corrected coordinates.
158
183
 
159
184
  **Parameters:**
160
- - `points` (np.ndarray): Shape (N, 2) array of [x, y] coordinates
185
+ - `points` (np.ndarray): Shape **(N, 2)** array of [x, y] coordinates
161
186
 
162
187
  **Returns:**
163
- - `np.ndarray`: Shape (N, 2) corrected coordinates
188
+ - `np.ndarray`: Shape **(N, 2)** corrected coordinates
189
+
190
+ **Note:** Input must be 2D array. For single point use `np.array([[x, y]])`
164
191
 
165
192
  ---
166
193
 
@@ -224,21 +251,67 @@ Transform from 3D ground coordinates to corrected coordinates.
224
251
  **Returns:**
225
252
  - `np.ndarray`: Shape (N, 2) corrected coordinates
226
253
 
254
+ ---
255
+
256
+ ### `src_to_ray(points)`
257
+
258
+ Generate 3D ray directions from source (distorted) image coordinates.
259
+
260
+ **Parameters:**
261
+ - `points` (np.ndarray): Shape (N, 2) array of [x, y] coordinates
262
+
263
+ **Returns:**
264
+ - `np.ndarray`: Shape (N, 3) normalized ray direction vectors
265
+
266
+ **Note:** All rays originate from the camera key-point (use `get_key_point()`)
267
+
268
+ ---
269
+
270
+ ### `ctd_to_ray(points)`
271
+
272
+ Generate 3D ray directions from corrected (undistorted) image coordinates.
273
+
274
+ **Parameters:**
275
+ - `points` (np.ndarray): Shape (N, 2) array of [x, y] coordinates
276
+
277
+ **Returns:**
278
+ - `np.ndarray`: Shape (N, 3) normalized ray direction vectors
279
+
280
+ ---
281
+
282
+ ### `get_key_point()`
283
+
284
+ Get the camera position (key-point) in world space.
285
+
286
+ **Returns:**
287
+ - `np.ndarray`: Shape (3, 1) array with [x, y, z] camera position
288
+
227
289
  ## Calibration File Format
228
290
 
229
291
  The calibration file is a NumPy `.npz` archive containing:
230
292
 
231
- - `src2ctd`: Lookup table for source to corrected transformation (H x W x 2)
232
- - `ctd2src`: Lookup table for corrected to source transformation (H x W x 2)
233
- - `x_gnd`, `y_gnd`, `z_gnd`: Expression strings for corrected to ground transformation
234
- - `x_im`, `y_im`: Expression strings for ground to corrected transformation
235
- - `im_width`, `im_height`: Image dimensions
236
- - `plan_scale`: Scale factor for ground plane
293
+ ### Lookup Tables
294
+ - `src2ctd`: Source to corrected coordinate map (H x W x 2)
295
+ - `ctd2src`: Corrected to source coordinate map (H x W x 2)
296
+ - `map_scale_h`: Height scale values (H x W)
297
+ - `map_scale_w`: Width scale values (H x W)
298
+ - `map_scale_vang`: Vertical angle values (H x W)
299
+
300
+ ### Symbolic Expressions (stored as strings, parsed with SymPy)
301
+ - `exp_im2gnd`: Image to ground coordinate transformation
302
+ - `exp_gnd2im`: Ground to image coordinate transformation
303
+ - `exp_key_point`: Camera key-point (position) in world space
304
+ - `exp_im2ray`: Image to ray direction transformation
305
+
306
+ ### Metadata
307
+ - `im_width`, `im_height`: Image dimensions in pixels
308
+ - `plan_scale`: Scale factor for ground plane coordinates (pixels per meter)
237
309
 
238
310
  ## Requirements
239
311
 
240
312
  - Python >= 3.7
241
313
  - NumPy >= 1.20.0
314
+ - SymPy >= 1.10.0
242
315
 
243
316
  ## Links
244
317
 
@@ -253,3 +326,8 @@ MIT License - see [LICENSE](LICENSE) file for details.
253
326
  ## Author
254
327
 
255
328
  Alexander Abramov ([extremal.ru@gmail.com](mailto:extremal.ru@gmail.com))
329
+
330
+ ## Upload PyPi
331
+
332
+ rm dist/* && python -m build && python -m twine upload dist/*
333
+