leap

package module
v0.0.0-...-26f1b0f Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2014 License: MIT Imports: 6 Imported by: 4

README

leap

Documentation

Index

Constants

View Source
const (
	Hovering string = "hovering"
	None     string = "none"
	Touching string = "touching"
)

Variables

View Source
var (
	WSPort string = "6437"
	WSHost string = "127.0.0.1"
	WSURL  string = "ws://127.0.0.1:6437/v1.json"
)

Functions

This section is empty.

Types

type Device

type Device struct {
	Conn        *websocket.Conn
	Frames, Bin chan *Frame
	// contains filtered or unexported fields
}

func Dial

func Dial(url string) (*Device, error)

Dial try to connects to the websocket and if successful will start a goroutine to decode frames from the websocket and send them on the Device channel

func (*Device) Close

func (dev *Device) Close()

func (*Device) GestEnable

func (dev *Device) GestEnable(enable bool) error

enables or disables the gestures form the leapmotion

type Finger

type Finger struct {
	ID int `json: "id"`
	*Pointable
}

type Frame

type Frame struct {
	CurrentFrameRate float32        `json:"currentFrameRate"`
	Gestures         []Gesture      `json:"gestures"`
	Hands            []Hand         `json:"hands"`
	Pointables       []Pointable    `json:"pintables"`
	Fingers          []Pointable    `json:"fingers"`
	Tools            []Pointable    `json:"tools"`
	ID               int            `json:"id"`
	InteractionBox   InteractionBox `json:"interactionBox"`
	R                Matrix         `json:"r"`
	S                float32        `json:"s"`
	T                Vector         `json:"t"`
	// microseconds elapsed since the Leap started
	Timestamp time.Duration `json:"timestamp"`
}

type Gesture

type Gesture struct {
	ID            int           `json:"id"`
	State         string        `json:"state"`
	Type          string        `json:"type"`
	Duration      time.Duration `json:"duration"` //in microseconds
	HandIds       []int         `json:"handIds"`
	PointableIds  []int         `json:"pointableIds"`
	Speed         float32       `json:"speed"`
	Radius        float32       `json:"radius"`
	Progress      float32       `json:"progress"`
	Center        Vector        `json:"center"`
	Normal        Vector        `json:"normal"`
	StartPosition Vector        `json:"startPosition"`
	Position      Vector        `json:"position"`
	Direction     Vector        `json:"direction"`
}

type Hand

type Hand struct {
	Direction              Vector      `json:"direction"` //: array of floats (vector)
	Fingers                []Pointable `json:"fingers"`
	Tools                  []Pointable `json:"tools"`
	Pointables             []Pointable `json:"pointables"`
	ID                     int         `json:"id"`           //: integer
	PalmNormal             Vector      `json:"palmNormal"`   //: array of floats (vector)
	PalmPosition           Vector      `json:"palmPosition"` //: array of floats (vector)
	PalmVelocity           Vector      `json:"palmVelocity"` //: array of floats (vector)
	SphereCenter           Vector      `json:"sphereCenter"` //: array of floats (vector)
	SphereRadius           float32     `json:"sphereRadius"` //: float
	StabilizedPalmPosition Vector      `json:"stabilizedPalmPosition"`
	R                      Matrix      `json:"r"` //: nested arrays of floats (matrix)
	S                      float32     `json:"s"` //: float
	T                      Vector      `json:"t"` //: array of floats (vector)
	PinchStrength          float32     `json:"pinchStrength"`
	GrabStrength           float32     `json:"grabStrength"`
	Confidence             float32     `json:"confidence"`
	Type                   string      `json:"type"`
}

type InteractionBox

type InteractionBox struct {
	//Valid bool `json: "valid"`
	//The center of the InteractionBox in device coordinates (millimeters). This point is equidistant from all sides of the box
	Center Vector `json:"center"`
	Size   Vector `json:"size"`
}

func (*InteractionBox) DenormalizePoint

func (ib *InteractionBox) DenormalizePoint(p Vector) Vector

func (*InteractionBox) Norm

func (ib *InteractionBox) Norm(p Vector) Vector

homebrew

func (*InteractionBox) NormalizePoint

func (ib *InteractionBox) NormalizePoint(p Vector, clamp bool) Vector

from the JS API

type Matrix

type Matrix struct {
	glm.Matrix3
}

func (*Matrix) UnmarshalJSON

func (m *Matrix) UnmarshalJSON(data []byte) error

type Pointable

type Pointable struct {
	//Valid                 bool    `json: "valid"`
	Tool                  bool    `json:"tool"`
	ID                    int     `json:"id"`
	HandId                int     `json:"handId"`
	Length                float32 `json:"length"`
	Width                 float32 `json:"width"`
	Direction             Vector  `json:"direction"`
	TipPosition           Vector  `json:"tipPosition"`
	StabilizedTipPosition Vector  `json:"stabilizedTipPosition"`
	TipVelocity           Vector  `json:"tipVelocity"`
	TouchZone             string  `json:"touchZone"`
	TouchDistance         float32 `json:"touchDistance"`
	TimeVisible           float32 `json:"timeVisible"`
}

type Tool

type Tool struct {
	ID int `json: "id"`
	*Pointable
}

type Vector

type Vector struct {
	glm.Vector3
}
func (f *Frame) UnmarshalJSON(data []byte) error {
	err := json.Unmarshal(data, f)
	if err != nil {
		switch t := err.(type) {
		case *json.UnmarshalFieldError:
			log.Println(t)
		case *json.UnmarshalTypeError:
			log.Println(t)
		case *json.UnsupportedTypeError:
			log.Println(t)
		case *json.UnsupportedValueError:
			log.Println(t)
		case *json.SyntaxError:
			log.Println(t)
		case *json.InvalidUnmarshalError:
			log.Println(t)
		}
		return err
	}
	f.Timestamp *= time.Microsecond
	return nil
}

func (*Vector) UnmarshalJSON

func (v *Vector) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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