Exemplo n.º 1
0
func main() {
	termbox.Init()
	defer termbox.Close()

	et, err := gaze.AnyEyeTracker()

	if err != nil {
		log.Println(err)
		return
	}

	et.Connect()
	defer et.Close()

	done := make(chan struct{})

	et.StartCalibration(func(err error) {
		if err != nil {
			log.Println("Could not start calibrating:", err)
			close(done)
			return
		}
		calibratePoint(et, 0.1, 0.1)
		calibratePoint(et, 0.9, 0.1)
		calibratePoint(et, 0.9, 0.9)
		calibratePoint(et, 0.1, 0.9)
		calibratePoint(et, 0.5, 0.5)
		et.ComputeAndSetCalibration(func(err error) {
			et.StopCalibration(func(err error) {
				defer close(done)
				if err != nil {
					log.Println("Could not start calibrating:", err)
					return
				}
			})
		})
	})
	points, err := et.CalibrationPoints()
	fmt.Println()
	<-done
}
Exemplo 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)
}
Exemplo n.º 3
0
func main() {
	termbox.Init()
	defer termbox.Close()

	et, err := gaze.AnyEyeTracker()

	if err != nil {
		log.Println(err)
		return
	}

	et.Connect()
	defer et.Close()
	termbox.Clear(0, termbox.ColorWhite) //Set bg to white.
	et.StartTracking(func(data *gaze.GazeData) {
		ts := data.TrackingStatus()
		if ts >= gaze.BothEyesTracked && ts != gaze.OneEyeTrackedUnknownWhich {
			termbox.Clear(0, termbox.ColorWhite)
			drawPoint(*data.Left().GazePointOnDisplay(), leftMarker)
			drawPoint(*data.Right().GazePointOnDisplay(), rightMarker)
			termbox.Flush()
		}
	})

	done := make(chan struct{})

	go func() {
		for {
			event := termbox.PollEvent()
			if event.Type == termbox.EventKey && event.Key == termbox.KeyEsc {
				close(done)
			}
		}
	}()

	<-done
}