Skip to content
buka edited this page Mar 19, 2012 · 1 revision
import "freenect"
Overview
Index

Overview

go-freenect is a wrapper for the libfreenect C library.

Index

Constants
type DepthCamera
    func (camera *DepthCamera) Start() int
    func (camera *DepthCamera) Stop() int
type DepthFormat
type DepthSink
type DepthSource
type Device
    func (device *Device) Close() int
    func (device *Device) DepthCamera(res Resolution, fmt DepthFormat, source DepthSource, sink DepthSink) (*DepthCamera, int)
    func (device *Device) GetTilt() *Tilt
    func (device *Device) LED(option LEDOption) int
    func (device *Device) Open() int
    func (device *Device) VideoCamera(res Resolution, fmt VideoFormat, source VideoSource, sink VideoSink) (*VideoCamera, int)
type Freenect
    func Initialize() (*Freenect, int)
    func (freenect *Freenect) Log(logger Logger)
    func (freenect *Freenect) LogLevel(level LoggerLevel)
    func (freenect *Freenect) Shutdown() int
type LEDOption
type Logger
type LoggerLevel
type Resolution
type Tilt
    func (tilt *Tilt) Refresh()
    func (tilt *Tilt) SetAngle(deg float64) int
type VideoCamera
    func (camera *VideoCamera) Start() int
    func (camera *VideoCamera) Stop() int
type VideoFormat
type VideoSink
type VideoSource

Package files

freenect.go

Constants

const (
    LogFatal   = LoggerLevel(C.FREENECT_LOG_FATAL)
    LogError   = LoggerLevel(C.FREENECT_LOG_ERROR)
    LogWarning = LoggerLevel(C.FREENECT_LOG_WARNING)
    LogNotice  = LoggerLevel(C.FREENECT_LOG_NOTICE)
    LogInfo    = LoggerLevel(C.FREENECT_LOG_INFO)
    LogDebug   = LoggerLevel(C.FREENECT_LOG_DEBUG)
    LogSpew    = LoggerLevel(C.FREENECT_LOG_SPEW)
    LogFlood   = LoggerLevel(C.FREENECT_LOG_FLOOD)
)
const (
    LOW    = Resolution(C.FREENECT_RESOLUTION_LOW)
    MEDIUM = Resolution(C.FREENECT_RESOLUTION_MEDIUM)
    HIGH   = Resolution(C.FREENECT_RESOLUTION_HIGH)
)
const (
    RGB             = VideoFormat(C.FREENECT_VIDEO_RGB)
    BAYER           = VideoFormat(C.FREENECT_VIDEO_BAYER)
    IR_8BIT         = VideoFormat(C.FREENECT_VIDEO_IR_8BIT)
    IR_10BIT        = VideoFormat(C.FREENECT_VIDEO_IR_10BIT)
    IR_10BIT_PACKED = VideoFormat(C.FREENECT_VIDEO_IR_10BIT_PACKED)
    YUV_RGB         = VideoFormat(C.FREENECT_VIDEO_YUV_RGB)
    YUV_RAW         = VideoFormat(C.FREENECT_VIDEO_YUV_RAW)
)
const (
    D11BIT        = DepthFormat(C.FREENECT_DEPTH_11BIT)
    D10BIT        = DepthFormat(C.FREENECT_DEPTH_10BIT)
    D11BIT_PACKED = DepthFormat(C.FREENECT_DEPTH_11BIT_PACKED)
    D10BIT_PACKED = DepthFormat(C.FREENECT_DEPTH_10BIT_PACKED)
    REGISTERED    = DepthFormat(C.FREENECT_DEPTH_REGISTERED)
    MM            = DepthFormat(C.FREENECT_DEPTH_MM)
)
const (
    OFF              = LEDOption(C.LED_OFF)
    GREEN            = LEDOption(C.LED_GREEN)
    RED              = LEDOption(C.LED_RED)
    YELLOW           = LEDOption(C.LED_YELLOW)
    BLINK_GREEN      = LEDOption(C.LED_BLINK_GREEN)
    BLINK_RED_YELLOW = LEDOption(C.LED_BLINK_RED_YELLOW)
)
const (
    TILT_STOPPED  = int(C.TILT_STATUS_STOPPED)
    TILT_AT_LIMIT = int(C.TILT_STATUS_LIMIT)
    TILT_MOVING   = int(C.TILT_STATUS_MOVING)
)
type DepthCamera struct {
    <span class="comment">// contains filtered or unexported fields</span>
}

