asmagic 0.1.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.
asmagic-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shenzhen AncoraSpring Robotics Technology Co., Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Include only necessary documentation
2
+ include README.md
3
+ include LICENSE
4
+
5
+ # Include type hints
6
+ include asmagic/py.typed
7
+
8
+ # Include proto files
9
+ recursive-include asmagic/proto *.py
10
+
11
+ # Exclude unnecessary files
12
+ global-exclude __pycache__
13
+ global-exclude *.py[co]
14
+ global-exclude .DS_Store
15
+ exclude *.egg-info
16
+
17
+ # Exclude tutorial and guide files (not needed in package)
18
+ exclude 新手上传PyPI教程.md
19
+ exclude 超简单上传命令.md
20
+ exclude 依赖说明.md
21
+ exclude PUBLISH_TO_PYPI.md
22
+ exclude QUICK_PUBLISH.md
23
+ exclude README_PUBLISH.md
24
+ exclude HIGH_FPS_GUIDE.md
25
+ exclude IDE_SETUP.md
26
+ exclude IMAGE_DISPLAY_GUIDE.md
27
+ exclude SIMPLE_API_GUIDE.md
28
+ exclude TYPE_HINTS_DEMO.md
29
+ exclude USAGE_SIMPLE.md
30
+ exclude publish.sh
31
+ exclude test_type_hints.py
32
+
33
+ # Exclude examples directory (users can see them on GitHub)
34
+ recursive-exclude examples *
35
+
asmagic-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.1
2
+ Name: asmagic
3
+ Version: 0.1.0
4
+ Summary: AR Sensor Data Magic Library - Subscribe to AR sensor data streams
5
+ Author: ASMagic Team
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/asmagic/asmagic
8
+ Project-URL: Documentation, https://github.com/asmagic/asmagic#readme
9
+ Project-URL: Repository, https://github.com/asmagic/asmagic
10
+ Project-URL: Issues, https://github.com/asmagic/asmagic/issues
11
+ Keywords: ar,sensor,zmq,protobuf,streaming
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: numpy>=1.20.0
27
+ Requires-Dist: pyzmq>=22.0.0
28
+ Requires-Dist: protobuf>=4.0.0
29
+ Provides-Extra: image
30
+ Requires-Dist: opencv-python>=4.5.0; extra == "image"
31
+ Requires-Dist: Pillow>=8.0.0; extra == "image"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
34
+ Requires-Dist: black>=22.0.0; extra == "dev"
35
+ Requires-Dist: mypy>=0.990; extra == "dev"
36
+ Provides-Extra: all
37
+ Requires-Dist: opencv-python>=4.5.0; extra == "all"
38
+ Requires-Dist: Pillow>=8.0.0; extra == "all"
39
+
40
+ # asmagic
41
+
42
+ A lightweight Python library for subscribing to AR sensor data streams via ZeroMQ.
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install asmagic
48
+ ```
49
+
50
+ For image display support:
51
+
52
+ ```bash
53
+ pip install asmagic[image]
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ ```python
59
+ from asmagic import ARDataSubscriber
60
+
61
+ # Create subscriber
62
+ sub = ARDataSubscriber("192.168.1.100")
63
+
64
+ # Get data frame
65
+ data = sub.get()
66
+ if data:
67
+ print(data.timestamp)
68
+ print(data.velocity)
69
+ print(data.local_pose)
70
+ print(data.camera_intrinsics)
71
+
72
+ sub.close()
73
+ ```
74
+
75
+ ## Usage
76
+
77
+ ### Continuous Data Streaming
78
+
79
+ ```python
80
+ from asmagic import ARDataSubscriber
81
+
82
+ sub = ARDataSubscriber("192.168.1.100")
83
+
84
+ try:
85
+ while True:
86
+ data = sub.get()
87
+ if data:
88
+ print(f"Velocity: {data.velocity}")
89
+ print(f"Local pose: {data.local_pose}")
90
+ print(f"Timestamp: {data.timestamp}")
91
+ except KeyboardInterrupt:
92
+ pass
93
+ finally:
94
+ sub.close()
95
+ ```
96
+
97
+ ### Image Display
98
+
99
+ Requires `opencv-python` and `Pillow`:
100
+
101
+ ```bash
102
+ pip install asmagic[image]
103
+ ```
104
+
105
+ ```python
106
+ from asmagic import ARDataSubscriber
107
+ import cv2
108
+
109
+ sub = ARDataSubscriber("192.168.1.100")
110
+
111
+ try:
112
+ while True:
113
+ data = sub.get()
114
+ if data:
115
+ # Display both color and depth images
116
+ data.show_images()
117
+
118
+ # Or display individually
119
+ # data.show_color()
120
+ # data.show_depth()
121
+
122
+ if cv2.waitKey(1) == 27: # ESC to exit
123
+ break
124
+ finally:
125
+ sub.close()
126
+ cv2.destroyAllWindows()
127
+ ```
128
+
129
+ ### Accessing Individual Fields
130
+
131
+ ```python
132
+ from asmagic import ARDataSubscriber
133
+
134
+ sub = ARDataSubscriber("192.168.1.100")
135
+
136
+ # Get specific data
137
+ velocity = sub.get_velocity()
138
+ pose = sub.get_local_pose()
139
+ timestamp = sub.get_timestamp()
140
+
141
+ sub.close()
142
+ ```
143
+
144
+ ## API Reference
145
+
146
+ ### ARDataSubscriber
147
+
148
+ **Constructor:**
149
+
150
+ ```python
151
+ ARDataSubscriber(ip, port=8000, hwm=1, conflate=True, verbose=False)
152
+ ```
153
+
154
+ **Parameters:**
155
+
156
+ - `ip` (str): IP address of the AR device
157
+ - `port` (int): Port number (default: 8000)
158
+ - `hwm` (int): High water mark for ZMQ socket (default: 1)
159
+ - `conflate` (bool): Enable message conflation (default: True)
160
+ - `verbose` (bool): Print connection info (default: False)
161
+
162
+ **Methods:**
163
+
164
+ | Method | Returns | Description |
165
+ | ------------------------------------- | ---------------------- | --------------------- |
166
+ | `get(timeout=1000)` | `ARFrame` or `None` | Get latest data frame |
167
+ | `get_timestamp(timeout=1000)` | `float` or `None` | Get timestamp |
168
+ | `get_velocity(timeout=1000)` | `np.ndarray` or `None` | Get velocity |
169
+ | `get_local_pose(timeout=1000)` | `np.ndarray` or `None` | Get local pose |
170
+ | `get_global_pose(timeout=1000)` | `np.ndarray` or `None` | Get global pose |
171
+ | `get_camera_intrinsics(timeout=1000)` | `np.ndarray` or `None` | Get camera intrinsics |
172
+ | `get_color_image(timeout=1000)` | `bytes` or `None` | Get color image bytes |
173
+ | `get_depth_image(timeout=1000)` | `np.ndarray` or `None` | Get depth image array |
174
+ | `close()` | `None` | Close connection |
175
+
176
+ ### ARFrame
177
+
178
+ Data object returned by `get()`:
179
+
180
+ **Properties:**
181
+
182
+ | Property | Type | Description |
183
+ | ------------------- | ------------ | -------------------------------- |
184
+ | `timestamp` | `float` | Frame timestamp |
185
+ | `velocity` | `np.ndarray` | Velocity vector |
186
+ | `local_pose` | `np.ndarray` | Local pose matrix |
187
+ | `global_pose` | `np.ndarray` | Global pose matrix |
188
+ | `camera_intrinsics` | `np.ndarray` | Camera intrinsic parameters |
189
+ | `color_img` | `bytes` | Color image bytes (JPEG/PNG) |
190
+ | `depth_img` | `bytes` | Raw depth image bytes |
191
+ | `depth_width` | `int` | Depth image width |
192
+ | `depth_height` | `int` | Depth image height |
193
+ | `has_color_image` | `bool` | Whether color image is available |
194
+ | `has_depth_image` | `bool` | Whether depth image is available |
195
+
196
+ **Methods:**
197
+
198
+ | Method | Returns | Description |
199
+ | ------------------------------------- | ------------ | --------------------------------- |
200
+ | `get_depth_array()` | `np.ndarray` | Get depth as numpy array (uint16) |
201
+ | `show_color(window_name)` | `bool` | Display color image |
202
+ | `show_depth(window_name, colormap)` | `bool` | Display depth image |
203
+ | `show_images(show_color, show_depth)` | `tuple` | Display both images |
204
+
205
+ ## Requirements
206
+
207
+ - Python >= 3.8
208
+ - numpy >= 1.20.0
209
+ - pyzmq >= 22.0.0
210
+ - protobuf >= 4.0.0
211
+
212
+ Optional (for image display):
213
+
214
+ - opencv-python >= 4.5.0
215
+ - Pillow >= 8.0.0
216
+
217
+ ## License
218
+
219
+ MIT License
@@ -0,0 +1,180 @@
1
+ # asmagic
2
+
3
+ A lightweight Python library for subscribing to AR sensor data streams via ZeroMQ.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install asmagic
9
+ ```
10
+
11
+ For image display support:
12
+
13
+ ```bash
14
+ pip install asmagic[image]
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```python
20
+ from asmagic import ARDataSubscriber
21
+
22
+ # Create subscriber
23
+ sub = ARDataSubscriber("192.168.1.100")
24
+
25
+ # Get data frame
26
+ data = sub.get()
27
+ if data:
28
+ print(data.timestamp)
29
+ print(data.velocity)
30
+ print(data.local_pose)
31
+ print(data.camera_intrinsics)
32
+
33
+ sub.close()
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### Continuous Data Streaming
39
+
40
+ ```python
41
+ from asmagic import ARDataSubscriber
42
+
43
+ sub = ARDataSubscriber("192.168.1.100")
44
+
45
+ try:
46
+ while True:
47
+ data = sub.get()
48
+ if data:
49
+ print(f"Velocity: {data.velocity}")
50
+ print(f"Local pose: {data.local_pose}")
51
+ print(f"Timestamp: {data.timestamp}")
52
+ except KeyboardInterrupt:
53
+ pass
54
+ finally:
55
+ sub.close()
56
+ ```
57
+
58
+ ### Image Display
59
+
60
+ Requires `opencv-python` and `Pillow`:
61
+
62
+ ```bash
63
+ pip install asmagic[image]
64
+ ```
65
+
66
+ ```python
67
+ from asmagic import ARDataSubscriber
68
+ import cv2
69
+
70
+ sub = ARDataSubscriber("192.168.1.100")
71
+
72
+ try:
73
+ while True:
74
+ data = sub.get()
75
+ if data:
76
+ # Display both color and depth images
77
+ data.show_images()
78
+
79
+ # Or display individually
80
+ # data.show_color()
81
+ # data.show_depth()
82
+
83
+ if cv2.waitKey(1) == 27: # ESC to exit
84
+ break
85
+ finally:
86
+ sub.close()
87
+ cv2.destroyAllWindows()
88
+ ```
89
+
90
+ ### Accessing Individual Fields
91
+
92
+ ```python
93
+ from asmagic import ARDataSubscriber
94
+
95
+ sub = ARDataSubscriber("192.168.1.100")
96
+
97
+ # Get specific data
98
+ velocity = sub.get_velocity()
99
+ pose = sub.get_local_pose()
100
+ timestamp = sub.get_timestamp()
101
+
102
+ sub.close()
103
+ ```
104
+
105
+ ## API Reference
106
+
107
+ ### ARDataSubscriber
108
+
109
+ **Constructor:**
110
+
111
+ ```python
112
+ ARDataSubscriber(ip, port=8000, hwm=1, conflate=True, verbose=False)
113
+ ```
114
+
115
+ **Parameters:**
116
+
117
+ - `ip` (str): IP address of the AR device
118
+ - `port` (int): Port number (default: 8000)
119
+ - `hwm` (int): High water mark for ZMQ socket (default: 1)
120
+ - `conflate` (bool): Enable message conflation (default: True)
121
+ - `verbose` (bool): Print connection info (default: False)
122
+
123
+ **Methods:**
124
+
125
+ | Method | Returns | Description |
126
+ | ------------------------------------- | ---------------------- | --------------------- |
127
+ | `get(timeout=1000)` | `ARFrame` or `None` | Get latest data frame |
128
+ | `get_timestamp(timeout=1000)` | `float` or `None` | Get timestamp |
129
+ | `get_velocity(timeout=1000)` | `np.ndarray` or `None` | Get velocity |
130
+ | `get_local_pose(timeout=1000)` | `np.ndarray` or `None` | Get local pose |
131
+ | `get_global_pose(timeout=1000)` | `np.ndarray` or `None` | Get global pose |
132
+ | `get_camera_intrinsics(timeout=1000)` | `np.ndarray` or `None` | Get camera intrinsics |
133
+ | `get_color_image(timeout=1000)` | `bytes` or `None` | Get color image bytes |
134
+ | `get_depth_image(timeout=1000)` | `np.ndarray` or `None` | Get depth image array |
135
+ | `close()` | `None` | Close connection |
136
+
137
+ ### ARFrame
138
+
139
+ Data object returned by `get()`:
140
+
141
+ **Properties:**
142
+
143
+ | Property | Type | Description |
144
+ | ------------------- | ------------ | -------------------------------- |
145
+ | `timestamp` | `float` | Frame timestamp |
146
+ | `velocity` | `np.ndarray` | Velocity vector |
147
+ | `local_pose` | `np.ndarray` | Local pose matrix |
148
+ | `global_pose` | `np.ndarray` | Global pose matrix |
149
+ | `camera_intrinsics` | `np.ndarray` | Camera intrinsic parameters |
150
+ | `color_img` | `bytes` | Color image bytes (JPEG/PNG) |
151
+ | `depth_img` | `bytes` | Raw depth image bytes |
152
+ | `depth_width` | `int` | Depth image width |
153
+ | `depth_height` | `int` | Depth image height |
154
+ | `has_color_image` | `bool` | Whether color image is available |
155
+ | `has_depth_image` | `bool` | Whether depth image is available |
156
+
157
+ **Methods:**
158
+
159
+ | Method | Returns | Description |
160
+ | ------------------------------------- | ------------ | --------------------------------- |
161
+ | `get_depth_array()` | `np.ndarray` | Get depth as numpy array (uint16) |
162
+ | `show_color(window_name)` | `bool` | Display color image |
163
+ | `show_depth(window_name, colormap)` | `bool` | Display depth image |
164
+ | `show_images(show_color, show_depth)` | `tuple` | Display both images |
165
+
166
+ ## Requirements
167
+
168
+ - Python >= 3.8
169
+ - numpy >= 1.20.0
170
+ - pyzmq >= 22.0.0
171
+ - protobuf >= 4.0.0
172
+
173
+ Optional (for image display):
174
+
175
+ - opencv-python >= 4.5.0
176
+ - Pillow >= 8.0.0
177
+
178
+ ## License
179
+
180
+ MIT License
@@ -0,0 +1,31 @@
1
+ """
2
+ asmagic - Read Daya from asMagic App
3
+
4
+ A Python library for subscribing to AR sensor data streams.
5
+
6
+ Example - Simple and clean:
7
+ >>> from asmagic import ARDataSubscriber
8
+ >>>
9
+ >>> sub = ARDataSubscriber("192.168.1.100")
10
+ >>>
11
+ >>> # Get data - super simple!
12
+ >>> data = sub.get()
13
+ >>> if data:
14
+ ... print(data.timestamp)
15
+ ... print(data.velocity)
16
+ ... print(data.local_pose)
17
+ >>>
18
+ >>> sub.close()
19
+ """
20
+
21
+ __version__ = "0.1.0"
22
+ __author__ = "ASMagic Team"
23
+
24
+ # Main exports - keep it simple, no need to expose ARFrame
25
+ from .subscriber import ARDataSubscriber
26
+
27
+ __all__ = [
28
+ "ARDataSubscriber",
29
+ "__version__",
30
+ ]
31
+