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
For image display support:
pip install asmagic[image]
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
Requires opencv-python and Pillow:
pip install asmagic[image]
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
Optional (for image display):
- 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
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
File details
Details for the file asmagic-0.1.0.tar.gz.
File metadata
- Download URL: asmagic-0.1.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adbfd2283083f0ec7a77ed2698ed57cab674066f883f568fa17b4386f813d319
|
|
| MD5 |
59bf306933d1dd5bedf41100bd6adb26
|
|
| BLAKE2b-256 |
ec33e2e31eaf7432af2b6b1bf04aa3976c45f613fa5a3976a1fec47a1bb29049
|
File details
Details for the file asmagic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: asmagic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 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 |
6001385e9d88cf670c314903cd3c0309918c4564482f8c2856bebbed17e3f771
|
|
| MD5 |
5296b047a00fb17e2253b60956c2c8fe
|
|
| BLAKE2b-256 |
6454b3b3d96206ce79364d99b6c4558e6435f0eab09e1f910a7b25fe6cf25ae7
|