diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 668602f..5a6aa9f 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -6,8 +6,8 @@ #define TOBII_ADDR "192.168.71.50" //#define TOBII_ADDR "192.168.23.156" -#define EYEDEVICE_GLASS2 -//#define EYEDEVICE_NONE +//#define EYEDEVICE_GLASS2 +#define EYEDEVICE_NONE class BaseProcess; class ECTrainerGUI; diff --git a/ECTrainer2/EyeTrack.cpp b/ECTrainer2/EyeTrack.cpp index 2cb15a6..5a318f8 100644 --- a/ECTrainer2/EyeTrack.cpp +++ b/ECTrainer2/EyeTrack.cpp @@ -5,6 +5,9 @@ #include "ECTrainer.h" #include "KeepAlive.h" #include "SceneCamera.h" +#include "nkcWinUtils.h" +#include "HPTimer.h" +#include "Worker.h" #pragma comment(lib, "ws2_32.lib") #include @@ -18,6 +21,12 @@ , _gpCy(MEAN_BUF_SIZE) { _pupilD.l = _pupilD.r = 0; + _wtimer = ::CreateWaitableTimer(NULL, TRUE, NULL); +} + +// デストラクタ +EyeTrack::~EyeTrack() { + CloseHandle(_wtimer); } // メインループ @@ -67,7 +76,13 @@ #elif defined(EYEDEVICE_NONE) _GazeV.Put(cv::Point2f(-1.F, -1.F)); + Ect()->PWorker()->SetTrigger(); ::Sleep(10); return true; #endif } + +// FPS表示 +void EyeTrack::FPS(double fps) { + nkc::wut::DebugPrintf(_T("[EyeTrack] %.1f fps\n"), fps); +} diff --git a/ECTrainer2/EyeTrack.h b/ECTrainer2/EyeTrack.h index 681255b..7f85738 100644 --- a/ECTrainer2/EyeTrack.h +++ b/ECTrainer2/EyeTrack.h @@ -24,19 +24,24 @@ int _lastGidx; // 前回のデータインデックス cv::Point2f _gazePoint; MeanBuffer _gpCx, _gpCy; // 移動平均バッファ - + HANDLE _wtimer; + // ECTrainerインスタンス取得 ECTrainer* Ect() { return (ECTrainer*)_pUserdata; } public: // コンストラクタ EyeTrack(ECTrainer* pEct); + // デストラクタ + ~EyeTrack(); // メインループ bool Routine(); // 注視点の更新状況 bool IsNewGazeV() { return _GazeV.IsNew(); } // 注視点を取得 cv::Point2f GetGazeV() { return _GazeV.Get(); } + // FPS表示 + void FPS(double fps); }; diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index 2bfe2ec..843779c 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -23,12 +23,14 @@ { _pExpTimer = new nkc::HPTimer(); _pContactTimer = new nkc::HPTimer(); + _Trigger = ::CreateEvent(NULL, FALSE, FALSE, NULL); } // デストラクタ Worker::~Worker() { nkc::wut::SafeDelete((void**)&_pExpTimer); nkc::wut::SafeDelete((void**)&_pContactTimer); + ::CloseHandle(_Trigger); } // 初期化 @@ -43,10 +45,11 @@ bool Worker::Routine() { // 視線情報更新を待つ - if (!Ect()->PEyeTrack()->IsNewGazeV()) { - Sleep(0); - return false; - } + if (::WaitForSingleObject(_Trigger, 1) == WAIT_TIMEOUT) return false; + //if (!Ect()->PEyeTrack()->IsNewGazeV()) { + // Sleep(0); + // return false; + //} cv::Point2f gazeV = (Ect()->PEyeTrack()->GetGazeV()); int stimNo = Ect()->PStimulus()->GetStimNo(); diff --git a/ECTrainer2/Worker.h b/ECTrainer2/Worker.h index 5ec7f5c..0ee7f70 100644 --- a/ECTrainer2/Worker.h +++ b/ECTrainer2/Worker.h @@ -37,6 +37,7 @@ cv::Mat _StimImage; // 刺激画像 nkc::RingBuffer _FullScreenImage; // 全画面用画像 int _FBLevel; // フィードバックレベル 1~5 + HANDLE _Trigger; // 処理開始トリガ // ECTrainerインスタンス取得 ECTrainer* Ect() { return (ECTrainer*)_pUserdata; } @@ -74,4 +75,6 @@ double GetContactTime(); // 実験経過時間を取得(msec) double GetExpTime(); + // トリガーセット + void SetTrigger() { ::SetEvent(_Trigger); } };