camera-client 0.2.6__tar.gz → 0.2.8__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camera-client
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
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
@@ -60,8 +60,18 @@ python -m camera_client get_camera_archive https://example.com/camera.npz
60
60
 
61
61
  # Download from file with URLs (one per line, non-URL lines ignored)
62
62
  python -m camera_client get_camera_archive -f urls.txt -o ./archives
63
+
64
+ # Download from JSON config (list of objects with "archive_url" or "camera_uuid" key)
65
+ python -m camera_client get_camera_archive -f config.json -o ./archives
66
+
67
+ # Download only specific camera from JSON config
68
+ python -m camera_client get_camera_archive -f config.json --camera_id=66 -o ./archives
63
69
  ```
64
70
 
71
+ JSON config entries may use `"archive_url"` (direct link) or `"camera_uuid"` (requires
72
+ `CAMERA_SERVICE_ENTRYPOINT` env variable — the URL is constructed as
73
+ `<CAMERA_SERVICE_ENTRYPOINT>/processing_api/projection_npz_archive/<camera_uuid>`).
74
+
65
75
  ## Quick Start
66
76
 
67
77
  ```python
@@ -30,8 +30,18 @@ python -m camera_client get_camera_archive https://example.com/camera.npz
30
30
 
31
31
  # Download from file with URLs (one per line, non-URL lines ignored)
32
32
  python -m camera_client get_camera_archive -f urls.txt -o ./archives
33
+
34
+ # Download from JSON config (list of objects with "archive_url" or "camera_uuid" key)
35
+ python -m camera_client get_camera_archive -f config.json -o ./archives
36
+
37
+ # Download only specific camera from JSON config
38
+ python -m camera_client get_camera_archive -f config.json --camera_id=66 -o ./archives
33
39
  ```
34
40
 
41
+ JSON config entries may use `"archive_url"` (direct link) or `"camera_uuid"` (requires
42
+ `CAMERA_SERVICE_ENTRYPOINT` env variable — the URL is constructed as
43
+ `<CAMERA_SERVICE_ENTRYPOINT>/processing_api/projection_npz_archive/<camera_uuid>`).
44
+
35
45
  ## Quick Start
36
46
 
37
47
  ```python
@@ -1,6 +1,7 @@
1
1
  """Command-line interface for camera-client package."""
2
2
 
3
3
  import argparse
4
+ import json
4
5
  import os
5
6
  import sys
6
7
  from pathlib import Path
@@ -84,24 +85,59 @@ def download_archive(url: str, output_dir: str = ".", silent: bool = False) -> b
84
85
  return False
85
86
 
86
87
 
87
- def download_from_file(file_path: str, output_dir: str = ".") -> None:
88
+ def download_from_file(file_path: str, output_dir: str = ".", camera_id: int = None) -> None:
88
89
  """
89
- Download multiple camera calibration archives from URLs listed in a file.
90
+ Download camera calibration archives from a .txt file with URLs or a .json config.
90
91
 
91
- Non-URL lines (comments, notes, etc.) are automatically skipped.
92
+ For .txt files: one URL per line, non-URL lines are ignored.
93
+ For .json files: expects a list of objects with "archive_url" key.
94
+ Optionally filter by camera_id.
92
95
 
93
96
  Args:
94
- file_path: Path to file containing URLs (one per line, non-URL lines are ignored)
97
+ file_path: Path to .txt or .json file
95
98
  output_dir: Directory to save the downloaded files (default: current directory)
99
+ camera_id: If provided, only download archives for this camera_id (JSON only)
96
100
  """
97
101
  try:
