本文整理汇总了C++中ParametersLoader类的典型用法代码示例。如果您正苦于以下问题:C++ ParametersLoader类的具体用法?C++ ParametersLoader怎么用?C++ ParametersLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParametersLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initTrial
void initTrial()
{
// --- initializing all variables
// pick up[ the current size
if(training)
sizeNow = trial[round].getCurrent()["Size"];
else
sizeNow = round;
diameter = depthCyl[sizeNow];
if(training)
condition = "training";
else
condition = "catch";
// pick up the next size
// if it's training...
if(training)
{
// if there is another trial after the current...
if(trial[round].hasNext())
sizeNext = trial[round].getFullExtractions().at(trialNumber+1)["Size"];
else // else if the next trial is a catch trial
sizeNext = round;
}
// else if it's catch...
else
{
// if there is another catch trial...
if(trialNumber+1 < str2num<int>(parameters.find("numCatchTrials")))
sizeNext = round;
else if(round<ROUNDS-1) // else if there is another round after the current...
sizeNext = trial[round+1].getFullExtractions().at(0)["Size"];
else // else the next trial is 99 (exp will be over)
sizeNext = 99;
}
pickedUp=false; // has the obj been lifted?
noVisibleFingers=0;
frameN=0;
handAtStart=true;
fingersOccluded = 0;
// turn the screen black
isStimulusDrawn=false;
// rebuffer the openGL scene
drawGLScene();
// move the platform
// if it's the first trial of the first round (of the training)...
if(trialNumber==0 && training && round==0)
{
// calibrate the platform
platformPos = markers[4].p.transpose();
// move it first up
Vector3d pos0(0,-175,0); // desired location
moveObjectAbsolute(pos0, platformPos, 6000);
}
// move object to middle position
Vector3d pos1(0,-175,middlePos); // desired location
moveObjectAbsolute(pos1, platformPos, 6000);
// object's exact location depends on the current test condition
// if it's a training trial[round]...
if(training)
objLocation = str2num<double>(parameters.find("TrainingDist"));
else // else if it's a catch trial[round]...
objLocation = str2num<double>(parameters.find("CatchDist"));
// move object to location
Vector3d pos2(0,-175,objLocation); // desired location
moveObjectAbsolute(pos2, platformPos, 6000);
// update markers
optotrak->updateMarkers();
// put new values into markers
markers = optotrak->getAllMarkers();
// initialize the pagnet's position to magnetPos
magnetPos = markers[3].p.transpose()[1];
// move the screen to middle position
initProjectionScreen(middlePos);
// move the screen to location
initProjectionScreen(objLocation);
// open the trial file, where we record online movements
// setting file's name
if(training)
trialFileName = "C:/Users/visionlab/Google Drive/DATA/SizeWeightIllusion/" + parameters.find("SubjectName") + "/" + parameters.find("SubjectName") + "_round_" + stringify<double>(round) + "trial_" + stringify<double>(trialNumber) + "training.txt";
else
trialFileName = "C:/Users/visionlab/Google Drive/DATA/SizeWeightIllusion/" + parameters.find("SubjectName") + "/" + parameters.find("SubjectName") + "_round_" + stringify<double>(round) + "trial_" + stringify<double>(trialNumber) + "catch.txt";
// creating-opening the file
trialFile.open(trialFileName.c_str());
// writing the first line of the file (headers)
trialFile << fixed << "subjName" << "\t" <<
"trialN" << "\t" <<
//.........这里部分代码省略.........
示例2: advanceTrial
void advanceTrial()
{
double timeElapsed = timer.getElapsedTimeInMilliSec();
responseFile.precision(3);
responseFile <<
parameters.find("SubjectName") << "\t" <<
interoculardistance << "\t" <<
trialNumber << "\t" <<
objLocation <<"\t" <<
sizeNow <<"\t" <<
diameter <<"\t" <<
timer.getElapsedTimeInMilliSec() << "\t" <<
training << "\t" <<
round << "\t" <<
endl;
trialFile.close();
trialNumber++;
allTrials++;
// if fingers were invisible for more than 20% of the trial
double noVisibleFingersD = noVisibleFingers;
double frameND = frameN;
if(noVisibleFingersD/frameND > .2)
trial[round].reinsert(trial[round].getCurrent()); // repeat this trial at the end
if(training)
{
if( !trial[round].isEmpty() )
{
trial[round].next();
initTrial();
}
else
{
trialNumber = 0;
training=false;
initTrial();
}
}else
{
if(trialNumber < str2num<int>(parameters.find("numCatchTrials")))
{
trial[round].next();
initTrial();
}else if(round+1<ROUNDS) // if there is another round after the current
{
trialNumber = 0;
round++;
trial[round].next();
training=true;
initTrial();
}else
{
cleanup();
exit(0);
}
}
}
示例3: drawInfo
void drawInfo()
{
if ( visibleInfo )
{
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
GLText text;
if ( gameMode )
text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
else
text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
text.enterTextInputMode();
switch ( headCalibrationDone )
{
case 0:
{
if ( allVisibleHead )
text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
else
text.draw("Be visible with the head and glasses");
}
break;
case 1:
case 2:
{
if ( allVisiblePatch )
text.draw("Move the head in the center");
else
text.draw("Be visible with the patch");
}
break;
case 3: // When the head calibration is done then calibrate the fingers
{
switch ( fingerCalibrationDone )
{
case 0:
text.draw("Press F to record platform markers");
break;
case 1:
text.draw("Move index and thumb on platform markers to record ghost finger tips, then press F");
break;
case 2:
text.draw("Move index and thumb to rigidbody tip to define starting position, then press F");
break;
case 3:
text.draw("Finger calibration successfull!");
break;
}
}
break;
}
if ((GetKeyState(VK_CAPITAL) & 0x0001)!=0)
{
text.draw("#");
text.draw("#");
text.draw("# ----------------------------> Caps Lock ON!");
text.draw("#");
text.draw("#");
}
text.draw("####### SUBJECT #######");
text.draw("#");
text.draw("# Name: " +parameters.find("SubjectName"));
text.draw("# IOD: " +stringify<double>(interoculardistance));
text.draw("#");
if ( abs(mirrorAlignment - 45.0) < 0.2 )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("# Mirror Alignment = " + stringify<double>(mirrorAlignment));
glColor3fv(glWhite);
text.draw("#");
text.draw("#######################");
text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );
glColor3fv(glWhite);
text.draw("Calibration Platform" );
if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
glColor3fv(glWhite);
text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
glColor3fv(glWhite);
text.draw(" " );
text.draw("Mirror" );
if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
//.........这里部分代码省略.........
示例4: drawStimulus
void drawStimulus()
{
if (fingerCalibrationDone==3 && isStimulusDrawn && !pickedUp)
{
if(markers[3].p.transpose()[1]-magnetPos > 2.5)
pickedUp = true;
else
pickedUp = pickedUp;
glLoadIdentity();
// check for fingers' visibility
if(fingersOccluded==0)
drawFingers();
else
drawNoFingers();
// location of the object depends on the condition
if(training)
{
// and on the visibility of the magnet
if(!objectOccluded)
{
// place object at training pos
glTranslated(0.0,markers[3].p.transpose()[1]-magnetPos,str2num<double>(parameters.find("TrainingDist")));
// rotation available for debugging purposes (vertical by default)
glRotated(theta,1,0,0);
// black square in the middle to present only half of the cylinder
if(half)
drawBlackSquare();
// draw the object
drawEllipsoid(sizeNow);
}else
{
glTranslated(0.0,0.0,-400.0);
glRotated(M_PI*90.0,0,0,1);
drawEllipsoid(sizeNow);
}
}else
{
if(!objectOccluded)
{
// place object at training pos
glTranslated(0.0,markers[3].p.transpose()[1]-magnetPos,str2num<double>(parameters.find("CatchDist")));
// rotation available for debugging purposes (vertical by default)
glRotated(theta,1,0,0);
// black square in the middle to present only half of the cylinder
if(half)
drawBlackSquare();
// draw the object
drawEllipsoid(sizeNow);
}else
{
glTranslated(0.0,0.0,-400.0);
glRotated(M_PI,0,0,1);
drawEllipsoid(sizeNow);
}
}
}
}
示例5: initTrial
void initTrial()
{
// reset counters
frameN = 0;
stimulus = 1;
isTrialDone = false;
motion = 0.0;
cerr << "\n--------- TRIAL #" << trialNumber << " ----------" << endl;
// set the width of the object to 20mm
objwidth = 20.0;
// retrieve the depth cue
if(trial.getCurrent().first["DepthCue"] == 1)
{
depth_cue_pedestal = "stereo";
depth_cue_stimulus = "motion_mono";
}
else
{
depth_cue_pedestal = "motion_mono";
depth_cue_stimulus = "stereo";
}
// draw an empty screen
isStimulusDrawn=false;
// assign the stimuli
if(unifRand(-1.0, 1.0) > 0.0)
{
first_stimulus = "pedestal";
second_stimulus = "stimulus";
} else
{
first_stimulus = "stimulus";
second_stimulus = "pedestal";
}
#ifdef TEST
double PSE = str2num<double>(parameters.find("PSE"));
double JND = unifRand(-str2num<double>(parameters.find("JND")), str2num<double>(parameters.find("JND")));
cerr << "PSE = " << PSE << endl;
cerr << "JND = " << JND << endl;
// set the depth of the pedestal
depth_pedestal = trial.getCurrent().first["RelDepthObj"];
// set the depth of the stimulus
depth_stimulus = depth_pedestal + trial.getCurrent().second->getCurrentStaircase()->getState();
objdistance = trial.getCurrent().first["AbsDepth"];
// bool decision = ((depth_stimulus + JND) > (depth_pedestal + PSE) && first_stimulus == "stimulus") || (depth_stimulus + JND) > (depth_pedestal + PSE) && second_stimulus == "stimulus";
bool decision = ((depth_stimulus + JND) > (depth_pedestal + PSE) || (depth_stimulus + JND) > (depth_pedestal + PSE));
advanceTrial(decision);
#else
if(training)
{
// set the depth of the pedestal
depth_pedestal = 40.0;
// set the depth of the stimulus to be either clearly smaller or clearly larger than the pedestal
if(unifRand(-1.0, 1.0) > 0.0)
depth_stimulus = 20.0;
else
depth_stimulus = 60.0;
objdistance = -360;
}
if(experiment)
{
// set the depth of the pedestal
depth_pedestal = trial.getCurrent().first["RelDepthObj"];
// set the depth of the stimulus
depth_stimulus = depth_pedestal + trial.getCurrent().second->getCurrentStaircase()->getState();
objdistance = trial.getCurrent().first["AbsDepth"];
}
// build the three rods
build_three_rods();
// refresh the scene
drawGLScene();
// set the monitor at the right ditance
initProjectionScreen(objdistance);
// draw the stimulus
beepOk(0);
isStimulusDrawn=true;
timer.start();
#endif
}
示例6: drawFixation
void drawFixation()
{
switch ( headCalibrationDone )
{
case 1:
// Fixed stimulus
glColor3fv(glWhite);
glDisable(GL_BLEND);
glPointSize(5);
glBegin(GL_POINTS);
glVertex3d(0,0,focalDistance);
glEnd();
glPointSize(1);
break;
case 2:
// Fixed stimulus + projected points
glColor3fv(glWhite);
glDisable(GL_BLEND);
glPointSize(5);
glBegin(GL_POINTS);
glVertex3d(0,0,focalDistance);
glColor3fv(glRed);
glVertex3dv(projPointEyeRight.data());
glColor3fv(glBlue);
glVertex3d(eyeRight.x(),eyeRight.y(),focalDistance);
glEnd();
glPointSize(1);
// Draw the calibration circle
glColor3fv(glWhite);
break;
case 3:
{
// DRAW THE FIXATION POINT
double eyeToCenterAngleX= toDegrees(atan(eyeRight.x()/(-focalDistance-eyeRight.z()) ));
double eyeToCenterAngleY= toDegrees(atan(eyeRight.y()/(-focalDistance-eyeRight.z()) ));
double projPointAngleX = toDegrees( atan( (projPointEyeRight.x()-eyeRight.x())/abs(projPointEyeRight.z())));
double maxAllowedTranslationYaw = str2num<double>(parameters.find("MaxAllowedTranslationYaw"));
Vector3d stimulusCenter(0,0,0);
Matrix3d objrotation = Matrix3d::Identity();
// IMPORTANT Reset the previous status of transformation
objectActiveTransformation.setIdentity();
switch ( (int) factors["Rotation"] )
{
case 2:
{
objrotation = (AngleAxis<double>(eulerAngles.getYaw()*factors["FollowingSpeed"], Vector3d::UnitY())
*AngleAxis<double>(eulerAngles.getPitch(), Vector3d::UnitX())).toRotationMatrix();
instantPlaneSlant = toDegrees(eulerAngles.getYaw())*factors["RotationSpeed"]+factors["Slant"];
stimulusCenter = objrotation*Vector3d(0,0,focalDistance)+headEyeCoords.getRigidStart().getFullTransformation().translation();
objectActiveTransformation.linear()=objrotation;
}
break;
case 1:
{
objrotation = (AngleAxis<double>(eulerAngles.getYaw(), Vector3d::UnitY())
*AngleAxis<double>(eulerAngles.getPitch()*factors["FollowingSpeed"], Vector3d::UnitX())).toRotationMatrix();
instantPlaneSlant = toDegrees(eulerAngles.getPitch())*factors["RotationSpeed"]+factors["Slant"];
stimulusCenter = objrotation*Vector3d(0,0,focalDistance)+headEyeCoords.getRigidStart().getFullTransformation().translation();
objectActiveTransformation.linear()=objrotation;
}
break;
case 0:
{
objrotation = (AngleAxis<double>(eulerAngles.getYaw(), Vector3d::UnitY())
*AngleAxis<double>(eulerAngles.getPitch(), Vector3d::UnitX())).toRotationMatrix();
//instantPlaneSlant = eyeRight.x()*factors["RotationSpeed"]/10+factors["Slant"];
instantPlaneSlant = toDegrees( atan(eyeRight.x()/abs(focalDistance+eyeRight.z()) ) )*factors["RotationSpeed"]+factors["Slant"];
stimulusCenter = headEyeCoords.getRigidStart().getFullTransformation().linear()*Vector3d(eyeRight.x()*factors["FollowingSpeed"],eyeRight.y(),eyeRight.z()+focalDistance);
objectActiveTransformation.linear() = objrotation;
}
break;
}
objectActiveTransformation.translation() = stimulusCenter;
Vector3d fixationPointTmp = objectActiveTransformation.translation();
glPushMatrix();
glTranslated(fixationPointTmp.x(),fixationPointTmp.y(),fixationPointTmp.z());
glutSolidSphere(1,10,10);
glPopMatrix();
break;
}
}
}
示例7: drawInfo
void drawInfo()
{
if ( visibleInfo )
{
GLText text;
text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
text.enterTextInputMode();
text.draw("####### SUBJECT #######");
text.draw("#");
text.draw("# Name: " +parameters.find("SubjectName"));
text.draw("# IOD: " +stringify<double>(interoculardistance));
text.draw("#");
if(visibleSpecs)
{
text.draw("# trial: " +stringify<double>(trialNumber));
text.draw("#");
text.draw("# obj depth: " +stringify<double>(trial.getCurrent().first["RelDepthObj"]));
text.draw("# simulated depth: " +stringify<double>(trial.getCurrent().second->getCurrentStaircase()->getState()));
text.draw("# stairID: " +stringify<double>(trial.getCurrent().second->getCurrentStaircase()->getID()));
text.draw("#");
text.draw("# stairState: " +stringify<double>(trial.getCurrent().second->getCurrentStaircase()->getState() - trial.getCurrent().first["RelDepthObj"]));
text.draw("#");
text.draw("# stairInversions: " +stringify<double>(trial.getCurrent().second->getCurrentStaircase()->getInversions()));
text.draw("# stairAscending: " +stringify<double>(trial.getCurrent().second->getCurrentStaircase()->getAscending()));
text.draw("#");
text.draw("# stepsDone: " +stringify<double>(trial.getCurrent().second->getCurrentStaircase()->getStepsDone()));
}
// text.draw("#");
/*
for ( std::map<string,double>::iterator iter = trial.getCurrent().begin(); iter!=trial.getCurrent().end();++iter)
{
text.draw(iter->first + ": " + stringify<double>(iter->second));
}
*/
text.draw("#######################");
/* text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
glColor3fv(glWhite);
text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(9)+stringify< Eigen::Matrix<double,1,3> > (markers[9].p.transpose())+ " [mm]" );
glColor3fv(glWhite);
text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" );
text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" );
text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY));
text.draw(" ");
text.draw("jitter = " +stringify<double>(jitter));
text.draw(" ");
text.draw("size = " +stringify<double>((xedge + jitter)));
text.draw("xedge = " +stringify<double>(xedge));
text.draw(" ");
text.draw("depth = " +stringify<double>(zedge + (jitter/2)));
text.draw("zedge = " +stringify<double>(zedge));
*/ text.leaveTextInputMode();
}
}
示例8: initVariables
void initVariables()
{
trial.init(parameters);
interoculardistance = str2num<double>(parameters.find("IOD"));
}
示例9: idle
void idle()
{
updateTheMarkers();
// Visibility check
allVisiblePlatform = isVisible(markers[1].p) && isVisible(markers[2].p);
allVisibleIndex = isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p);
allVisibleThumb = isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p);
allVisibleFingers = allVisibleIndex && allVisibleThumb;
allVisibleObject = isVisible(markers[8].p) && isVisible(markers[11].p) && isVisible(markers[12].p);
allVisiblePatch = isVisible(markers[10].p) && isVisible(markers[11].p) && isVisible(markers[12].p);
allVisibleHead = allVisiblePatch && isVisible(markers[9].p);
// mirror alignment check
mirrorAlignment = asin(
abs((markers[6].p.z()-markers[7].p.z()))/
sqrt(
pow(markers[6].p.x()-markers[7].p.x(), 2) +
pow(markers[6].p.z()-markers[7].p.z(), 2)
)
)*180/M_PI;
// screen Y alignment check
screenAlignmentY = asin(
abs((markers[19].p.y()-markers[21].p.y()))/
sqrt(
pow(markers[19].p.x()-markers[21].p.x(), 2) +
pow(markers[19].p.y()-markers[21].p.y(), 2)
)
)*180/M_PI;
// screen Z alignment check
screenAlignmentZ = asin(
abs(markers[19].p.z()-markers[20].p.z())/
sqrt(
pow(markers[19].p.x()-markers[20].p.x(), 2) +
pow(markers[19].p.z()-markers[20].p.z(), 2)
)
)*180/M_PI*
abs(markers[19].p.x()-markers[20].p.x())/
(markers[19].p.x()-markers[20].p.x());
// eye coordinates
eyeRight = Vector3d(interoculardistance/2,0,0);
eyeLeft = Vector3d(-interoculardistance/2,0,0);
// fingers coordinates, fingersOccluded and framesOccluded
if ( allVisibleFingers )
{
indexCoords.update(markers[13].p, markers[14].p, markers[16].p );
thumbCoords.update(markers[15].p, markers[17].p, markers[18].p );
}
// Record the calibration platform's position and home position
if ( isVisible(markers[1].p) && allVisibleObject && fingerCalibrationDone==0 )
{
fingerCalibrationDone=1;
calibration_fingers(fingerCalibrationDone);
}
// Record the calibration platform's position and home position
if ( isVisible(markers[2].p) && allVisibleObject && fingerCalibrationDone==1 )
{
fingerCalibrationDone=2;
calibration_fingers(fingerCalibrationDone);
beepOk(2);
}
if ( allVisibleObject && fingerCalibrationDone==2 )
{
upperPin.update(markers[8].p, markers[11].p, markers[12].p );
lowerPin.update(markers[8].p, markers[11].p, markers[12].p );
}
#ifndef SIMULATION
// index coordinates
if(allVisibleIndex)
ind = indexCoords.getP1();
// thumb coordinates
if(allVisibleThumb)
thu = thumbCoords.getP1();
#endif
// what the program checks online during the grasp
if (fingerCalibrationDone==4 )
{
// frames counting
frameN++;
// fingersOccluded
if ( allVisibleFingers )
fingersOccluded = 0;
else
{
fingersOccluded=1;
}
//.........这里部分代码省略.........
示例10: drawInfo
void drawInfo()
{
if ( visibleInfo )
{
GLText text;
text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
text.enterTextInputMode();
switch (fingerCalibrationDone)
{
case 0:
text.draw("Calibration object and index marker are not visible.");
break;
case 1:
{
glColor3fv(glGreen);
text.draw("Index marker has been detected and calibrated. Waiting for Thumb marker to be visible...");
} break;
case 2:
{
glColor3fv(glGreen);
text.draw("Index marker has been detected and calibrated.");
text.draw("Thumb marker has been detected and calibrated.");
glColor3fv(glWhite);
text.draw("Touch the two outer markers with the fingerpads then press F (fingers and calibration object visible)");
} break;
case 3:
text.draw("Set home position then press F to start the demo");
break;
}
glColor3fv(glWhite);
text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );
text.draw(" ");
text.draw("####### SUBJECT #######");
text.draw("#");
text.draw("# Name: " +parameters.find("SubjectName"));
text.draw("# IOD: " +stringify<double>(interoculardistance));
text.draw("#");
text.draw("# trial: " +stringify<double>(trialNumber));
text.draw("#");
text.draw("#######################\n\n");
text.draw(" ");
// check if mirror is calibrated
if ( abs(mirrorAlignment - 45.0) < 0.2 )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));
// check if monitor is calibrated
if ( screenAlignmentY < 89.0 )
glColor3fv(glRed);
else
glColor3fv(glGreen);
text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));
if ( abs(screenAlignmentZ) < 89.0 )
glColor3fv(glRed);
else
glColor3fv(glGreen);
text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));
glColor3fv(glWhite);
// X and Z coords of simulated fixation
text.draw("# Fixation Z = " +stringify<double>(markers[19].p.x()-120.0)+ " [mm]");
text.draw("# Fixation X = " +stringify<double>(markers[19].p.z()+363.0)+ " [mm]");
text.draw(" ");
glColor3fv(glWhite);
text.draw("Calibration Platform" );
if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
if ( isVisible(markers[3].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
glColor3fv(glWhite);
text.draw(" " );
text.draw("Index" );
if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );
glColor3fv(glWhite);
//.........这里部分代码省略.........
示例11: idle
void idle()
{
// update optotrak
optotrak->updateMarkers();
// fill markers with updated coords
markers = optotrak->getAllMarkers();
// Coordinates picker
allVisiblePlatform = isVisible(markers[1].p);
allVisibleIndex = isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p);
allVisibleThumb = isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p);
allVisibleFingers = allVisibleIndex && allVisibleThumb;
// mirror visible
allVisiblePatch = isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p);
allVisibleHead = allVisiblePatch && isVisible(markers[1].p);
if ( allVisiblePatch )
headEyeCoords.update(markers[5].p,markers[6].p,markers[7].p);
if ( allVisibleFingers )
{
indexCoords.update(markers[13].p, markers[14].p, markers[16].p );
thumbCoords.update(markers[15].p, markers[17].p, markers[18].p );
fingersOccluded = 0;
}
// during the trial (after the calibratioon)
if (fingerCalibrationDone==3 )
{
// check for visibility of the fingers
if ( !allVisibleFingers )
{
fingersOccluded=1;
noVisibleFingers++;
}
// check for the visibility of the object
if(!isVisible(markers[3].p))
objectOccluded=1;
else
objectOccluded=0;
// start the flow of the frames
frameN++;
// eye coords depend on whether the head calibration took place or not
if(headCalibration)
{
// real time coords
eyeLeft = headEyeCoords.getLeftEye();
eyeRight = headEyeCoords.getRightEye();
} else {
// fixed coords
eyeRight = Vector3d(interoculardistance/2,0,0);
eyeLeft = -eyeRight;
}
// online position of fingers updated
index = indexCoords.getP1();
thumb = thumbCoords.getP1();
// online posotion of the mirror updated
mirrorAlignment = asin(
abs((markers[6].p.z()-markers[7].p.z()))/
sqrt(
pow(markers[6].p.x()-markers[7].p.x(), 2) +
pow(markers[6].p.z()-markers[7].p.z(), 2)
)
)*180/M_PI;
// online info written in the trialFile
trialFile << fixed <<
parameters.find("SubjectName") << "\t" << //subjName
trialNumber << "\t" << //trialN
timer.getElapsedTimeInMilliSec() << "\t" << //time
frameN << "\t" << //frameN
index.transpose() << "\t" << //indexXraw, indexYraw, indexZraw
thumb.transpose() << "\t" << //thumbXraw, thumbYraw, thumbZraw
eyeRight.transpose() << "\t" << //eyeRXraw, eyeRYraw, eyeRZraw
eyeLeft.transpose() << "\t" << //eyeLXraw, eyeLYraw, eyeLZraw
fingersOccluded << "\t" << //fingersOccluded
markers[3].p.transpose() << "\t" << //objectPos
isStimulusDrawn << "\t" <<
noVisibleFingers << "\t" <<
round << "\t" <<
objLocation <<"\t" <<
sizeNow <<"\t" <<
diameter <<"\t" <<
condition << "\t" <<
interoculardistance << "\t" <<
allTrials
;
trialFile << endl;
}
}
示例12: drawInfo
void drawInfo()
{
if ( visibleInfo )
{
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
GLText text;
if ( gameMode )
text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
else
text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
text.enterTextInputMode();
switch ( headCalibrationDone )
{
case 0:
{
if ( allVisibleHead )
text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
else
text.draw("Be visible with the head and glasses");
}
break;
case 1:
case 2:
{
if ( allVisiblePatch )
text.draw("Move the head in the center");
else
text.draw("Be visible with the patch");
}
break;
case 3: // When the head calibration is done then calibrate the fingers
{
switch ( fingerCalibrationDone )
{
case 0:
text.draw("Press F to record platform markers");
break;
case 1:
text.draw("Move index on platform markers to record ghost finger tips, then press F");
break;
case 2:
text.draw("Move index to rigidbody tip to define starting position, then press F");
break;
case 3:
text.draw("Finger calibration successfull!");
break;
}
}
break;
}
text.draw("####### SUBJECT #######");
text.draw("#");
text.draw("# Name: " +parameters.find("SubjectName"));
text.draw("# IOD: " +stringify<double>(interoculardistance));
text.draw("#");
text.draw("# trial: " +stringify<double>(trialNumber));
text.draw("#");
// text.draw("# obj depth: " +stringify<double>(trial.getCurrent()["RelDepthObj"] + dz));
// text.draw("#");
/*
for ( std::map<string,double>::iterator iter = trial.getCurrent().begin(); iter!=trial.getCurrent().end();++iter)
{
text.draw(iter->first + ": " + stringify<double>(iter->second));
}
*/
text.draw("#######################");
text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );
// platform calibration
if ( isVisible(markers[15].p) && isVisible(markers[16].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Platform front "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
text.draw("Platform side "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );
//head
if ( isVisible(markers[1].p) && isVisible(markers[2].p) && isVisible(markers[3].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Head 1 "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
text.draw("Head 2 "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
text.draw("Head 3 "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
text.draw("Head 4 "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
//index
if ( isVisible(markers[7].p) && isVisible(markers[8].p) && isVisible(markers[9].p) )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("Index 1 "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
text.draw("Index 2 "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );
//.........这里部分代码省略.........
示例13: drawInfo
/*** INFO ***/
void drawInfo()
{
if ( visibleInfo )
{
GLText text;
text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
text.enterTextInputMode();
glColor3fv(glWhite);
if(experiment)
text.draw("####### SUBJECT #######");
if(training)
text.draw("####### THIS IS JUST A TRAINING #######");
text.draw("#");
text.draw("# Name: " +parameters.find("SubjectName"));
text.draw("# IOD: " +stringify<double>(interoculardistance));
text.draw("#");
text.draw("# trial: " +stringify<double>(trialNumber));
text.draw("#");
text.draw("#######################\n\n");
text.draw(" ");
// check if mirror is calibrated
if ( abs(mirrorAlignment - 45.0) < 0.2 )
glColor3fv(glGreen);
else
glColor3fv(glRed);
text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));
// check if monitor is calibrated
if ( screenAlignmentY < 89.0 )
glColor3fv(glRed);
else
glColor3fv(glGreen);
text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));
if ( abs(screenAlignmentZ) < 89.4 )
glColor3fv(glRed);
else
glColor3fv(glGreen);
text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));
glColor3fv(glWhite);
// X and Z coords of simulated fixation
text.draw("# Fixation Z = " +stringify<double>(markers.at(screen1).p.x()-120.0)+ " [mm]");
text.draw("# Fixation X = " +stringify<double>(markers.at(screen1).p.z()+363.0)+ " [mm]");
text.draw(" ");
glColor3fv(glWhite);
text.draw(" " );
text.draw("time: " +stringify<int>(timer.getElapsedTimeInMilliSec()));
text.draw(" " );
if(depth_cue_pedestal == "stereo")
{
text.draw("Moving: = " +stringify<double> (depth_stimulus));
text.draw("Stereo: = " +stringify<double> (depth_pedestal));
} else
{
text.draw("Moving: = " +stringify<double> (depth_pedestal));
text.draw("Stereo: = " +stringify<double> (depth_stimulus));
}
text.leaveTextInputMode();
}
if ( expFinished )
{
GLText text2;
text2.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
text2.enterTextInputMode();
text2.draw("The experiment is finished.");
text2.leaveTextInputMode();
}
if ( inPause )
{
GLText text3;
text3.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
text3.enterTextInputMode();
text3.draw("P A U S E");
text3.leaveTextInputMode();
}
}
示例14: update
void update(int value)
{ // Read the experiment from file, if the file is finished exit suddenly
if ( inputStream.eof() )
{ cleanup();
exit(0);
}
if ( isReading )
{ // This reads a line (frame) in inputStream
readline(inputStream, trialNumber, headCalibration, trialMode, pointMatrix );
headEyeCoords.update(pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2));
Affine3d active = headEyeCoords.getRigidStart().getFullTransformation();
eulerAngles.init( headEyeCoords.getRigidStart().getFullTransformation().rotation() );
eyeLeft = headEyeCoords.getLeftEye();
eyeRight= headEyeCoords.getRightEye();
cyclopeanEye = (eyeLeft+eyeRight)/2.0;
if ( trialMode == STIMULUSMODE )
stimulusFrames++;
if ( trialMode == FIXATIONMODE )
stimulusFrames=0;
// Projection of view normal on the focal plane
Vector3d directionOfSight = (active.rotation()*Vector3d(0,0,-1)).normalized();
Eigen::ParametrizedLine<double,3> lineOfSightRight = Eigen::ParametrizedLine<double,3>::Through( eyeRight , eyeRight+directionOfSight );
Eigen::ParametrizedLine<double,3> lineOfSightLeft = Eigen::ParametrizedLine<double,3>::Through( eyeLeft, eyeLeft+directionOfSight );
double lineOfSightRightDistanceToFocalPlane = lineOfSightRight.intersection(focalPlane);
double lineOfSightLeftDistanceToFocalPlane = lineOfSightLeft.intersection(focalPlane);
//double lenghtOnZ = (active*(center-eyeCalibration )+eyeRight).z();
projPointEyeRight = lineOfSightRightDistanceToFocalPlane *(directionOfSight)+ (eyeRight);
projPointEyeLeft= lineOfSightLeftDistanceToFocalPlane * (directionOfSight) + (eyeLeft);
// second projection the fixation point computed with z non constant but perfectly parallel to projPointEyeRight
lineOfSightRightDistanceToFocalPlane= (( active.rotation()*(center)) - eyeRight).norm();
Vector3d secondProjection = lineOfSightRightDistanceToFocalPlane *(directionOfSight)+ (eyeRight);
if ( !zOnFocalPlane )
projPointEyeRight=secondProjection ;
// Compute the translation to move the eye in order to avoid share components
Vector3d posAlongLineOfSight = (headEyeCoords.getRigidStart().getFullTransformation().rotation())*(eyeRight -eyeCalibration);
// GENERATION OF PASSIVE MODE.
// HERE WE MOVE THE SCREEN TO FACE THE OBSERVER's EYE
if ( passiveMode )
{
initProjectionScreen(0, headEyeCoords.getRigidStart().getFullTransformation()*Translation3d(center));
}
else
initProjectionScreen(focalDistance, Affine3d::Identity());
objectPassiveTransformation = ( cam.getModelViewMatrix()*objectActiveTransformation );
ofstream outputfile;
outputfile.open("data.dat");
outputfile << "Subject Name: " << parameters.find("SubjectName") << endl;
outputfile << "Passive matrix:" << endl << objectPassiveTransformation.matrix() << endl;
outputfile << "Yaw: " << toDegrees(eulerAngles.getYaw()) << endl <<"Pitch: " << toDegrees(eulerAngles.getPitch()) << endl;
outputfile << "EyeLeft: " << headEyeCoords.getLeftEye().transpose() << endl;
outputfile << "EyeRight: " << headEyeCoords.getRightEye().transpose() << endl << endl;
outputfile << "Slant: " << instantPlaneSlant << endl;
outputfile << "Factors:" << endl;
for (map<string,double>::iterator iter=factors.begin(); iter!=factors.end(); ++iter)
{
outputfile << "\t\t" << iter->first << "= " << iter->second << endl;
}
}
if ( trialMode == PROBEMODE )
isReading=false;
glutPostRedisplay();
glutTimerFunc(TIMER_MS, update, 0);
}
示例15: initTrial
void initTrial()
{
// reset counters
frameN = 0;
stimulus = 1;
isTrialDone = false;
motion = 0.0;
if(checkglasses)
build_stereocheck();
cerr << "\n--------- TRIAL #" << trialNumber << " ----------" << endl;
// set the width of the object to 20mm
objwidth = 20.0;
// retrieve the depth cue
if(trial.getCurrent().first["DepthCue"] == 1)
{
depth_cue_pedestal = "stereo";
depth_cue_stimulus = "motion_mono";
}
else
{
depth_cue_pedestal = "motion_mono";
depth_cue_stimulus = "stereo";
}
// draw an empty screen
isStimulusDrawn=false;
// assign the stimuli
if(unifRand(-1.0, 1.0) > 0.0)
{
first_stimulus = "pedestal";
second_stimulus = "stimulus";
} else
{
first_stimulus = "stimulus";
second_stimulus = "pedestal";
}
#ifdef TEST
double PSE = str2num<double>(parameters.find("PSE"));
double JND = unifRand(-str2num<double>(parameters.find("JND")), str2num<double>(parameters.find("JND")));
cerr << "PSE = " << PSE << endl;
cerr << "JND = " << JND << endl;
// set the depth of the pedestal
depth_pedestal = trial.getCurrent().first["RelDepthObj"];
// set the depth of the stimulus
depth_stimulus = depth_pedestal + trial.getCurrent().second->getCurrentStaircase()->getState();
objdistance = trial.getCurrent().first["AbsDepth"];
// bool decision = ((depth_stimulus + JND) > (depth_pedestal + PSE) && first_stimulus == "stimulus") || (depth_stimulus + JND) > (depth_pedestal + PSE) && second_stimulus == "stimulus";
bool decision = ((depth_stimulus + JND) > (depth_pedestal + PSE) || (depth_stimulus + JND) > (depth_pedestal + PSE));
advanceTrial(decision);
#else
if(training)
{
trial_time = 2500;
// set the depth of the pedestal
depth_pedestal = 40.0;
// set the depth of the stimulus to be either clearly smaller or clearly larger than the pedestal
if(unifRand(-1.0, 1.0) > 0.0)
depth_stimulus = 20.0;
else
depth_stimulus = 60.0;
objdistance = -360;
}
if(experiment)
{
trial_time = trial_duration;
// set the depth of the pedestal
depth_pedestal = trial.getCurrent().first["RelDepthObj"];
// set the depth of the stimulus
depth_stimulus = depth_pedestal + trial.getCurrent().second->getCurrentStaircase()->getState();
objdistance = trial.getCurrent().first["AbsDepth"];
}
// build fixation cross
build_fixation_cross();
// build the two planes
build_two_planes();
// calculate the length of the oblique plane
oblPlane_pedestal_length = sqrt( pow(depth_pedestal, 2) + pow(obl_length, 2) );
oblPlane_stimulus_length = sqrt( pow(depth_stimulus, 2) + pow(obl_length, 2) );
build_oblique_plane(oblPlane_pedestal_length, oblPlane_stimulus_length);
//.........这里部分代码省略.........