diff --git a/ECTrainer2/BaseProcess.cpp b/ECTrainer2/BaseProcess.cpp index 103e7f0..0984e93 100644 --- a/ECTrainer2/BaseProcess.cpp +++ b/ECTrainer2/BaseProcess.cpp @@ -1,6 +1,6 @@ #include "BaseProcess.h" #include "ECTrainer.h" -//#include "MyWinUtils.h" +#include "MyWinUtils.h" // �R���X�g���N�^ BaseProcess::BaseProcess(ECTrainer* pEct) @@ -33,6 +33,9 @@ // ���b�Z�[�W���[�v MSG msg; + mwut::HPTimer timer; + int fpsCounter = 0; + const int fpsCount = 100; while (1) { if (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!::GetMessage(&msg, NULL, 0, 0)) break; @@ -43,7 +46,15 @@ ::DispatchMessage(&msg); } } else { - if (!this->Routine()) break; + if (this->Routine() && this->ClassName().size() > 0) { + // FPS���� + if (++fpsCounter >= fpsCount) { + fpsCounter = 0; + double fps = fpsCount * 1000.0 / timer.Interval(); + mwut::DebugPrintf(_T("%s : %.1f fps\n"), + mwut::Multi2Wide(this->ClassName()).c_str(), fps); + } + } } _messageQueReady = true; } diff --git a/ECTrainer2/BaseProcess.h b/ECTrainer2/BaseProcess.h index 9a02161..440d90b 100644 --- a/ECTrainer2/BaseProcess.h +++ b/ECTrainer2/BaseProcess.h @@ -1,6 +1,7 @@ #pragma once #include +#include class ECTrainer; enum class ECTMSG; @@ -22,6 +23,8 @@ virtual bool Routine(); // ���b�Z�[�W���� virtual bool EventProc(MSG& msg); + // �N���X���擾�i�h���N���X�ŃI�[�o�[���C�h�����FPS�\���j + virtual std::string ClassName() { return ""; } // FPS�\�� public: // �R���X�g���N�^ diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 077416a..4626807 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -4,9 +4,10 @@ #include #include -#define TOBII_ADDR "192.168.71.50" -//#define EYEDEVICE_GLASS2 -#define EYEDEVICE_NONE +//#define TOBII_ADDR "192.168.71.50" +#define TOBII_ADDR "192.168.23.155" +#define EYEDEVICE_GLASS2 +//#define EYEDEVICE_NONE class BaseProcess; class ECTrainerGUI; @@ -55,7 +56,7 @@ class ECTrainer { // �v���Z�X�ꗗ�i���������j GUI < REST << SCNCAM < ALIVE < EYETR << STIM - enum class PROC { GUI, REST, WORKER, IMGPROC, SCNCAM, ALIVE, EYETR, BITAL, STIM, NUM }; + enum class PROC { GUI, REST, WORKER, IMGPROC, ALIVE, EYETR, BITAL, STIM, SCNCAM, NUM }; BaseProcess* _pProcs[(int)PROC::NUM]; Marker* _pMarker; diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index f2d79d1..9538696 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -34,7 +34,7 @@ // �h���񎦃E�C���h�E std::vector displays = mwut::GetDisplayInfo(); // ���s�‹��̏��擾 - if (displays.size() > 1) { + if (displays.size() > 1 && !FORCE_SINGLE_MONITOR) { // �}���`���j�^�̏ꍇ // �T�u��ʂɑ���p�l���\�� cv::moveWindow(WIN_MAIN, displays[1].left, displays[1].top); diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index 1c0f3a5..689fb5c 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -6,6 +6,8 @@ class ECTrainer; +#define FORCE_SINGLE_MONITOR 0 + class ECTrainerGUI : public BaseProcess { private: diff --git a/ECTrainer2/ImageProc.cpp b/ECTrainer2/ImageProc.cpp index 5fe461a..6e4ec5c 100644 --- a/ECTrainer2/ImageProc.cpp +++ b/ECTrainer2/ImageProc.cpp @@ -13,8 +13,10 @@ bool ImageProc::Routine() { // �V�[���J�����̃t���[���X�V�҂� - Sleep(0); - if (!_pEct->PSceneCamera()->IsNew()) return true; + if (!_pEct->PSceneCamera()->IsNew()) { + Sleep(1); + return false; + } cv::Mat img = _pEct->PSceneCamera()->GetImage().clone(); _pEct->PMarker()->Detect(img); diff --git a/ECTrainer2/ImageProc.h b/ECTrainer2/ImageProc.h index bc47970..908ab63 100644 --- a/ECTrainer2/ImageProc.h +++ b/ECTrainer2/ImageProc.h @@ -10,6 +10,8 @@ { RingBuffer _OutputBuf; + //std::string ClassName() { return "ImageProc"; } // FPS�\�� + public: ImageProc(ECTrainer* pEct); bool Routine(); diff --git a/ECTrainer2/KeepAlive.h b/ECTrainer2/KeepAlive.h index 5f99371..29c34e3 100644 --- a/ECTrainer2/KeepAlive.h +++ b/ECTrainer2/KeepAlive.h @@ -12,6 +12,8 @@ int _socketAddrLen; // �A�h���X���̃T�C�Y int _count; // ���[�v�J�E���g + //std::string ClassName() { return "KeepAlive"; } // FPS�\�� + public: static const int SOCKET_BUF_LEN = 512; // Socket�ʐM�o�b�t�@�T�C�Y diff --git a/ECTrainer2/SceneCamera.cpp b/ECTrainer2/SceneCamera.cpp index 819e948..547f973 100644 --- a/ECTrainer2/SceneCamera.cpp +++ b/ECTrainer2/SceneCamera.cpp @@ -39,7 +39,7 @@ cv::Mat scene; _SceneCam >> scene; _buffer.Put(scene); - Sleep(0); + Sleep(15); // Tobii�̃V�[���J������25FPS 15ms��Sleep�͖��Ȃ� return true; } diff --git a/ECTrainer2/SceneCamera.h b/ECTrainer2/SceneCamera.h index 3c49f9b..04da545 100644 --- a/ECTrainer2/SceneCamera.h +++ b/ECTrainer2/SceneCamera.h @@ -12,6 +12,8 @@ RingBuffer _buffer; cv::Size _sceneSize; + std::string ClassName() { return "SceneCamera"; } // FPS�\�� + public: SceneCamera(ECTrainer* pEct); bool Init(); diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index 2611107..794d193 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -56,8 +56,10 @@ bool Worker::Routine() { // �������X�V��҂� - //Sleep(0); - if (!_pEct->PEyeTrack()->IsNewGazeV()) return true; + if (!_pEct->PEyeTrack()->IsNewGazeV()) { + Sleep(1); + return true; + } cv::Point2f gazeV = (_pEct->PEyeTrack()->GetGazeV()); int stimNo = _pEct->PStimulus()->GetStimNo();