Ejemplo n.º 1
0
func calibratePoint(et gaze.EyeTracker, x, y float64) {
	termbox.Clear(0, 0)
	sizeX, sizeY := termbox.Size()
	dx, dy := int(float64(sizeX)*x), int(float64(sizeY)*y)
	termbox.CellBuffer()[sizeX*dy+dx] = termbox.Cell{'#', marker, termbox.ColorDefault}
	termbox.Flush()
	//log.Printf("Termbox Size: (%d, %d)", sizeX, sizeY)
	log.Printf("Calibrating (%.3f, %.3f)", x, y)
	done := make(chan struct{})
	time.Sleep(1 * time.Second) //Minimum time. Gives user time to react.
	et.AddPointToCalibration(gaze.NewPoint2D(x, y), func(err error) {
		close(done) //Synchronizing async call.
	})
	<-done
}
Ejemplo n.º 2
0
func main() {
	flag.Parse()
	log.Println("Creating tracker...")
	var et *gaze.EyeTracker
	var err error
	if *auto {
		et, err = gaze.AnyEyeTracker()
	} else {
		url := flag.Arg(0)
		et, err = gaze.EyeTrackerFromURL(url)
	}

	if err != nil {
		log.Fatalln("Error:", err)
	}

	defer et.Close()
	log.Println("Tracker created.")
	log.Println("Connecting to tracker.")

	checked(et.Connect())

	log.Println("Connected!")

	info, err := et.Info()

	checked(err)

	log.Println(info)

	et.StartTracking(func(data *gaze.GazeData) {
		ts := data.TrackingStatus()
		if ts >= gaze.BothEyesTracked && ts != gaze.OneEyeTrackedUnknownWhich {
			fmt.Println(data)
		}
	})

	time.Sleep(time.Second * 30)
}