GFreenectDevice

GFreenectDevice — Object representing a kinect sensor device

Synopsis

struct              GFreenectDevice;
struct              GFreenectDeviceClass;
void                gfreenect_device_get_accel          (GFreenectDevice *self,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            gfreenect_device_get_accel_finish   (GFreenectDevice *self,
                                                         gdouble *x,
                                                         gdouble *y,
                                                         gdouble *z,
                                                         GAsyncResult *result,
                                                         GError **error);
gboolean            gfreenect_device_get_accel_sync     (GFreenectDevice *self,
                                                         gdouble *x,
                                                         gdouble *y,
                                                         gdouble *z,
                                                         GCancellable *cancellable,
                                                         GError **error);
guint8 *            gfreenect_device_get_depth_frame_grayscale
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);
guint8 *            gfreenect_device_get_depth_frame_raw
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);
void                gfreenect_device_get_tilt_angle     (GFreenectDevice *self,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gdouble             gfreenect_device_get_tilt_angle_finish
                                                        (GFreenectDevice *self,
                                                         GAsyncResult *result,
                                                         GError **error);
gdouble             gfreenect_device_get_tilt_angle_sync
                                                        (GFreenectDevice *self,
                                                         GCancellable *cancellable,
                                                         GError **error);
guint8 *            gfreenect_device_get_video_frame_raw
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);
guint8 *            gfreenect_device_get_video_frame_rgb
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);
void                gfreenect_device_new                (gint device_index,
                                                         guint subdevices,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
GFreenectDevice *   gfreenect_device_new_finish         (GAsyncResult *result,
                                                         GError **error);
void                gfreenect_device_set_led            (GFreenectDevice *self,
                                                         GFreenectLed led,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            gfreenect_device_set_led_finish     (GFreenectDevice *self,
                                                         GAsyncResult *result,
                                                         GError **error);
void                gfreenect_device_set_tilt_angle     (GFreenectDevice *self,
                                                         gdouble tilt_angle,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gboolean            gfreenect_device_set_tilt_angle_finish
                                                        (GFreenectDevice *self,
                                                         GAsyncResult *result,
                                                         GError **error);
gboolean            gfreenect_device_start_depth_stream (GFreenectDevice *self,
                                                         GFreenectDepthFormat format,
                                                         GError **error);
gboolean            gfreenect_device_start_video_stream (GFreenectDevice *self,
                                                         GFreenectResolution resolution,
                                                         GFreenectVideoFormat format,
                                                         GError **error);
gboolean            gfreenect_device_stop_depth_stream  (GFreenectDevice *self,
                                                         GError **error);
gboolean            gfreenect_device_stop_video_stream  (GFreenectDevice *self,
                                                         GError **error);

Object Hierarchy

  GObject
   +----GFreenectDevice

Implemented Interfaces

GFreenectDevice implements GAsyncInitable and GInitable.

Properties

  "index"                    gint                  : Read / Write / Construct Only
  "led"                      guint                 : Read / Write
  "subdevices"               guint                 : Read / Write / Construct Only
  "tilt-angle"               gdouble               : Read / Write

Signals

  "depth-frame"                                    : Action
  "video-frame"                                    : Action

Description

A GFreenectDevice is created using the asynchronous failable constructor gfreenect_device_new(). Then gfreenect_device_new_finish() is called within the provided callback, to obtain the new GFreenectDevice instance.

Use gfreenect_device_set_tilt_angle() and gfreenect_device_set_tilt_angle_finish() to asynchronously move the tilt motor to the desired angle. gfreenect_device_get_tilt_angle() and gfreenect_device_get_tilt_angle_finish() are used to obtain the current tilt angle, also asynchronously. For a synchronous call use gfreenect_device_get_tilt_angle_sync().

The led status is set asynchronously using gfreenect_device_set_led() and gfreenect_device_set_led_finish().

To start the depth or video camera streams, use gfreenect_device_start_depth_stream() and gfreenect_device_start_video_stream() respectively. Then connect to the signals "depth-frame" and "video-frame" to get notified when a new frame is available. The actual frame data is obtained using methods like gfreenect_device_get_depth_frame_raw(), gfreenect_device_get_depth_frame_grayscale(), gfreenect_device_get_video_frame_rgb(), etc. Note that these methods should only be called from within the signal handlers.

The accelerometer data can be obtained asynchronously using gfreenect_device_get_accel() and gfreenect_device_get_accel_finish(), or synchronously using gfreenect_device_get_accel_sync().

Details

struct GFreenectDevice

struct GFreenectDevice;


struct GFreenectDeviceClass

struct GFreenectDeviceClass {
  GObjectClass parent_class;

  /* Signal prototypes */
  void (* depth_frame) (GFreenectDevice *self, gpointer user_data);
  void (* video_frame) (GFreenectDevice *self, gpointer user_data);
};

GObjectClass parent_class;

depth_frame ()

Prototype for "depth-frame" signal

video_frame ()

Prototype for "video-frame" signal

gfreenect_device_get_accel ()

void                gfreenect_device_get_accel          (GFreenectDevice *self,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Gets the accelerometer data asynchronously. Use gfreenect_device_get_accel_finish() to obtain the results.

See gfreenect_device_get_accel_sync() for a blocking version of this method.

self :

The GFreenectDevice

cancellable :

A cancellable object, or NULL. [allow-none]

callback :

A function to be called upon completion, or NULL. [scope async][allow-none]

user_data :

An arbitrary user data to pass in callback, or NULL. [allow-none]

gfreenect_device_get_accel_finish ()

gboolean            gfreenect_device_get_accel_finish   (GFreenectDevice *self,
                                                         gdouble *x,
                                                         gdouble *y,
                                                         gdouble *z,
                                                         GAsyncResult *result,
                                                         GError **error);

Retrieves the result of a gfreenect_device_get_accel() operation.

self :

The GFreenectDevice

x :

A pointer to retrieve the X-axis value of the accelerometer. [out][allow-none]

y :

A pointer to retrieve the Y-axis value of the accelerometer. [out][allow-none]

z :

A pointer to retrieve the Z-axis value of the accelerometer. [out][allow-none]

result :

The GAsyncResult provided in the callback

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_get_accel_sync ()

gboolean            gfreenect_device_get_accel_sync     (GFreenectDevice *self,
                                                         gdouble *x,
                                                         gdouble *y,
                                                         gdouble *z,
                                                         GCancellable *cancellable,
                                                         GError **error);

Retrieves the accelerometer data synchronously. See gfreenect_device_get_accel() for a non-blocking version of this method.

self :

The GFreenectDevice

x :

A pointer to retrieve the X-axis value of the accelerometer. [out][allow-none]

y :

A pointer to retrieve the Y-axis value of the accelerometer. [out][allow-none]

z :

A pointer to retrieve the Z-axis value of the accelerometer. [out][allow-none]

cancellable :

A cancellable object, or NULL. [allow-none]

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_get_depth_frame_grayscale ()

guint8 *            gfreenect_device_get_depth_frame_grayscale
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);

Retrieves one depth frame in RGB format using gray values to represent the depth. This method is useful for rendering the frame directly to an RGB capable texture. Optionally the frame metadata can also be retrieved providing a non-NULL pointer to a GFreenectFrameMode structure in frame_mode.

This method should only be called within a "depth-frame" signal handler, otherwise the returned values can be undefined.

self :

The GFreenectDevice

len :

A pointer to retrieve the length of the returned frame data. [out][allow-none]

frame_mode :

A GFreenectFrameMode structure to fill with the attributes of the frame. [out][allow-none]

Returns :

An array of len bytes representing the frame data. [array length=len][element-type guint8][transfer none]

gfreenect_device_get_depth_frame_raw ()

guint8 *            gfreenect_device_get_depth_frame_raw
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);

Retrieves one depth frame in raw format as provided by the lower levels. Optionally the frame metadata can also be retrieved providing a non-NULL pointer to a GFreenectFrameMode structure in frame_mode.

This method should only be called within a "depth-frame" signal handler, otherwise the returned values can be undefined.

self :

The GFreenectDevice

len :

A pointer to retrieve the length of the returned frame data. [out][allow-none]

frame_mode :

A GFreenectFrameMode structure to fill with the attributes of the frame. [out][allow-none]

Returns :

An array of len bytes representing the frame data. [array length=len][element-type guint8][transfer none]

gfreenect_device_get_tilt_angle ()

void                gfreenect_device_get_tilt_angle     (GFreenectDevice *self,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Asynchronously gets the current angle of the tilt motor. Use gfreenect_device_get_tilt_angle_finish() to obtain the results.

self :

The GFreenectDevice

cancellable :

A cancellable object, or NULL. [allow-none]

callback :

A function to be called upon completion, or NULL. [scope async][allow-none]

user_data :

An arbitrary user data to pass in callback, or NULL. [allow-none]

gfreenect_device_get_tilt_angle_finish ()

gdouble             gfreenect_device_get_tilt_angle_finish
                                                        (GFreenectDevice *self,
                                                         GAsyncResult *result,
                                                         GError **error);

Obtains the result of a gfreenect_device_get_tilt_angle() operation.

self :

The GFreenectDevice

result :

The GAsyncResult provided in the callback

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

The tilt motor angle, or 0.0 upon error. Notice that 0.0 is a valid return value so the error argument should also be checked.

gfreenect_device_get_tilt_angle_sync ()

gdouble             gfreenect_device_get_tilt_angle_sync
                                                        (GFreenectDevice *self,
                                                         GCancellable *cancellable,
                                                         GError **error);

Gets the current angle of the tilt motor synchronously. This is the blocking version of gfreenect_device_get_tilt_angle().

self :

The GFreenectDevice

cancellable :

A cancellable object, or NULL. [allow-none]

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

The tilt motor angle, or 0.0 upon error. Notice that 0.0 is a valid return value so the error argument should also be checked.

gfreenect_device_get_video_frame_raw ()

guint8 *            gfreenect_device_get_video_frame_raw
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);

Retrieves one video frame in raw format as provided by the lower levels. Optionally the frame metadata can also be retrieved providing a non-NULL pointer to a GFreenectFrameMode structure in frame_mode.

This method should only be called within a "video-frame" signal handler, otherwise the returned values can be undefined.

self :

The GFreenectDevice

len :

A pointer to retrieve the length of the returned frame data. [out][allow-none]

frame_mode :

A GFreenectFrameMode structure to fill with the attributes of the frame. [out][allow-none]

Returns :

An array of len bytes representing the frame data. [array length=len][element-type guint8][transfer none]

gfreenect_device_get_video_frame_rgb ()

guint8 *            gfreenect_device_get_video_frame_rgb
                                                        (GFreenectDevice *self,
                                                         gsize *len,
                                                         GFreenectFrameMode *frame_mode);

Retrieves one video frame in RGB format. A conversion to RGB is applied if the video format is set to IR (infra-red). This method is useful for rendering the frame directly to an RGB capable texture.

Optionally the frame metadata can also be retrieved providing a non-NULL pointer to a GFreenectFrameMode structure in frame_mode.

This method should only be called within a "depth-frame" signal handler, otherwise the returned values can be undefined.

self :

The GFreenectDevice

len :

A pointer to retrieve the length of the returned frame data. [out][allow-none]

frame_mode :

A GFreenectFrameMode structure to fill with the attributes of the frame. [out][allow-none]

Returns :

An array of len bytes representing the frame data. [array length=len][element-type guint8][transfer none]

gfreenect_device_new ()

void                gfreenect_device_new                (gint device_index,
                                                         guint subdevices,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Constructs a new GFreenectDevice object asynchronously. The actual instance is obtained with gfreenect_device_new_finish() when callback is called.

device_index :

The device index to use, normally 0 for one kinect sensor attached

subdevices :

Or'ed combination of subdevices to use from GFreenectSubdevice set

cancellable :

The cancellable object. [allow-none]

callback :

The callback to be called when the new instance is ready. [scope async]

user_data :

User data to pass in callback. [allow-none]

gfreenect_device_new_finish ()

GFreenectDevice *   gfreenect_device_new_finish         (GAsyncResult *result,
                                                         GError **error);

Returns the new instance of GFreenectDevice constructed with gfreenect_device_new(), or NULL if an error occurred, in which case error is set acordingly.

result :

The GAsyncResult provided in the callback

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

The newly created GFreenectDevice upon success, of NULL otherwise. [transfer full]

gfreenect_device_set_led ()

void                gfreenect_device_set_led            (GFreenectDevice *self,
                                                         GFreenectLed led,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Sets the status of the device's led asynchronously. Use gfreenect_device_set_led_finish() to obtain the result of the operation.

If this method is called while a previous operation has not completed, a G_IO_ERROR_PENDING error occurs.

self :

The GFreenectDevice

led :

A led status from GFreenectLed

cancellable :

A cancellable object, or NULL. [allow-none]

callback :

The function to call upon completion, or NULL. [scope async][allow-none]

user_data :

Arbitrary user data to pass in callback, or NULL. [allow-none]

gfreenect_device_set_led_finish ()

gboolean            gfreenect_device_set_led_finish     (GFreenectDevice *self,
                                                         GAsyncResult *result,
                                                         GError **error);

Obtains the result of a gfreenect_device_set_led() operation.

self :

The GFreenectDevice

result :

The GAsyncResult provided in the callback

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_set_tilt_angle ()

void                gfreenect_device_set_tilt_angle     (GFreenectDevice *self,
                                                         gdouble tilt_angle,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Moves the tilt motor angle to tilt_angle asynchronously. Acceptable values are in the range -31.0 to 31.0. Use gfreenect_device_set_tilt_angle_finish() to obtain the result of the operation.

If this method is called while a previous operation has not completed (the motor is still moving), a G_IO_ERROR_PENDING error occurs.

self :

The GFreenectDevice

tilt_angle :

The angle to move the tilt motor to

cancellable :

A cancellable object, or NULL. [allow-none]

callback :

The function to call upon completion, or NULL. [scope async][allow-none]

user_data :

Arbitrary user data to pass in callback, or NULL. [allow-none]

gfreenect_device_set_tilt_angle_finish ()

gboolean            gfreenect_device_set_tilt_angle_finish
                                                        (GFreenectDevice *self,
                                                         GAsyncResult *result,
                                                         GError **error);

Obtains the result of a gfreenect_device_set_tilt_angle() operation.

self :

The GFreenectDevice

result :

The GAsyncResult provided in the callback

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_start_depth_stream ()

gboolean            gfreenect_device_start_depth_stream (GFreenectDevice *self,
                                                         GFreenectDepthFormat format,
                                                         GError **error);

Starts the depth camera stream. After calling this, the "depth-frame" signal is triggered whenever a new frame is available. Use gfreenect_device_stop_depth_stream() to stop it.

self :

The GFreenectDevice

format :

A GFreenectDepthFormat to use

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_start_video_stream ()

gboolean            gfreenect_device_start_video_stream (GFreenectDevice *self,
                                                         GFreenectResolution resolution,
                                                         GFreenectVideoFormat format,
                                                         GError **error);

Starts the video camera stream. After calling this, the "video-frame" signal is triggered whenever a new frame is available. Use gfreenect_device_stop_video_stream() to stop it.

self :

The GFreenectDevice

resolution :

A GFreenectResolution to use

format :

A GFreenectVideoFormat to use

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_stop_depth_stream ()

gboolean            gfreenect_device_stop_depth_stream  (GFreenectDevice *self,
                                                         GError **error);

Stops the depth camera stream that was previously started with gfreenect_device_start_depth_stream().

self :

The GFreenectDevice

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

gfreenect_device_stop_video_stream ()

gboolean            gfreenect_device_stop_video_stream  (GFreenectDevice *self,
                                                         GError **error);

Stops the video camera stream that was previously started with gfreenect_device_start_video_stream().

self :

The GFreenectDevice

error :

A pointer to a GError, or NULL. [allow-none]

Returns :

TRUE on success or FALSE if an error occurred.

Property Details

The "index" property

  "index"                    gint                  : Read / Write / Construct Only

The index of the kinect device sensor in the bus. Normally zero for a single device.

Allowed values: [G_MAXULONG,8]

Default value: -1


The "led" property

  "led"                      guint                 : Read / Write

The status of the sensor's led, from GFreenectLed set.

Allowed values: <= 6

Default value: 0


The "subdevices" property

  "subdevices"               guint                 : Read / Write / Construct Only

The or'ed combination of subdevices from GFreenectSubdevice that have been activated.

Allowed values: <= 7

Default value: 3


The "tilt-angle" property

  "tilt-angle"               gdouble               : Read / Write

The sensor's tilt motor angle relative to the horizon.

Allowed values: [-31,31]

Default value: 0

Signal Details

The "depth-frame" signal

void                user_function                      (GFreenectDevice *self,
                                                        gpointer         user_data)      : Action

Called whenever a new depth frame is available. The depth stream has to be started with gfreenect_device_start_depth_stream().

self :

The GFreenectDevice

user_data :

user data set when the signal handler was connected.

The "video-frame" signal

void                user_function                      (GFreenectDevice *self,
                                                        gpointer         user_data)      : Action

Called whenever a new video frame is available. The video stream has to be started with gfreenect_device_start_video_stream().

self :

The GFreenectDevice

user_data :

user data set when the signal handler was connected.