leap

package module
v0.0.0-...-90addea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

README

leap

Go API for Leap Motion devices.

This is a simple porting of the Leap Motion API on https://developer.leapmotion.com/documentation/javascript/supplements/Leap_JSON.html.

This is experimental and the API will probably change often, so use it at your own risks!

Documentation

Overview

This package provides a simple API to connect to a leap motion device and parse all the data sent by the device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

A Conn holds a connection to a leap motion device.

func Connect

func Connect(host string) (*Conn, error)

Connect connects to a leap device running on the given host, and checks the version running is correct.

func (*Conn) Close

func (c *Conn) Close()

Close closes the connection to the device.

func (*Conn) Decode

func (c *Conn) Decode(v interface{}) error

Decode uses the given value to decode the Frame sent from the device. This can be useful to minimize the amount of data decoded.

func (*Conn) Frame

func (c *Conn) Frame() (*Frame, error)

Frame returns the next Frame sent by the device.

type Frame

type Frame struct {
	CurrentFrameRate float64        `json:"currentFrameRate"`
	ID               float64        `json:"id"`
	R                [][]float64    `json:"r"`
	S                float64        `json:"s"`
	T                []float64      `json:"t"`
	Timestamp        int64          `json:"timestamp"`
	Gestures         []Gesture      `json:"gestures"`
	Hands            []Hand         `json:"hands"`
	InteractionBox   InteractionBox `json:"interactionBox"`
	Pointables       []Pointable    `json:"pointables"`
}

A Frame contains a snapshot of the data detected by the device.

type Gesture

type Gesture struct {
	Center        []float64    `json:"center"`    // circle only
	Direction     []float64    `json:"direction"` // swipe, keyTap, screenTap only
	Duration      int64        `json:"duration"`
	HandsIDs      []int        `json:"handIds"`
	ID            int          `json:"id"`
	Normal        []float64    `json:"normal"` // circle only
	PointableIDs  []int        `json:"pointableIds"`
	Position      []float64    `json:"position"`      // swipe, keyTap, screenTap only
	Progress      float64      `json:"progress"`      // circle, keyTap, screenTap only
	Radius        float64      `json:"radius"`        // circle only
	Speed         float64      `json:"speed"`         // swipe only
	StartPosition []float64    `json:"startPosition"` // swipe only
	State         GestureState `json:"state"`
	Type          GestureType  `json:"type"`
}

type GestureState

type GestureState string
const (
	Start  GestureState = "start"
	Update GestureState = "update"
	Stop   GestureState = "stop"
)

type GestureType

type GestureType string
const (
	Circle    GestureType = "circle"
	Swipe     GestureType = "swipe"
	KeyTap    GestureType = "keyTap"
	ScreenTap GestureType = "screenType"
)

type Hand

type Hand struct {
	Direction              []float64   `json:"direction"`
	ID                     int         `json:"id"`
	PalmNormal             []float64   `json:"palmNormal"`
	PalmPosition           []float64   `json:"palmPosition"`
	PalmVelocity           []float64   `json:"palmVelocity"`
	R                      [][]float64 `json:"r"`
	S                      float64     `json:"s"`
	SphereCenter           []float64   `json:"sphereCenter"`
	SphereRadius           float64     `json:"sphereRadius"`
	StabilizedPalmPosition []float64   `json:"stabilizedPalmPosition"`
	T                      []float64   `json:"t"`
	TimeVisible            float64     `json:"timeVisible"`
}

type InteractionBox

type InteractionBox struct {
	Center []float64 `json:"center"`
	Size   []float64 `json:"size"`
}

type Pointable

type Pointable struct {
	Direction             []float64 `json:"direction"`
	HandID                int       `json:"handId"`
	ID                    int       `json:"id`
	Length                float64   `json:"length"`
	StabilizedTipPosition []float64 `json:"stabilizedTipPosition"`
	TimeVisible           float64   `json:"timeVisible"`
	TipPosition           []float64 `json:"tipPosition"`
	TipVelocity           []float64 `json:"tipVelocity"`
	Tool                  bool      `json:"tool"`
	TouchDistance         float64   `json:"touchDistance"`
	TouchZone             TouchZone `json:"touchZone"`
}

type TouchZone

type TouchZone string
const (
	None     TouchZone = "none"
	Hovering TouchZone = "hovering"
	Touching TouchZone = "touching"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL