diff --git a/ECTrainer2/BitalMonitor.h b/ECTrainer2/BitalMonitor.h index 842dbe9..91f7cc0 100644 --- a/ECTrainer2/BitalMonitor.h +++ b/ECTrainer2/BitalMonitor.h @@ -9,7 +9,7 @@ { const int COM_PORT = 4; const char LF = 10; - const int NO_SIGNAL_TIMEOUT = 5000; // ���M���Ɣ��肷�鎞�� (ms) + const DWORD NO_SIGNAL_TIMEOUT = 5000; // ���M���Ɣ��肷�鎞�� (ms) GComPort _Com; RingBuffer _rrInterval; diff --git a/ECTrainer2/Marker.cpp b/ECTrainer2/Marker.cpp index ecb7518..70915ff 100644 --- a/ECTrainer2/Marker.cpp +++ b/ECTrainer2/Marker.cpp @@ -1,15 +1,12 @@ #include "Marker.h" #include "ECTrainer.h" - -#ifdef _DEBUG -#include -#endif +#include "myWinUtils.h" // �R���X�g���N�^ -Marker::Marker() +Marker::Marker() : _detected(false) - , _HomographyV2I(ECTrainer::RINGBUFSIZE) + , _HomographyV2I(ECTrainer::RINGBUFSIZE, cv::Mat::zeros(3, 3, CV_64F)) { _Dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); CalcMarkerCorners(IMGSIZE); @@ -98,9 +95,7 @@ // �}�[�J�[��`�悷�� void Marker::DrawMarker(cv::Mat& img) { if (_Corners.size() < 1) { -#ifdef _DEBUG - std::cout << "Marker isn't generated." << std::endl; -#endif + mwut::DebugPrintf(_T("Marker not generated")); return; } diff --git a/ECTrainer2/MovieObject.h b/ECTrainer2/MovieObject.h index 2f9ebb8..8b4148d 100644 --- a/ECTrainer2/MovieObject.h +++ b/ECTrainer2/MovieObject.h @@ -40,5 +40,5 @@ // �w�莞�Ԃ̃I�u�W�F�N�g����Ԃ� std::vector GetElements(float sTime); // �t���[������Ԃ� - int GetNumFrames() { return _frame.size(); } + int GetNumFrames() { return (int)_frame.size(); } }; diff --git a/ECTrainer2/TobiiREST.cpp b/ECTrainer2/TobiiREST.cpp index d70683b..6b80fde 100644 --- a/ECTrainer2/TobiiREST.cpp +++ b/ECTrainer2/TobiiREST.cpp @@ -46,7 +46,7 @@ // ���[�v bool TobiiREST::MainLoop() { - DWORD lastBatteryQuery = timeGetTime(); + DWORD lastBatteryQuery = 0; while (_pEct->IsAppRun()) { // �L�����u���[�V���� diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index 241af53..22ca2bb 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -2,25 +2,25 @@ Worker::Worker(ECTrainer* pEct) : BaseProcess(pEct) - , LOG_FILENAME(_T("log.txt")) , _AppStatus(APP_STATUS::BOOT) - , _fpLog(NULL) { + , _fpLog(NULL) + , _StartTime(0) { } bool Worker::Init() { - if (_tfopen_s(&_fpLog, LOG_FILENAME, _T("w")) != 0) { + if (_tfopen_s(&_fpLog, LOG_FILENAME.c_str(), _T("w")) != 0) { ::MessageBox(_pEct->PECTrainerGUI()->GetMainHWnd(), _T("Can't open log file."), _T("Error"), 0); return false; } - _ftprintf(_fpLog, _T("time,gazeVx,gazeVy,RR\n")); + _ftprintf(_fpLog, _T("time,gazeVx,gazeVy,H11,H12,H13,H21,H22,H23,H31,H32,H33,RR\n")); return true; } bool Worker::MainLoop() { - int64 start = cv::getTickCount(); _AppStatus = APP_STATUS::IDLE; + _StartTime = cv::getTickCount(); while (_pEct->IsAppRun()) { // �������X�V��҂� @@ -32,23 +32,19 @@ switch (_pEct->PTobiiREST()->GetCalibStatus()) { case CALIB_STATUS::DONE: _pEct->PStimulus()->SetPage(STIM_PAGE::CALIB_COMPLETE); + this->WriteLog(_T("Calibration complete.")); _AppStatus = APP_STATUS::IDLE; break; case CALIB_STATUS::FAIL: case CALIB_STATUS::ERR: _pEct->PStimulus()->SetPage(STIM_PAGE::CALIB_FAILED); + this->WriteLog(_T("Calibration failed.")); _AppStatus = APP_STATUS::IDLE; break; } } - // ���O�o�� - auto elapse = (cv::getTickCount() - start) * 1000. / cv::getTickFrequency(); - _ftprintf(_fpLog, _T("%.1f"), elapse); - cv::Point2f gazeV = (_pEct->GetGazeV()); - _ftprintf(_fpLog, _T(",%.1f,%.1f"), gazeV.x, gazeV.y); - _ftprintf(_fpLog, _T(",%d"), _pEct->PBitalMonitor()->GetRR()); - _ftprintf(_fpLog, _T("\n")); + this->WriteLog(); } fclose(_fpLog); @@ -60,5 +56,33 @@ _pEct->PStimulus()->SetPage(STIM_PAGE::CALIB); _pEct->PTobiiREST()->StartCalibration(); _AppStatus = APP_STATUS::CALIB; + this->WriteLog(_T("Calibration start.")); return true; } + +// ���O�o�� +void Worker::WriteLog(const TCHAR* msg) { + _mtxLog.lock(); + + auto elapse = (cv::getTickCount() - _StartTime) * 1000. / cv::getTickFrequency(); + _ftprintf(_fpLog, _T("%.1f"), elapse); + + if (msg) { + _ftprintf(_fpLog, msg); + } else { + cv::Point2f gazeV = (_pEct->GetGazeV()); + _ftprintf(_fpLog, _T(",%.1f,%.1f"), gazeV.x, gazeV.y); + cv::Mat h = _pEct->PMarker()->GetHomography(); + if (!h.empty() && h.rows == 3 && h.cols == 3) { + double* ptr = h.ptr(0); + for (int i = 0; i < 9; i++) { + _ftprintf(_fpLog, _T(",%lf"), *(ptr + i)); + } + } + + _ftprintf(_fpLog, _T(",%d"), _pEct->PBitalMonitor()->GetRR()); + _ftprintf(_fpLog, _T("\n")); + } + + _mtxLog.unlock(); +} diff --git a/ECTrainer2/Worker.h b/ECTrainer2/Worker.h index 65a8611..9bc4370 100644 --- a/ECTrainer2/Worker.h +++ b/ECTrainer2/Worker.h @@ -2,15 +2,22 @@ #include "BaseProcess.h" #include - +#include +#include +#include +#include enum class APP_STATUS { BOOT, IDLE, CALIB, EXEC }; class Worker : public BaseProcess { - const TCHAR* LOG_FILENAME; + const std::wstring LOG_FILENAME = _T("log.txt"); APP_STATUS _AppStatus; FILE* _fpLog; + int64 _StartTime; + std::mutex _mtxLog; + + void WriteLog(const TCHAR* msg = NULL); public: Worker(ECTrainer* pEct); diff --git "a/\343\203\241\343\203\203\343\202\273\343\203\274\343\202\270\345\233\263.xlsx" "b/\343\203\241\343\203\203\343\202\273\343\203\274\343\202\270\345\233\263.xlsx" index 167733b..412cfa0 100644 --- "a/\343\203\241\343\203\203\343\202\273\343\203\274\343\202\270\345\233\263.xlsx" +++ "b/\343\203\241\343\203\203\343\202\273\343\203\274\343\202\270\345\233\263.xlsx" Binary files differ