Skip to content

Instantly share code, notes, and snippets.

@kristienooms
Last active November 18, 2015 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristienooms/4c8df53f3800f46b1958 to your computer and use it in GitHub Desktop.
Save kristienooms/4c8df53f3800f46b1958 to your computer and use it in GitHub Desktop.
The Eye Tribe Tracker - Record raw data in txt-file - JAVA
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.theeyetribe.client.GazeManager;
import com.theeyetribe.client.GazeManager.ApiVersion;
import com.theeyetribe.client.GazeManager.ClientMode;
import com.theeyetribe.client.IGazeListener;
import com.theeyetribe.client.data.GazeData;
public class TETsimple
{
public static void main(String[] args)
{
logData("gd_le_pcc_x,gd_le_pcc_y,gd_le_ps,gd_le_rc_x,gd_le_rc_y,gd_le_sc_x,gd_le_sc_y,gd_re_pcc_x,gd_re_pcc_y,gd_re_ps,gd_re_rc_x,gd_re_rc_y,gd_re_sc_x,gd_re_sc_y,gd_rc_x ,gd_rc_y,gd_sc_x ,gd_sc_y,gd_if,gd_s,gd_ts,gd_tss,gd_STE,gd_STF,gd_STG,gd_STL,gd_STP");
final GazeManager gm = GazeManager.getInstance();
boolean success = gm.activate(ApiVersion.VERSION_1_0, ClientMode.PUSH);
final GazeListener gazeListener = new GazeListener();
gm.addGazeListener(gazeListener);
//TODO: Do awesome gaze control wizardry
//shutDown
Runtime.getRuntime().addShutdownHook(new Thread()
{
@Override
public void run()
{
gm.removeGazeListener(gazeListener);
gm.deactivate();
}
});
}
public static void logData(String data){
try {
String fileName= "data/demoETs.txt";
Writer output = new BufferedWriter(new FileWriter(fileName, true));
output.write(data+"\n");
output.flush();
} catch (IOException ex) {
java.util.logging.Logger.getLogger(Logger.class.getName()).log(Level.SEVERE, null, ex);
}
}
private static class GazeListener implements IGazeListener
{
double gd_le_pcc_x;
double gd_le_pcc_y;
double gd_le_ps;
double gd_le_rc_x;
double gd_le_rc_y;
double gd_le_sc_x;
double gd_le_sc_y;
double gd_re_pcc_x;
double gd_re_pcc_y;
double gd_re_ps;
double gd_re_rc_x;
double gd_re_rc_y;
double gd_re_sc_x;
double gd_re_sc_y;
double gd_rc_x;
double gd_rc_y;
double gd_sc_x;
double gd_sc_y;
boolean gd_if;
int gd_s;
long gd_ts;
String gd_tss;
int gd_STE;
int gd_STF;
int gd_STG;
int gd_STL;
int gd_STP;
String data;
@Override
public void onGazeUpdate(GazeData gazeData)
{
System.out.println(gazeData.toString());
System.out.println(gazeData.smoothedCoordinates.x);
System.out.println(gazeData.smoothedCoordinates.y);
System.out.println(gazeData.timeStampString);
gd_sc_x = gazeData.smoothedCoordinates.x;
gd_sc_y = gazeData.smoothedCoordinates.y;
gd_tss=gazeData.timeStampString;
gd_le_pcc_x= gazeData.leftEye.pupilCenterCoordinates.x;
gd_le_pcc_y=gazeData.leftEye.pupilCenterCoordinates.y;
gd_le_ps=gazeData.leftEye.pupilSize;
gd_le_rc_x=gazeData.leftEye.rawCoordinates.x;
gd_le_rc_y=gazeData.leftEye.rawCoordinates.y;
gd_le_sc_x=gazeData.leftEye.smoothedCoordinates.x;
gd_le_sc_y=gazeData.leftEye.smoothedCoordinates.y;
gd_re_pcc_x= gazeData.rightEye.pupilCenterCoordinates.x;
gd_re_pcc_y=gazeData.rightEye.pupilCenterCoordinates.y;
gd_re_ps=gazeData.rightEye.pupilSize;
gd_re_rc_x=gazeData.rightEye.rawCoordinates.x;
gd_re_rc_y=gazeData.rightEye.rawCoordinates.y;
gd_re_sc_x=gazeData.rightEye.smoothedCoordinates.x;
gd_re_sc_y=gazeData.rightEye.smoothedCoordinates.y;
gd_rc_x=gazeData.rawCoordinates.x;
gd_rc_y=gazeData.rawCoordinates.y;
gd_sc_x = gazeData.smoothedCoordinates.x;
gd_sc_y = gazeData.smoothedCoordinates.y;
gd_if=gazeData.isFixated;
gd_s=gazeData.state;
gd_ts=gazeData.timeStamp;
gd_tss=gazeData.timeStampString;
gd_STE=gazeData.STATE_TRACKING_EYES;
gd_STF=gazeData.STATE_TRACKING_FAIL;
gd_STG=gazeData.STATE_TRACKING_GAZE;
gd_STL=gazeData.STATE_TRACKING_LOST;
gd_STP=gazeData.STATE_TRACKING_PRESENCE;
data =gd_le_pcc_x+","+gd_le_pcc_y +","+gd_le_ps+","+gd_le_rc_x+","+gd_le_rc_y+","+gd_le_sc_x+","+gd_le_sc_y+","+gd_re_pcc_x+","+gd_re_pcc_y+","+gd_re_ps+","+gd_re_rc_x+","+gd_re_rc_y+","+gd_re_sc_x+","+gd_re_sc_y+","+gd_rc_x +","+gd_rc_y+","+gd_sc_x +","+gd_sc_y+","+gd_if+","+gd_s+","+gd_ts+","+gd_tss+","+gd_STE+","+gd_STF+","+gd_STG+","+gd_STL+","+gd_STP;
logData(data);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment