Async Streaming Examples
Overview
Basic Async Pattern
import asyncio
import cv2
from uesynth import AsyncUESynthClient
async def basic_async_capture():
"""Basic pattern for async data capture."""
async with AsyncUESynthClient() as client:
# Start a capture (non-blocking)
request_id = await client.capture.rgb(width=1920, height=1080)
print(f"Started capture request: {request_id}")
# Do other work while capture is processing
await client.camera.set_location(x=100, y=200, z=50)
# Get the captured frame
frame = await client.get_latest_frame()
if frame is not None:
cv2.imwrite("async_capture.png", frame)
print("✅ Frame captured and saved")
asyncio.run(basic_async_capture())High-Performance Collection
Real-time Simulation
Producer-Consumer Pattern
Error Handling & Resilience
Performance Tips
1. Use Streaming for High Throughput
2. Batch Operations
3. Configure for Performance
Next Steps
Last updated