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
00087
00088 manager.start();
00089
00090 d->setEyeTracker(et);
00091 d->setEventLog(el);
00092
00093 el->pushEvent(std::string("===== Trial 1: ====="));
00094
00095
00096
00097
00098
00099 LINFO("eyescanner started going to start reading stuff");
00100
00101
00102 d->clearScreen();
00103 d->displayISCANcalib();
00104 d->waitForKey();
00105
00106 Image< PixRGB<byte> > displayImage (1920,1080, ZEROS);
00107 drawCircle(displayImage, Point2D<int>(1920/2,1080/2), 5, PixRGB<byte>(255,0,0));
00108
00109 SDL_Surface *surf = d->makeBlittableSurface(displayImage, true);
00110 d->displaySurface(surf, -2);
00111
00112 CalibrationTransform::Data pts;
00113 AffineTransform a;
00114 Image<double> txf;
00115 Point2D<int> testpoint;
00116 Point2D<double> testpointCalib,testpointD;
00117
00118 LINFO("precalib");
00119 pts = et->getCalibrationSet(d);
00120 LINFO("postcalib");
00121 txf = a.computeTransform(pts);
00122 LINFO("transform is...");
00123 std::cerr << txf << std::endl;
00124 testpoint = et->getEyePos();
00125 testpointD = Point2D<double>(testpoint);
00126 LINFO("\n testpoint %d,%d",testpoint.i,testpoint.j);
00127 testpointCalib = a.getCalibrated(testpointD);
00128 LINFO("\n testpoint %d,%d, calibrated %f,%f",testpoint.i,testpoint.j,testpointCalib.i,testpointCalib.j);
00129 d->clearScreen();
00130
00131
00132 char tmp[40];
00133
00134
00135
00136 while(d->checkForKey() < 0)
00137 {
00138 displayImage.clear();
00139 testpoint = et->getEyePos();
00140 testpointD = Point2D<double>(testpoint);
00141 testpointCalib = a.getCalibrated(testpointD);
00142 LINFO("\n testpoint %d,%d, calibrated %f,%f",testpoint.i,testpoint.j,testpointCalib.i,testpointCalib.j);
00143 drawCircle(displayImage, Point2D<int>(testpointCalib), 2, PixRGB<byte>(255,0,0));
00144 sprintf(tmp,"(%d,%d)",(int)testpointCalib.i,(int)testpointCalib.j);
00145 writeText(displayImage,Point2D<int>(testpointCalib),tmp,PixRGB<byte>(255,0,0),PixRGB<byte>(0,0,0),SimpleFont::FIXED(8));
00146
00147 SDL_Surface *surf2 = d->makeBlittableSurface(displayImage, true);
00148 d->displaySurface(surf2, -2);
00149 SDL_FreeSurface(surf2);
00150
00151
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 usleep(50000);
00165 et->track(false);
00166
00167 manager.stop();
00168
00169
00170 return 0;
00171
00172
00173 }
00174
00175 extern "C" int main(const int argc, char** argv)
00176 {
00177
00178 try
00179 {
00180 return submain(argc,argv);
00181 }
00182 catch (...)
00183 {
00184 REPORT_CURRENT_EXCEPTION;
00185 }
00186 return 1;
00187 }
00188
00189
00190
00191
00192
00193
00194
00195
00196