bool VisuoThread::getFixation(Bottle &bStereo) { Vector stereo(4); imgMutex.wait(); if(img[LEFT]!=NULL) { stereo[0]=stereo[2]=0.5*img[LEFT]->width(); stereo[1]=stereo[3]=0.5*img[LEFT]->height(); } else { stereo[0]=stereo[2]=160; stereo[1]=stereo[3]=120; } imgMutex.post(); for(size_t i=0; i<stereo.size(); i++) bStereo.addDouble(stereo[i]); int side=40; startTracker(stereo,side); return true; }
void Sensors::onBrainStart() { // start sensors for( int k = 0; k < sensors.count(); k++ ) { Sensor *sensor = sensors.getClassByIndex( k ); sensor -> startSensor(); logger.logInfo( "onBrainStart: sensor started - name=" + sensor -> getName() ); } // start poller startTracker(); }
bool VisuoThread::getRaw(Bottle &bStereo) { Vector stereo; bool ok=false; //empty the buffers Bottle *bL=rawInPort[LEFT].read(false); Bottle *bR=rawInPort[RIGHT].read(false); double t=Time::now(); while(stereo.size()!=4 && Time::now()-t<rawWaitThresh && !interrupted) { Bottle *bL=rawInPort[LEFT].read(false); Bottle *bR=rawInPort[RIGHT].read(false); if(bL!=NULL || bR!=NULL) stereo.resize(4,0.0); if(bL!=NULL) { stereo[0]=bL->get(0).asInt(); stereo[1]=bL->get(1).asInt(); } if(bR!=NULL) { stereo[2]=bR->get(0).asInt(); stereo[3]=bR->get(1).asInt(); } } if(stereo.size()==4) { int side=40; startTracker(stereo,side); ok=true; } for(size_t i=0; i<stereo.size(); i++) bStereo.addDouble(stereo[i]); return ok; }
void BarabellaApp::setOperationMode(OperationMode mode) { operationMode = mode; switch (operationMode) { case STREAMING: view3d.setCube(sCube); view3d.setDrawMode(View3D::NORMAL); break; case CLIPPLAYBACK: view3d.setDrawMode(View3D::NORMAL); break; case TRACKING: view3d.setDrawMode(View3D::TRACKING); startTracker(); break; } }
FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : QMainWindow(parent), #if defined(_WIN32) keybindingWorker(NULL), #else keyCenter(this), keyToggle(this), #endif b(bundle("opentrack-ui")), s(b), pose(std::vector<axis_opts*>{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}), timUpdateHeadPose(this), pTrackerDialog(NULL), pSecondTrackerDialog(NULL), pProtocolDialog(NULL), pFilterDialog(NULL), kbd_quit(QKeySequence("Ctrl+Q"), this), looping(0) { ui.setupUi(this); setFixedSize(size()); _keyboard_shortcuts = 0; _curve_config = 0; tracker = 0; CurveConfigurationDialog* ccd; if (!_curve_config) { ccd = new CurveConfigurationDialog( this, this ); _curve_config = ccd; } else { ccd = dynamic_cast<CurveConfigurationDialog*>(_curve_config); } QDir::setCurrent(QCoreApplication::applicationDirPath()); fill_profile_cbx(); connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); ui.cbxSecondTrackerSource->addItem(QIcon(), ""); dlopen_filters.push_back((DynamicLibrary*) NULL); ui.iconcomboFilter->addItem(QIcon(), ""); fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); tie_setting(s.tracker2_dll, ui.cbxSecondTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); tie_setting(s.filter_dll, ui.iconcomboFilter); connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); GetCameraNameDX(); connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); #ifndef _WIN32 connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); #endif connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); kbd_quit.setEnabled(true); }
bool VisuoThread::getMotion(Bottle &bStereo) { Vector stereo; bool ok=false; double t=Time::now(); while(Time::now()-t<motionWaitThresh && !interrupted) { motMutex.wait(); // If the buffers are sufficently dense and not so small, return true. double size=0.0; if (buffer[LEFT].size()>minMotionBufSize && buffer[RIGHT].size()>minMotionBufSize) { Vector p[2]; for (int cam=0; cam<2; cam++) { double size_cam,u,v,n; double u_std,v_std; size_cam=u=v=0.0; u_std=v_std=0.0; n=1.0/buffer[cam].size(); for (unsigned int i=0; i<buffer[cam].size(); i++) { size_cam+=buffer[cam][i].size; u+=buffer[cam][i].p.x; v+=buffer[cam][i].p.y; u_std+=buffer[cam][i].p.x*buffer[cam][i].p.x; v_std+=buffer[cam][i].p.y*buffer[cam][i].p.y; } size_cam*=n; u*=n; v*=n; u_std=sqrt(n*u_std-u*u); v_std=sqrt(n*v_std-v*v); //check if the motion detected point is not wildly moving if (u_std<motionStdThresh && v_std<motionStdThresh) { p[cam].resize(2); p[cam][0]=u; p[cam][1]=v; } else break; size+=size_cam; } int side=cvRound(2*sqrt(size/3.1415)*2); if (p[LEFT].size()==2 && p[RIGHT].size()==2) { stereo.resize(4); stereo[0]=p[LEFT][0]; stereo[1]=p[LEFT][1]; stereo[2]=p[RIGHT][0]; stereo[3]=p[RIGHT][1]; startTracker(stereo,cvRound(side)); ok=true; } } motMutex.post(); } for(size_t i=0; i<stereo.size(); i++) bStereo.addDouble(stereo[i]); return ok; }