pip install neoruntime-ipc-sdk==0.8.0 Copy PIP instructions
Python SDK for NeoRuntime EdgeCam AI Platform
python -m pip install neoruntime-ipc-sdk Pre-release builds are staged on TestPyPI for validation (dependencies still come from PyPI):
python -m pip install --index-url https://test.pypi.org/simple/ \ --extra-index-url https://pypi.org/simple/ neoruntime-ipc-sdk Install from source:
git clone https://github.com/camthink-ai/neoruntime-sdks.git cd neoruntime-sdks python -m pip install -e ./python Or build and install a local wheel:
cd neoruntime-sdks/python python -m pip install --upgrade build python -m build --wheel python -m pip install dist/neoruntime_ipc_sdk-*.whl Quick Start 1. AI Inference from neoruntime_ipc_sdk import InferenceClient # Create inference client inf = InferenceClient() # Single inference import numpy as np image = np.zeros((1080, 1920, 3), dtype=np.uint8) result = inf.infer(image, model_id="person_v1") print(f"Detected {len(result.objects)} objects") # Subscribe to video stream inference results for frame_seq, result in inf.subscribe(stream="cam0_main", model="person_v1", fps=10): print(f"Frame {frame_seq}: Detected {len(result.objects)} objects") for obj in result.objects: print(f" - {obj.label}: {obj.score:.2f} @ [{obj.bbox.x:.2f}, {obj.bbox.y:.2f}]") 2. Event Bus from neoruntime_ipc_sdk import EventClient events = EventClient() # Publish event events.publish("app/alert", { "type": "person_detected", "zone": "A", "confidence": 0.95 }) # Subscribe to events (supports wildcards) for event in events.subscribe("model/*/detections"): print(f"Received event: {event.topic}") print(f"Data: {event.payload}") # Subscribe with callback def on_alert(event): print(f"Alert: {event.payload}") events.on_event("app/alert", on_alert) 3. Device Control from neoruntime_ipc_sdk import DeviceClient, IrCutMode dev = DeviceClient() # Light control dev.set_white_light(80) # White light brightness 80% dev.set_ir_led(True) # Turn on IR LED dev.set_ircut(IrCutMode.NIGHT) # Night vision mode # PTZ control dev.pan_left(speed=50) dev.tilt_up(speed=30) dev.ptz_stop() dev.save_preset(1) # Save preset dev.call_preset(1) # Call preset # Zoom and focus dev.zoom_in(speed=50) dev.zoom_out(speed=50) dev.set_zoom_level(0.5) # Set zoom to 50% dev.set_focus_level(0.5) # Set focus to 50% dev.focus_auto(True) dev.lens_init() # Initialize lens module dev.lens_reset_zero(zoom=True, focus=True) # Reset both axes dev.oneshot_autofocus() # One-shot autofocus dev.set_lens_limits(zoom_limit={"min_pos": 0, "max_pos": 1000}) # Set lens limits status = dev.get_lens_status() # Get lens status dict dev.lens_goto_ratio_distance(2.0, 3.0) # Zoom+focus linked move # GPIO dev.gpio_set(pin=10, value=True) value = dev.gpio_get(pin=11) # Get device status status = dev.get_device_status() print(f"SoC Temperature: {status.soc_temp_c}C") print(f"White light level: {status.white_light_level}") 4. Video Stream Access from neoruntime_ipc_sdk import FdMediaClient media = FdMediaClient() # List available streams streams = media.list_streams() print(f"Available streams: {streams}") # ['main', 'sub'] # Get single frame frame = media.get_frame("main") if frame: print(f"Frame size: {frame.width}x{frame.height}, format: {frame.format}") rgb_image = frame.to_rgb() # Convert to RGB format # Subscribe to video stream for frame in media.subscribe("main"): # frame.image is the decoded numpy array process_frame(frame.image) # Encoded stream (H.264/H.265): get_encoded_stream() returns a client for packet in media.get_encoded_stream("main").subscribe(): print(f"{packet.codec_name()} packet: {len(packet.data)} bytes") # Use callback def process(frame): print(f"Frame: {frame.sequence}") media.on_frame("main", process) 5. Complete Example: AI + Device Linkage from neoruntime_ipc_sdk import InferenceClient, DeviceClient, EventClient # Initialize clients inf = InferenceClient() dev = DeviceClient() events = EventClient() # Subscribe to person detection results for frame_seq, result in inf.subscribe(stream="cam0_main", model="person_v1"): # Person detected if result.has_person(): # Turn on white light dev.set_white_light(100) # Publish alert event events.publish("app/perimeter_alert", { "person_count": result.count_by_label("person"), "objects": [ {"label": obj.label, "score": obj.score} for obj in result.objects ] }) else: # Turn off white light dev.set_white_light(0) 7. Inference Pipeline (client-side pre/post) For custom models whose postprocess is not handled server-side, or apps that need their own thresholds — InferencePipeline composes preprocessing (derived from the model's input spec, DSP-scaled for keep-fd frames), inference, and a client-side YOLO decoder whose thresholds are yours:
from neoruntime_ipc_sdk import ( FdMediaClient, InferencePipeline, YoloV8Postprocessor, ) pipe = InferencePipeline.from_model( "custom_yolov8n", postprocessor=YoloV8Postprocessor(labels=["person", "car"], score_threshold=0.3), ) for frame in FdMediaClient().subscribe("sub", keep_fd=True): out = pipe.run(frame) # out.objects in source-frame coordinates Preprocessor also works standalone: tensor, meta = pre(frame) with meta.to_source(x, y) mapping model-input coordinates back to the frame. When a family model fits, InferenceClient.subscribe remains the cheaper path — see PERFORMANCE.md for the decision table.
For long-running apps, PipelineRunner productises the whole loop — a reader thread pulling frames into a latest-wins queue, a worker thread running the pipeline and handing results to a sink, keep-fd handles released on consumption, drops/latency/errors visible in stats:
Detection visualization on a live frame (pure numpy/PIL, cv2 optional):
from neoruntime_ipc_sdk import EncodedStreamClient, HlsWriter with HlsWriter("/srv/hls", segment_seconds=4.0, window=5) as hls: for frame in EncodedStreamClient("/run/aipc/encoded/main.sock").subscribe(): hls.write(frame) # cuts on keyframes # serve /srv/hls/ over HTTP and point hls.js at index.m3u8 MJPEG preview page — one WSGI app (mount in Flask) or a standalone server:
Event bus client for publishing and subscribing to events.
Device control client for controlling camera peripherals.
Known device limitation: on current firmware (verified on a test device, 2026-08) the lens HAL bridge rejects set_af_windows and get_af_measurement with "not yet supported". The SDK-side plumbing is complete; both calls will start working once the device firmware adds bridge support. Oneshot, zoom-follow, status, and cancel all work today.
Video stream client receiving frames over UDS (dma-buf fds, decoded on receive by default).
diagnostics() (never raises) snapshots the SDK's execution environment — the first stop when an app feels slow:
from neoruntime_ipc_sdk import diagnostics report = diagnostics() report["optional_deps"]["cv2"] # {"available": bool, "version": ...} report["services"]["camera_control"] # {"path", "exists", "connectable"} report["media"]["encoded_dir"]["streams"] report["accel_router"]["ops"]["nv12_to_rgb"]["backend"] # "hardware" | "software" Without cv2 installed, conversions/resize/JPEG run on pure-numpy fallbacks that are 10-50x slower at frame rate — the SDK warns once per operation on that path.
diagnostics.check() grades the snapshot against an app's requirements — a deployment gate:
from neoruntime_ipc_sdk.diagnostics import check check(["inference", "camera_sock"]).raise_if_unhealthy() # RuntimeError listing failures # live model/stream probes are opt-in: check(["model_registered", "stream_active"], inference=InferenceClient(), model_id="person_v1", camera=CameraClient(), stream_id="main").raise_if_unhealthy() Hardware/software routing is one app-wide knob (see AccelRouter.health() for what is actually serving each operation):
from neoruntime_ipc_sdk import set_route_policy set_route_policy("software_only") # baseline/benchmark; "prefer_hardware" (default), "hardware_only" (refuse silent CPU fallback) Architecture and stability The SDK is layered, and the middle layer is a stability contract:
Pure-python MPEG-TS muxing of EncodedFrame Annex-B payloads — no ffmpeg required.
Detection visualization on RGB numpy arrays (returns new arrays, input untouched).
Configuration management, reads from environment variables.
SDK automatically reads configuration from environment variables:
The generated protobuf stubs in neoruntime_ipc_sdk/proto/ (*_pb2.py / *_pb2_grpc.py) are committed to the repo so the SDK imports cleanly on a fresh clone, editable install, and inside packaged wheels. They are re-included via sdk/python/.gitignore and do not affect the global "no generated artifacts" policy for Go services.
If you change any .proto source, regenerate and re-commit them:
make sdk-proto # regenerate stubs (inference/event/device/app/camera) make sdk-proto-check # verify committed stubs match .proto sources git add sdk/python/neoruntime_ipc_sdk/proto/*_pb2*.py Run Tests cd sdk/python pip install -e ".[dev]" pytest tests/ Build Package python setup.py build Build Wheel The recommended way to build a distributable wheel is:
python -m pip install --upgrade build python -m build --wheel ls dist/*.whl The generated wheel is written to dist/, for example:
pip install dist/neoruntime_ipc_sdk-*.whl For older tooling, this also works:
python setup.py bdist_wheel Do not commit files from dist/; publish them as release artifacts instead.
In the public neoruntime-sdks repository, GitHub Actions builds a wheel for pull requests, pushes to main, and manual workflow runs. The wheel is uploaded as a workflow artifact named python-sdk-wheel.
To create or update a GitHub Release, either push a version tag or run the workflow manually with release publishing enabled:
git tag v0.5.0 git push origin v0.5.0 The release tag version must match the package version in setup.py. On release tags, the repository-level workflow also attaches the C++ SDK tarball to the same GitHub Release.
PyPI packages are not published yet. Until they are available, use source installs, local wheels, or GitHub Release artifacts.
MIT License. See the repository LICENSE file.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
The dropdown lists show the available interpreters, ABIs, and platforms.
Enable javascript to be able to filter the list of wheel files.
Copy a direct link to the current filters Copy
Details for the file neoruntime_ipc_sdk-0.8.0.tar.gz.
The following attestation bundles were made for neoruntime_ipc_sdk-0.8.0.tar.gz:
Publisher: wheel.yml on camthink-ai/neoruntime-sdks




