Package: pyrealsense
Cross-platformctypes/Cythonwrapper to thelibrealsenselibrary.Prerequisitesinstalllibrealsenseand run the examples.install the dependencies: pyrealsense usespycparserfor extracting
necessary enums and structures definitions from the librealsense API,Cythonfor wrapping the inlined functions in
the librealsense API, andNumpyfor
generic data shuffling.Windows specifics: set environment variable PYRS_INCLUDES to thers.hdirectory location and environment variable PYRS_LIBS to
the librealsense binary location. You might also need to havestdint.havailable in your path.InstallationfromPyPI- (OBS: not
always the latest):pip install pyrealsensefrom source:python setup.py installOnline Usage## setup logging
import logging
logging.basicConfig(level = logging.INFO)

## import the package
import pyrealsense as pyrs

## start the service - also available as context manager
serv = pyrs.Service()

## create a device from device id and streams of interest
cam = serv.Device(device_id = 0, streams = [pyrs.stream.ColorStream(fps = 60)])

## retrieve 60 frames of data
for _ in range(60):
    cam.wait_for_frames()
    print(cam.color)

## stop camera and service
cam.stop()
serv.stop()The server for Realsense devices is started withpyrs.Service()which will printout the number of devices available. It can also be
started as a context withwithpyrs.Service():.Different devices can be created from the serviceDevicefactory.
They are created as their own class defined by device id, name, serial,
firmware as well as enabled streams and camera presets. The default
behaviour create a device withid = 0and setup the color, depth,
pointcloud, color_aligned_depth, depth_aligned_color and infrared
streams.The available streams are either native or synthetic, and each one will
create a property that exposes the current content of the frame buffer
in the form ofdevice.<stream_name>, where<stream_name>is
color, depth, points, cad, dac or infrared. To get access to new data,Device.wait_for_frameshas to be called once per frame.Offline Usage## with connected device cam
from pyrealsense import offline
offline.save_depth_intrinsics(cam)## previous device cam now offline
from pyrealsense import offline
offline.load_depth_intrinsics('610205001689')  # camera serial number
d = np.linspace(0, 1000, 480*640, dtype=np.uint16)
pc = offline.deproject_depth(d)The moduleofflinecan store the rs_intrinsics and depth_scale of
a device to disk by default in the user’s home directory in the file.pyrealsense. This can later be loaded and used to deproject depth
data into pointcloud, which is useful to store raw video file and save
some disk memory.ExamplesThere are 3 examples using different visualisation technologies: - still
color withmatplotlib- color and depth
stream withopencv- pointcloud stream withVTKCaveatsTo this point, this wrapper is tested with:librealsense
v1.12.1Ubuntu 16.04 LTS, Mac OS X 10.12.2 w/ SR300 cameraMac OS X 10.12.3 w/ R200 cameraThe offline module only supports a single camera.Build StatusUbuntu Trusty, python 2 and 3:Possible Pull Requestsimprovments to the documentationmore functionality fromrs.hboiler plate code (Qt example?)support for several cameras in offline modulecontinuous integration for Windows and MacOsMake sure to push to thedevbranch.