pykinect package
The pykinect package provides access to the Kinect device. The pykinect package includes both the "nui" and "audio" subpackages. The nui package provides interactions with the Kinect cameras including skeleton tracking, video camera, as well as the depth
camera. The audio subpackage provides access to the Kinect devices microphones.
pykinect.nui package
the pykinect.nui package provides access to the Kinect devices cameras. This includes providing access to skeleton tracking, the video camera, as well as the depth camera.
Runtime class
The runtime class is the primary entry point for starting to work with the Kinect cameras. Usually this device is used in a with statement such as:
with nui.Runtime() as kinect:
pass
The runtime class has several arguments which can be used when constructing it to control what functionality is available or what device is used. It can be constructed as:
Runtime(nui_init_flags = ..., index = 0)
The default value for nui_init_flags is RuntimeOptions.UseColor | RuntimeOptions.UseDepth | RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking which enables all of the Kinect camera features. index specifies which Kinect device this
Runtime instance is controlling - this is useful when multiple Kinect devices are connected to the PC.
From here additional methods and attributes of the runtime class can be accessed for interacting with the Kinect device:
| Attribute Name |
Attribute type |
Description |
| depth_frame_ready |
Event |
Supports in place assignment with a callable to receive a callback when a new depth frame is available. |
| skeleton_frame_ready |
Event |
Supports in place assignment with a callable to receive a callback when a new skeleton frame is available. |
| video_frame_ready |
Event |
Supports in place assignment with a callable to receive a callback when a new video frame is available. |
| camera |
pykinect.nui.Camera |
Provides an object which enables manipulating the camera including getting and setting the angle of the camera. |
RuntimeOptions class
Provides a set of options which can be enabled per-Kinect sensor.
| Attribute Name |
Attribute type |
Description |
| UseColor |
int (value == 2) |
Enable the color cameras |
| UseDepth |
int (value == 0x20) |
Enable the depth camera |
| UseDepthAndPlayerIndex |
int (value == 1) |
Enable the depth and player index cameras |
| UseSkeletalTracking |
int (value == 8) |
Enable skeleton tracking. |
Device class
Represents a system's Kinect sensors
| Attribute Name |
Attribute type |
Description |
| count |
property (int) |
The number of active Kinect sensors that are attached to the system. |
ImageStream class
| Attribute Name |
Attribute type |
Description |
| open(image_stream_type = ..., frame_limit = ..., resolution = ..., image_type = ...) |
method |
Opens the image stream enabling images to be fetched.
- image_stream_type: One of ImageStreamType.Depth or ImageStreamType.Video
- frame_limit: The maximum number of frames which can be buffered, default 2.
- resolution: The resolution of the image to open, default ImageResolution.Resolution320x240.
- image_type: The image type to fetch, default ImageType.Color.
|
| get_next_frame(milliseconds_to_wait = 0) |
method |
Gets the next frame from the image stream. |
| get_valid_resolutions(image_type) |
static method |
Gets a sequence of supported resolutions for the given image type. |
ImageStreamType class
| Attribute Name |
Attribute type |
Description |
| Depth |
int (value == 0) |
An image stream for a depth view |
| Video |
int (value == 1) |
An image stream for a video view |
| Invalid |
int (value == -1) |
An invalid image stream type |
SkeletonEngine class
| Attribute Name |
Attribute type |
Description |
| enabled |
property (bool) |
Gets/sets if the skeleton engine is enabled |
| get_next_frame(timeout = -1) |
method |
Returns the next skeleton frame, by default blocking indefinitely until a frame is received. |
| depth_image_to_skeleton(fDepthX, fDepthY, usDepthValue) |
static method |
Maps a depth image point to a skeleton point. |
| skeleton_to_depth_image(vPoint, scaleX = 1, scaleY = 1) |
static method |
Maps a skeleton point to a depth image point. |
Camera class
Supports manipulating the camera including getting and setting the angle of the camera.
| Attribute Name |
Attribute type |
Description |
| ElevationMaximum |
int |
The maximum elevation which the camera supports. |
| ElevationMinimum |
Event |
The minimum elevation which the camera supports. |
| elevation_angle |
property (int) |
Gets or sets the maximum elevation angle |
| unique_device_name |
property (str) |
Provides an object which enables manipulating the camera including getting and setting the angle of the camera. |
| get_color_pixel_coordinates_from_depth_pixel(color_resolution, view_area, depth_x, depth_y, depth_value) |
method |
Returns the pixel coordinates in color image space that correspond to the specified pixel coordinates in depth image space.
- color_resolution: An ImageResolution value specifying the color image resolution.
- view_area: An ImageViewArea structure containing the pan and zoom settings. If you provide this argument, you should pass in the view area from the image frame against which you are registering pixels, rather than manually instantiating and populating the
structure. This helps ensure that your settings are valid.
- depth_x: The x coordinate in depth image space.
- depth_y: The y coordinate in depth image space.
- depth_value: The depth value in depth image space.
Returns: color_x, color_y - the x and y coordinate in the color image space |
pykinect.audio package