From 277cc7603eb6b4d9fed6a0a2de245e4cdde6ee8b Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Tue, 22 Mar 2011 21:34:47 +0000 Subject: Successfully use console app for faceAPI 3.2.6. combined with tracker class in DLL. Even managed to get the video-widget connected to the main-window... git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@56 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h | 2 +- FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp | 88 +++++++++------------------- 2 files changed, 28 insertions(+), 62 deletions(-) (limited to 'FTNoIR_Tracker_SM') diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h index 5bed0a16..1edc612f 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h +++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h @@ -19,7 +19,7 @@ public: void Release(); void Initialize( QFrame *videoframe ); void StartTracker( HWND parent_window ); - void StopTracker(); + void StopTracker( bool exit ); bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good void loadSettings(); bool SMCreateMapping(); diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp index a7f0668e..358ad962 100644 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp +++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp @@ -18,22 +18,22 @@ FTNoIR_Tracker_SM::~FTNoIR_Tracker_SM() qDebug() << "stopTracker says: terminating"; if ( pMemData != NULL ) { - pMemData->command = 100; // Issue 'stop' command UnmapViewOfFile ( pMemData ); } CloseHandle( hSMMutex ); CloseHandle( hSMMemMap ); hSMMemMap = 0; - - //_engine->stop(); - //smAPIQuit(); } void FTNoIR_Tracker_SM::Release() { qDebug() << "FTNoIR_Tracker_SM::Release says: Starting "; - delete this; + + if ( pMemData != NULL ) { + pMemData->command = FT_SM_EXIT; // Issue 'exit' command + } + delete this; } void FTNoIR_Tracker_SM::Initialize( QFrame *videoframe ) @@ -48,91 +48,57 @@ void FTNoIR_Tracker_SM::Initialize( QFrame *videoframe ) QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); } + if ( pMemData != NULL ) { + pMemData->command = 0; // Reset any and all commands + pMemData->handle = videoframe->winId(); // Handle of Videoframe widget + } + // // Start FTNoIR_FaceAPI_EXE.exe. The exe contains all faceAPI-stuff and is non-Qt... // - QString program = "FTNoIR_FaceAPI_EXE.exe"; - faceAPI = new QProcess(0); - faceAPI->start(program); - - ////try { - //// // Initialize the faceAPI Qt library - //// sm::faceapi::qt::initialize(); - //// smLoggingSetFileOutputEnable( false ); - - //// // Initialize the API - //// faceapi_scope = new APIScope(); - - //// //if (APIScope::internalQtGuiIsDisabled()){ - //// // QMessageBox::warning(0,"faceAPI Error","Something Bad",QMessageBox::Ok,QMessageBox::NoButton); - //// //} - - //// // Create head-tracking engine v2 using first detected webcam - //// CameraInfo::registerType(SM_API_CAMERA_TYPE_WDM); - //// _engine = QSharedPointer(new HeadTrackerV2()); - - ////} - ////catch (sm::faceapi::Error &e) - ////{ - //// /* ERROR with camera */ - //// QMessageBox::warning(0,"faceAPI Error",e.what(),QMessageBox::Ok,QMessageBox::NoButton); - ////} - - + QString program = "FTNoIR_FaceAPI_EXE.exe"; + faceAPI = new QProcess(0); + faceAPI->start(program); // Show the video widget qDebug() << "FTNoIR_Tracker_SM::Initialize says: videoframe = " << videoframe; - //// QMainWindow derived class. See mainwindow.h - // QSharedPointer camera; - // main_window = new MainWindow(camera,_engine,0); - // main_window->show(); - - //videoframe->show(); - //_display = new VideoDisplayWidget( _engine, videoframe, 0 ); - //l = new QVBoxLayout(videoframe); - //l->setMargin(0); - //l->setSpacing(0); - //l->addWidget(_display); - + videoframe->show(); return; } void FTNoIR_Tracker_SM::StartTracker( HWND parent_window ) { - - //// starts the faceapi engine - //if (_engine->state() != SM_API_ENGINE_STATE_HT_TRACKING) { - // _engine->start(); - //} - - //// some parameteres [optional] - //smHTSetHeadPosePredictionEnabled( _engine->handle(), false); - //smHTSetLipTrackingEnabled( _engine->handle(), false); - //smLoggingSetFileOutputEnable( false ); + if ( pMemData != NULL ) { + pMemData->command = FT_SM_START; // Start command + } return; } -void FTNoIR_Tracker_SM::StopTracker() +void FTNoIR_Tracker_SM::StopTracker( bool exit ) { qDebug() << "FTNoIR_Tracker_SM::StopTracker says: Starting "; // stops the faceapi engine -//// _engine->stop(); + if ( pMemData != NULL ) { +// if (exit == true) { + pMemData->command = (exit) ? FT_SM_EXIT : FT_SM_STOP; // Issue 'stop' command + //} + //else { + // pMemData->command = FT_SM_STOP; // Issue 'stop' command + //} + } return; } bool FTNoIR_Tracker_SM::GiveHeadPoseData(THeadPoseData *data) { - - qDebug() << "FTNoIR_Tracker_SM::GiveHeadPoseData says: Starting "; - // // Check if the pointer is OK and wait for the Mutex. // if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { - qDebug() << "FTNoIR_Tracker_SM::GiveHeadPoseData says: Retrieving data."; +// qDebug() << "FTNoIR_Tracker_SM::GiveHeadPoseData says: Retrieving data."; // // Copy the measurements to FaceTrackNoIR. -- cgit v1.2.3