This type represents the depth camera on the device. It can be acquired via the Device function of the same name.

func (*DepthCamera) Start

func (camera *DepthCamera) Start() int

Starts the acquisition of the depth stream. The source function will be invoked to obtain the first frame buffer.

func (*DepthCamera) Stop

func (camera *DepthCamera) Stop() int

Stops the acquisition of the depth stream.

type DepthFormat int32

type DepthSink

type DepthSink func(buffer []uint16, stamp int32)

Type definition for function used to receive depth frames from the device.

type DepthSource func(bytes int) []uint16

Type definition for function used to provide depth buffers to the device.

type Device

type Device struct {
    <span class="comment">// contains filtered or unexported fields</span>
}

A freenect device context.

func (*Device) Close

func (device *Device) Close() int

Closes the device and releases its resources.

func (*Device) DepthCamera

func (device *Device) DepthCamera(res Resolution, fmt DepthFormat, source DepthSource, sink DepthSink) (*DepthCamera, int)

This function creates a new structure representing a fixed format and resolution depth stream. Note the parameters will be validated and the corresponding depth mode will be set, but the stream will not be started. BUG(g): The depth mode is set here instead of on Start() which means we can't reset the camera...

func (*Device) GetTilt

func (device *Device) GetTilt() *Tilt

Returns a structure that can be used to control or read data from the motor controller. While this function will refresh the tilt state info from the device, if you're going to be reading values off the device, it's really necessary to be calling Refresh() on a draw/game loop or go routine, otherwise the data will be stale.

func (*Device) LED

func (device *Device) LED(option LEDOption) int

Sets the LED option - a combination of color and blink.

func (*Device) Open

func (device *Device) Open() int

Opens the device and prepares it for use. This must be the first call made on the Device.

func (*Device) VideoCamera

func (device *Device) VideoCamera(res Resolution, fmt VideoFormat, source VideoSource, sink VideoSink) (*VideoCamera, int)

This function creates a new structure representing a fixed format and resolution video stream. Note the parameters will be validated and the corresponding video mode will be set, but the stream will not be started. BUG(g): The video mode is set here instead of on Start() which means we can't reset the camera...

type Freenect

type Freenect struct {
    Devices []Device
    <span class="comment">// contains filtered or unexported fields</span>
}

The freenect library context. Once initialized, any attached and support devices are available via the Devices member.

func Initialize() (*Freenect, int)

This function inititalize the freenect library, selects the motor and camera subdevices and begins the event processing loop. Event processing occurs in a go routine that will be terminated upon a call to Shutdown()

func (*Freenect) Log

func (freenect *Freenect) Log(logger Logger)

Assigns a new logging callback function. Only one will be used; provide nil to stop receiving log messages from libfreenect.

func (*Freenect) LogLevel

func (freenect *Freenect) LogLevel(level LoggerLevel)

Sets a new log message level to control the verbosity of information coming from libfreenect.

func (*Freenect) Shutdown

func (freenect *Freenect) Shutdown() int

Shuts down the current [initialized] Freenect context.

type LEDOption

type LEDOption int

type Logger

type Logger func(level int, message string)

Type definition for the freenect context logger callback.

type LoggerLevel int
type Resolution int32

type Tilt

type Tilt struct {
    Angle  float32
    Status int
    AccelX float32
    AccelY float32
    AccelZ float32
    <span class="comment">// contains filtered or unexported fields</span>
}

This type represents the tilt and motor controls.

func (*Tilt) Refresh

func (tilt *Tilt) Refresh()

Tells the device to update it's state data. If you're going to be reading values off the device, it's really necessary to be calling this function on a draw/game loop or go routine, otherwise the data will be stale.

func (*Tilt) SetAngle

func (tilt *Tilt) SetAngle(deg float64) int

Sets the desired target angle (in degrees) of the device and starts the motor (if necessary). Note that range is something like +- 27 degrees.

type VideoCamera struct {
    <span class="comment">// contains filtered or unexported fields</span>
}

This type represents the video camera on the device. It can be acquired via the Device function of the same name.

func (*VideoCamera) Start

func (camera *VideoCamera) Start() int

Starts the acquisition of the video stream. The source function will be invoked to obtain the first frame buffer.

func (*VideoCamera) Stop

func (camera *VideoCamera) Stop() int

Stops the acquisition of the video stream.

type VideoFormat int32

type VideoSink

type VideoSink func(buffer []byte, stamp int32)

Type definition for function used to receive video frames from the device.

type VideoSource func(bytes int) []byte

Type definition for function used to provide video buffers to the device.