00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "Component/ModelManager.H"
00039 #include "Image/Image.H"
00040 #include "Psycho/PsychoDisplay.H"
00041 #include "Psycho/EyeTrackerConfigurator.H"
00042 #include "Psycho/EyeTracker.H"
00043 #include "Psycho/PsychoOpts.H"
00044 #include "Component/EventLog.H"
00045 #include "Component/ComponentOpts.H"
00046 #include "Raster/Raster.H"
00047 #include "Util/MathFunctions.H"
00048 #include "Util/Types.H"
00049 #include "Image/DrawOps.H"
00050 #include "Image/CalibrationTransform.H"
00051 #include "Image/AffineTransform.H"
00052 #include "Image/IO.H"
00053
00054 static int submain(const int argc, char** argv)
00055 {
00056
00057 MYLOGVERB = LOG_INFO;
00058
00059
00060
00061
00062 ModelManager manager("test get eye position");
00063
00064 nub::soft_ref<EyeTrackerConfigurator>
00065 etc(new EyeTrackerConfigurator(manager));
00066 manager.addSubComponent(etc);
00067
00068 nub::soft_ref<EventLog> el(new EventLog(manager));
00069 manager.addSubComponent(el);
00070
00071 nub::soft_ref<PsychoDisplay> d(new PsychoDisplay(manager));
00072 manager.addSubComponent(d);
00073
00074
00075 manager.setOptionValString(&OPT_EventLogFileName, "psychodata.psy");
00076 manager.setOptionValString(&OPT_EyeTrackerType, "ISCAN");
00077
00078
00079 if (manager.parseCommandLine(argc, argv, "", 0, 0) == false)
00080 return(1);
00081
00082
00083
00084 nub::soft_ref<EyeTracker> et = etc->getET();
00085 et->setEventLog(el);
00086 et->requestQuickEyeS();
00087
00088
00089 manager.start();
00090
00091 d->setEyeTracker(et);
00092 d->setEventLog(el);
00093
00094 el->pushEvent(std::string("===== Trial 1: ====="));
00095
00096
00097
00098
00099
00100 LINFO("eyescanner started going to start reading stuff");
00101
00102
00103 d->clearScreen();
00104 d->displayISCANcalib();
00105 d->waitForKey();
00106
00107 Image< PixRGB<byte> > displayImage (1920,1080, ZEROS);
00108 drawCircle(displayImage, Point2D<int>(1920/2,1080/2), 5, PixRGB<byte>(255,0,0));
00109
00110 SDL_Surface *surf = d->makeBlittableSurface(displayImage, true);
00111 d->displaySurface(surf, -2);
00112 et->calibrateOnline(d);
00113 Image<double> txf;
00114 Point2D<int> testpoint;
00115 Point2D<int> testpointCalib,testpointD;
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 testpoint = et->getEyePos();
00126 testpointCalib = et->getCalibEyePos();
00127 LINFO("\n testpoint %d,%d, calibrated %d,%d",testpoint.i,testpoint.j,testpointCalib.i,testpointCalib.j);
00128
00129 d->clearScreen();
00130 char tmp[40];
00131 SDL_Surface *surf2;
00132 LINFO("ready to set tracker to true");
00133 et->track(true);
00134 while(d->checkForKey() < 0)
00135 {
00136 displayImage.clear();
00137 testpointCalib = et->getCalibEyePos();
00138 LINFO("\n testpoint %d,%d, calibrated %d,%d",testpoint.i,testpoint.j,testpointCalib.i,testpointCalib.j);
00139
00140 if(displayImage.coordsOk(testpointCalib))
00141 {
00142 drawCircle(displayImage, Point2D<int>(testpointCalib), 2, PixRGB<byte>(255,0,0));
00143 sprintf(tmp,"(%d,%d)",(int)testpointCalib.i,(int)testpointCalib.j);
00144 writeText(displayImage,Point2D<int>(testpointCalib),tmp,PixRGB<byte>(255,0,0),PixRGB<byte>(0,0,0),SimpleFont::FIXED(8));
00145 surf2 = d->makeBlittableSurface(displayImage, true);
00146 d->displaySurface(surf2, -2);
00147 SDL_FreeSurface(surf2);
00148 }
00149
00150
00151 }
00152
00153
00154
00155 usleep(50000);
00156 et->track(false);
00157
00158 manager.stop();
00159
00160
00161 return 0;
00162
00163
00164 }
00165
00166 extern "C" int main(const int argc, char** argv)
00167 {
00168
00169 try
00170 {
00171 return submain(argc,argv);
00172 }
00173 catch (...)
00174 {
00175 REPORT_CURRENT_EXCEPTION;
00176 }
00177 return 1;
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187