/************************************************/ /* File: fixget.cpp */ /* Author: Andrew R. Freed */ /* Modified date: 5/6/03 */ /* */ /* This feeds raw XY data into the fixation */ /* detection algorithm and creates a fixation */ /* log. */ /************************************************/ #include #include #include "fixfunc.c" //all the hard fixation detection in here void main() { //Literature suggests these values as default int min_fix_pts = 6; float gaze_deviation = 5; //Some parameters that the detection algorithm uses SFLOAT x_gaze_delayed; SFLOAT y_gaze_delayed; SBYTE gazepoint_found_delayed; SFLOAT x_fix_delayed; SFLOAT y_fix_delayed; SFLOAT gaze_deviation_delayed; SINT saccade_duration_delayed; SINT fix_duration_delayed; //Must initialize fixation algorithm with number of points // required in a fixation InitFixation(min_fix_pts); //Replace pathname with one that works! fstream fin; fin.open("C:\\Documents and Settings\\arf132\\My Documents\\Thesis\\eyetrack\\S9t1PIC.dat",ios::in); //Replace pathname with one that works! fstream fout; fout.open("C:\\Documents and Settings\\arf132\\My Documents\\Thesis\\eyetrack\\fixview\\debug\\s9t1-all.txt",ios::out); /***************************************************/ /* fin header - sample rate is 60Hz */ /* */ /* DATA AUX PLANE INT PT INT PT DISTANCE */ /* # # # X Y (in) */ /***************************************************/ int aux, plane; float distance, xpt, ypt; char data[7]; /* 10000 is hardcoded number of data points */ /* Increase if you use more than 10000 points */ int result; int oldresult=0; int i=0; int total_fixations = 0; while( i<10000 ) { //Read in data points once per iteration fin >> data >> aux >> plane >> xpt >> ypt >> distance; i++; //Call to the detection algorithm result = DetectFixation(plane,(float)xpt,(float)ypt,gaze_deviation,min_fix_pts, &gazepoint_found_delayed, &x_gaze_delayed, &y_gaze_delayed, &gaze_deviation_delayed, &x_fix_delayed, &y_fix_delayed, &saccade_duration_delayed, &fix_duration_delayed); double time; //Print out any detected fixation if(result == FIXATION_COMPLETED) { total_fixations++; time = ( ((double) i) / 60.0 ); if(time > 9.9) cout.precision(3); else if(time > 0.99) cout.precision(3); else cout.precision(2); cout << total_fixations; cout << " " << time << " " << (int) (x_fix_delayed*2) << " " << (int) (y_fix_delayed*2) << endl; if(time > 9.9) fout.precision(4); else if(time > 0.99) fout.precision(4); else fout.precision(3); fout << total_fixations; fout << " " << time << " " << (int) (x_fix_delayed*2) << " " << (int) (y_fix_delayed*2) << endl; } oldresult = result; } // cout << "min fix pts: " << min_fix_pts << endl // << "gaze_deviation: " << gaze_deviation << endl // << "total_fixations: " << total_fixations << endl; }