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