AR Sensor Data Magic Library - Subscribe to AR sensor data streams
Project description
asmagic
A lightweight Python library for subscribing to AR sensor data streams via ZeroMQ.
Installation
pip install asmagic
Quick Start
from asmagic import ARDataSubscriber
# Create subscriber
sub = ARDataSubscriber("192.168.1.100")
# Get data frame
data = sub.get()
if data:
print(data.timestamp)
print(data.velocity)
print(data.local_pose)
print(data.camera_intrinsics)
sub.close()
Usage
Continuous Data Streaming
from asmagic import ARDataSubscriber
sub = ARDataSubscriber("192.168.1.100")
try:
while True:
data = sub.get()
if data:
print(f"Velocity: {data.velocity}")
print(f"Local pose: {data.local_pose}")
print(f"Timestamp: {data.timestamp}")
except KeyboardInterrupt:
pass
finally:
sub.close()
Image Display
from asmagic import ARDataSubscriber
import cv2
sub = ARDataSubscriber("192.168.1.100")
try:
while True:
data = sub.get()
if data:
# Display both color and depth images
data.show_images()
# Or display individually
# data.show_color()
# data.show_depth()
if cv2.waitKey(1) == 27: # ESC to exit
break
finally:
sub.close()
cv2.destroyAllWindows()
Accessing Individual Fields
from asmagic import ARDataSubscriber
sub = ARDataSubscriber("192.168.1.100")
# Get specific data
velocity = sub.get_velocity()
pose = sub.get_local_pose()
timestamp = sub.get_timestamp()
sub.close()
API Reference
ARDataSubscriber
Constructor:
ARDataSubscriber(ip, port=8000, hwm=1, conflate=True, verbose=False)
Parameters:
ip(str): IP address of the AR deviceport(int): Port number (default: 8000)hwm(int): High water mark for ZMQ socket (default: 1)conflate(bool): Enable message conflation (default: True)verbose(bool): Print connection info (default: False)
Methods:
| Method | Returns | Description |
|---|---|---|
get(timeout=1000) |
ARFrame or None |
Get latest data frame |
get_timestamp(timeout=1000) |
float or None |
Get timestamp |
get_velocity(timeout=1000) |
np.ndarray or None |
Get velocity |
get_local_pose(timeout=1000) |
np.ndarray or None |
Get local pose |
get_global_pose(timeout=1000) |
np.ndarray or None |
Get global pose |
get_camera_intrinsics(timeout=1000) |
np.ndarray or None |
Get camera intrinsics |
get_color_image(timeout=1000) |
bytes or None |
Get color image bytes |
get_depth_image(timeout=1000) |
np.ndarray or None |
Get depth image array |
close() |
None |
Close connection |
ARFrame
Data object returned by get():
Properties:
| Property | Type | Description |
|---|---|---|
timestamp |
float |
Frame timestamp |
velocity |
np.ndarray |
Velocity vector |
local_pose |
np.ndarray |
Local pose matrix |
global_pose |
np.ndarray |
Global pose matrix |
camera_intrinsics |
np.ndarray |
Camera intrinsic parameters |
color_img |
bytes |
Color image bytes (JPEG/PNG) |
depth_img |
bytes |
Raw depth image bytes |
depth_width |
int |
Depth image width |
depth_height |
int |
Depth image height |
has_color_image |
bool |
Whether color image is available |
has_depth_image |
bool |
Whether depth image is available |
Methods:
| Method | Returns | Description |
|---|---|---|
get_depth_array() |
np.ndarray |
Get depth as numpy array (uint16) |
show_color(window_name) |
bool |
Display color image |
show_depth(window_name, colormap) |
bool |
Display depth image |
show_images(show_color, show_depth) |
tuple |
Display both images |
Requirements
- Python >= 3.8
- numpy >= 1.20.0
- pyzmq >= 22.0.0
- protobuf >= 4.0.0
- opencv-python >= 4.5.0
- Pillow >= 8.0.0
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asmagic-0.1.1.tar.gz
(11.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
asmagic-0.1.1-py3-none-any.whl
(10.7 kB
view details)
File details
Details for the file asmagic-0.1.1.tar.gz.
File metadata
- Download URL: asmagic-0.1.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
345c8ad636741b272650a132896efa9a6687cf9f3e21054c6442907e7eb72fe5
|
|
| MD5 |
97582c09c22f088c1ea387cabb04e96a
|
|
| BLAKE2b-256 |
b969d53c0edf2619ccd59c590d80e316c46274164d90fe69e4de871381a46df8
|
File details
Details for the file asmagic-0.1.1-py3-none-any.whl.
File metadata
- Download URL: asmagic-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e33eec2b48b3e0bba405c6adcd8ea6ce92730c3fb747c7ca2300a99692feced
|
|
| MD5 |
6becfdcc345fb41c61d67bc8b7f40195
|
|
| BLAKE2b-256 |
daeaba6f82bd30b728462260398ce2facc8b70a84394bc1f0914ed23264ae305
|