Gomotion is a framework that uses the WebSocket protocol to communicate with a LeapMotion device.
- Dead simple to use.
- Frame collection happens concurrently
- JSON comes back parsed and placed into structs for handling.
http://godoc.org/github.com/whoisjake/gomotion
In your $GOPATH:
$ cd $GOPATH
$ go get github.com/whoisjake/gomotion
And then: import "github.com/whoisjake/gomotion"
package main
import (
"github.com/whoisjake/gomotion"
"log"
"runtime"
)
func main() {
// Get a device.
runtime.GOMAXPROCS(runtime.NumCPU())
device, err := gomotion.GetDevice("ws://127.0.0.1:6437/v3.json")
if err != nil {
log.Fatal(err)
}
device.Listen()
defer device.Close()
for frame := range device.Pipe {
log.Printf("%+v\n", frame)
}
}