psycho-spy1.C
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 "GUI/GUIOpts.H"
00040 #include "Image/Image.H"
00041 #include "Psycho/PsychoDisplay.H"
00042 #include "Psycho/EyeTrackerConfigurator.H"
00043 #include "Psycho/EyeTracker.H"
00044 #include "Psycho/PsychoOpts.H"
00045 #include "Component/EventLog.H"
00046 #include "Component/ComponentOpts.H"
00047 #include "Raster/Raster.H"
00048 #include "Util/MathFunctions.H"
00049 #include "Util/Types.H"
00050
00051
00052 extern "C" int submain(const int argc, char** argv)
00053 {
00054 MYLOGVERB = LOG_INFO;
00055
00056
00057 ModelManager manager("Psycho Still");
00058
00059
00060 nub::soft_ref<PsychoDisplay> d(new PsychoDisplay(manager));
00061 manager.addSubComponent(d);
00062
00063 nub::soft_ref<EyeTrackerConfigurator>
00064 etc(new EyeTrackerConfigurator(manager));
00065 manager.addSubComponent(etc);
00066
00067 nub::soft_ref<EventLog> el(new EventLog(manager));
00068 manager.addSubComponent(el);
00069
00070 manager.setOptionValString(&OPT_EventLogFileName, "psychodata.psy");
00071 manager.setOptionValString(&OPT_EyeTrackerType, "ISCAN");
00072 manager.setOptionValString(&OPT_SDLdisplayDims, "1920x1080");
00073
00074
00075 if (manager.parseCommandLine(argc, argv,
00076 "<img1.ppm> ... <imgN.ppm>", 1, -1)==false)
00077 return(1);
00078
00079
00080 nub::soft_ref<EyeTracker> et = etc->getET();
00081 d->setEyeTracker(et);
00082 d->setEventLog(el);
00083 et->setEventLog(el);
00084
00085
00086 manager.start();
00087
00088
00089 d->clearScreen();
00090 d->displayISCANcalib();
00091 d->waitForKey();
00092
00093
00094 d->displayText("<SPACE> to calibrate; other key to skip");
00095 int c = d->waitForKey();
00096 if (c == ' ') d->displayEyeTrackerCalibration(3, 3, 1);
00097
00098 d->clearScreen();
00099 d->displayText("<SPACE> for random play; other key for ordered");
00100 c = d->waitForKey();
00101
00102
00103 uint nbimgs = manager.numExtraArgs(); int index[nbimgs];
00104 for (uint i = 0; i < nbimgs; i ++) index[i] = i;
00105 if (c == ' ') { LINFO("Randomizing images..."); randShuffle(index, nbimgs); }
00106
00107
00108 for (uint i = 0; i < nbimgs; i ++)
00109 {
00110
00111 d->clearScreen();
00112 LINFO("Loading '%s'...", manager.getExtraArg(index[i]).c_str());
00113 Image< PixRGB<byte> > image =
00114 Raster::ReadRGB(manager.getExtraArg(index[i]));
00115
00116 SDL_Surface *surf = d->makeBlittableSurface(image, true);
00117
00118 LINFO("'%s' ready.", manager.getExtraArg(index[i]).c_str());
00119 d->displayFixation();
00120
00121
00122 d->waitForKey();
00123 d->waitNextRequestedVsync(false, true);
00124 d->pushEvent(std::string("===== Showing image: ") +
00125 manager.getExtraArg(index[i]) + " =====");
00126
00127
00128 et->track(true);
00129
00130
00131 d->displayFixationBlink();
00132
00133
00134 d->displaySurface(surf, -2);
00135
00136
00137 SDL_FreeSurface(surf);
00138
00139
00140 while(d->checkForKey() != -1) ;
00141
00142
00143
00144 for (int j = 0; j < 150; j ++) d->waitNextRequestedVsync();
00145
00146
00147 d->clearScreen();
00148
00149
00150 usleep(50000);
00151 et->track(false);
00152
00153
00154 et->recalibrate(d,20);
00155
00156 }
00157
00158 d->clearScreen();
00159 d->displayText("Part 1 complete. Thank you!");
00160 d->waitForKey();
00161
00162
00163 manager.stop();
00164
00165
00166 return 0;
00167 }
00168
00169 extern "C" int main(const int argc, char** argv)
00170 {
00171
00172
00173
00174
00175 try
00176 {
00177 return submain(argc, argv);
00178 }
00179 catch (...)
00180 {
00181 REPORT_CURRENT_EXCEPTION;
00182 }
00183
00184 return 1;
00185 }
00186
00187
00188
00189
00190
00191