98
- with open(file_path, 'r') as f:
99
- # Filter only lines that are valid URLs
100
- urls = [line.strip() for line in f if is_url(line)]
102
+ if file_path.endswith('.json'):
103
+ with open(file_path, 'r') as f:
104
+ configs = json.load(f)
105
+
106
+ if not isinstance(configs, list):
107
+ configs = [configs]
108
+
109
+ if camera_id is not None:
110
+ configs = [c for c in configs if c.get('camera_id') == camera_id]
111
+
112
+ urls = []
113
+ for c in configs:
114
+ if 'archive_url' in c:
115
+ urls.append(c['archive_url'])
116
+ elif 'camera_uuid' in c:
117
+ entrypoint = os.environ.get('CAMERA_SERVICE_ENTRYPOINT')
118
+ if not entrypoint:
119
+ print(
120
+ "Error: CAMERA_SERVICE_ENTRYPOINT environment variable is required "
121
+ f"for camera_uuid-based entries (camera_id={c.get('camera_id')})",
122
+ file=sys.stderr
123
+ )
124
+ sys.exit(1)
125
+ url = f"{entrypoint.rstrip('/')}/processing_api/projection_npz_archive/{c['camera_uuid']}"
126
+ urls.append(url)
127
+
128
+ if not urls:
129
+ msg = f"No matching entries found in {file_path}"
130
+ if camera_id is not None:
131
+ msg += f" for camera_id={camera_id}"
132
+ print(msg, file=sys.stderr)
133
+ sys.exit(1)
134
+ else:
135
+ with open(file_path, 'r') as f:
136
+ urls = [line.strip() for line in f if is_url(line)]
101
137
 
102
- if not urls:
103
- print(f"No URLs found in {file_path}", file=sys.stderr)
104
- sys.exit(1)
138
+ if not urls:
139
+ print(f"No URLs found in {file_path}", file=sys.stderr)
140
+ sys.exit(1)
105
141
 
106
142
  print(f"Found {len(urls)} URL(s) in {file_path}")
107
143
  print(f"Downloading to: {output_dir}\n")
@@ -127,6 +163,9 @@ def download_from_file(file_path: str, output_dir: str = ".") -> None:
127
163
  except FileNotFoundError:
128
164
  print(f"Error: File not found: {file_path}", file=sys.stderr)
129
165
  sys.exit(1)
166
+ except (json.JSONDecodeError, KeyError) as e:
167
+ print(f"Error parsing JSON file {file_path}: {e}", file=sys.stderr)
168
+ sys.exit(1)
130
169
  except Exception as e:
131
170
  print(f"Error reading file {file_path}: {e}", file=sys.stderr)
132
171
  sys.exit(1)
@@ -160,6 +199,12 @@ def main():
160
199
  default='.',
161
200
  help='Output directory (default: current directory)'
162
201
  )
202
+ download_parser.add_argument(
203
+ '--camera_id',
204
+ type=int,
205
+ default=None,
206
+ help='Filter by camera_id (only used with JSON config files)'
207
+ )
163
208
 
164
209
  args = parser.parse_args()
165
210
 
@@ -175,7 +220,7 @@ def main():
175
220
 
176
221
  # Process based on input type
177
222
  if args.file:
178
- download_from_file(args.file, args.output_dir)
223
+ download_from_file(args.file, args.output_dir, camera_id=args.camera_id)
179
224
  else:
180
225
  success = download_archive(args.url, args.output_dir)
181
226
  sys.exit(0 if success else 1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: camera-client
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
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
@@ -60,8 +60,18 @@ python -m camera_client get_camera_archive https://example.com/camera.npz
60
60
 
61
61
  # Download from file with URLs (one per line, non-URL lines ignored)
62
62
  python -m camera_client get_camera_archive -f urls.txt -o ./archives
63
+
64
+ # Download from JSON config (list of objects with "archive_url" or "camera_uuid" key)
65
+ python -m camera_client get_camera_archive -f config.json -o ./archives
66
+
67
+ # Download only specific camera from JSON config
68
+ python -m camera_client get_camera_archive -f config.json --camera_id=66 -o ./archives
63
69
  ```
64
70
 
71
+ JSON config entries may use `"archive_url"` (direct link) or `"camera_uuid"` (requires
72
+ `CAMERA_SERVICE_ENTRYPOINT` env variable — the URL is constructed as
73
+ `<CAMERA_SERVICE_ENTRYPOINT>/processing_api/projection_npz_archive/<camera_uuid>`).
74
+
65
75
  ## Quick Start
66
76
 
67
77
  ```python
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "camera-client"
7
- version = "0.2.6"
7
+ version = "0.2.8"
8
8
  description = "Python SDK for camera calibration and projection transformations - handle lens distortion, coordinate transformations, and 3D ray casting with symbolic expressions."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
File without changes
File without changes
File without changes
File without changes