psycho-mplayer.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 #ifndef APPPSYCHO_PSYCHO_MPLAYER_C_DEFINED
00039 #define APPPSYCHO_PSYCHO_MPLAYER_C_DEFINED
00040
00041 #include "Component/ModelManager.H"
00042 #include "Psycho/MPlayerWrapper.H"
00043 #include "Component/ComponentOpts.H"
00044 #include "Media/MediaOpts.H"
00045 #include <stdio.h>
00046 #include "Media/MPEGStream.H"
00047 #include "Psycho/EyeTrackerConfigurator.H"
00048 #include "Psycho/EyeTracker.H"
00049 #include "Psycho/PsychoOpts.H"
00050 #include <unistd.h>
00051
00052 int submain(const int argc, char ** argv)
00053 {
00054 ModelManager manager("Psycho-mplayer");
00055
00056 nub::soft_ref<EventLog> log(new EventLog(manager));
00057 nub::soft_ref<MPlayerWrapper> player(new MPlayerWrapper(manager));
00058 nub::soft_ref<PsychoDisplay> display(new PsychoDisplay(manager));
00059 nub::soft_ref<EyeTrackerConfigurator>
00060 configurator(new EyeTrackerConfigurator(manager));
00061
00062
00063
00064 manager.addSubComponent(configurator);
00065 manager.addSubComponent(player);
00066 manager.addSubComponent(log);
00067 manager.addSubComponent(display);
00068
00069
00070 if (manager.parseCommandLine(argc, argv,
00071 "<movie1.mpg> ... <movieN.mpg>", 1, -1)==false)
00072 return(1);
00073
00074
00075
00076 manager.setOptionValString(&OPT_EyeTrackerType, "ISCAN");
00077
00078
00079 nub::soft_ref<EyeTracker> tracker = configurator->getET();
00080 display->setEyeTracker(tracker);
00081 display->setEventLog(log);
00082 tracker->setEventLog(log);
00083 player->setEventLog(log);
00084
00085
00086 if (configurator->getModelParamString("EyeTrackerType").compare("EL") == 0)
00087 display->setModelParamVal("SDLslaveMode", true);
00088
00089
00090 manager.start();
00091
00092
00093 tracker->calibrate(display);
00094 display->clearScreen();
00095 display->displayText("<SPACE> for random play; other key for ordered");
00096
00097 int c;
00098 c = display->waitForKey(true);
00099
00100
00101 uint nbmovies = manager.numExtraArgs(); int index[nbmovies];
00102 for (uint i = 0; i < nbmovies; i++) index[i]=i;
00103 if(c == ' ')
00104 {
00105 LINFO("Randomizing movies...");
00106 randShuffle(index, nbmovies);
00107 }
00108
00109 for(uint i = 0; i < nbmovies; i++)
00110 {
00111 display->clearScreen();
00112
00113 LDEBUG("Playing '%s'...",manager.getExtraArg(index[i]).c_str());
00114 player->setSourceVideo(manager.getExtraArg(index[i]));
00115
00116
00117 sleep(1); if (system("/bin/sync")) LERROR("error in sync");
00118
00119
00120 display->displayFixation();
00121
00122
00123 display->waitForKey(true);
00124 display->waitNextRequestedVsync(false, true);
00125 display->displayFixationBlink();
00126
00127 tracker->track(true);
00128 player->runfromSDL(display);
00129
00130 usleep(50000);
00131 tracker->track(false);
00132
00133 display->clearScreen();
00134
00135 if(i%2==1 && i != nbmovies-1) tracker->recalibrate(display,13);
00136 }
00137
00138
00139 display->clearScreen();
00140 display->displayText("Experiment complete. Thank you for participating!");
00141 display->waitForKey(true);
00142
00143
00144
00145 manager.stop();
00146 return 0;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 int main(const int argc, char **argv)
00156 {
00157 try
00158 {
00159 return submain(argc, argv);
00160 }
00161 catch (...)
00162 {
00163 REPORT_CURRENT_EXCEPTION;
00164 }
00165
00166 return 1;
00167 }
00168 #endif // APPPSYCHO_PSYCHO_MPLAYER_C_DEFINED