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