diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index 5b7beab..8d59c36 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -11,7 +11,7 @@ class ECTrainerGUI : public BaseProcess { private: - const cv::String VERSION = "1.3"; + const cv::String VERSION = "1.4"; const cv::String WIN_DISP = "ECTrainer Display"; const cv::String WIN_MAIN_NAME = "Eye Communication Trainer"; const cv::String HEADER_FILE = "../images/Header.png"; diff --git a/ECTrainer2/Logger.cpp b/ECTrainer2/Logger.cpp index 253a15a..a61e09f 100644 --- a/ECTrainer2/Logger.cpp +++ b/ECTrainer2/Logger.cpp @@ -2,6 +2,7 @@ #include "nkcWinUtils.h" const char* Logger::DATA_LOG_FILE = LOG_DIR "%s_%s_%d.csv"; +const char* Logger::CALIB_LOG_FILE = LOG_DIR "%s_%s_%d_calib.csv"; const TCHAR* Logger::EVENT_LOG_FILE = _T(LOG_DIR "events.txt"); // コンストラクタ @@ -21,18 +22,20 @@ return false; } - _ftprintf(fp, msg); - - fclose(fp); + if (fp) { + _ftprintf(fp, msg); + fclose(fp); + } return true; } // データログ開始 -void Logger::StartRecord(std::string subject, int visit) { +void Logger::StartRecord(std::string subject, int visit, bool isCalib) { CreateDirectory(_T(LOG_DIR), NULL); _logFileName = nkc::wut::Multi2Wide( - cv::format(DATA_LOG_FILE, nkc::wut::DateTimeStr().c_str(), subject.c_str(), visit)); + cv::format(isCalib? CALIB_LOG_FILE : DATA_LOG_FILE, + nkc::wut::DateTimeStr().c_str(), subject.c_str(), visit)); nkc::wut::DebugPrintf(_T("Log start: %s\n"), _logFileName.c_str()); TCHAR msg[1024]; diff --git a/ECTrainer2/Logger.h b/ECTrainer2/Logger.h index 6197433..7c29c51 100644 --- a/ECTrainer2/Logger.h +++ b/ECTrainer2/Logger.h @@ -33,12 +33,13 @@ public: static const char* DATA_LOG_FILE; + static const char* CALIB_LOG_FILE; static const TCHAR* EVENT_LOG_FILE; static bool Append(const TCHAR* filename, const TCHAR* msg); static void WriteEvent(const TCHAR* msg); Logger(); - void StartRecord(std::string subject, int visit); + void StartRecord(std::string subject, int visit, bool isCalib = false); void WriteRecord(Record& r); void Stop(); std::wstring Filename() { return _logFileName; }; diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index 824562f..4254c52 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -52,6 +52,7 @@ cv::Point2f gazeV = (Ect()->PEyeTrack()->GetGazeV()); int stimNo = Ect()->PStimulus()->GetStimNo(); + int calibNo = Ect()->PStimulus()->GetSoftCalibNo(); // 注視点を画像座標に変換 auto gazeI = gazeV.x < 0 ? cv::Point2f(-1, -1) : Ect()->PMarker()->ConvV2I(gazeV) - _Shift; @@ -68,7 +69,7 @@ int fb = 0; double frameInterval = _pContactTimer->Interval(); std::vector elems = Ect()->PStimulus()->GetMovieObject(); - if (stimNo >= 0 || Ect()->PStimulus()->GetSoftCalibNo() >= 0) { + if (stimNo >= 0 || calibNo >= 0) { cv::Mat stimImg = _StimImage.clone(); float scale = (float)stimImg.cols / Ect()->PMarker()->IMGSIZE.width; if (elems.size() > 0) { @@ -139,10 +140,10 @@ } // ログ出力 - if (stimNo >= 0) { + if (stimNo >= 0 || calibNo >= 0) { Record r; r.ElapTime = _pExpTimer->Elapse() / 1000.; // 経過時間 - r.StimNo = stimNo; // 刺激データ番号 + r.StimNo = stimNo >= 0 ? stimNo : calibNo; // 刺激データ番号 r.SceneNo = stimNo < 1 ? 0 : Ect()->PStimulus()->GetScene(stimNo - 1); // シーン番号 r.SceneTime = Ect()->PStimulus()->GetStimTime() / 1000.; // 刺激提示の経過時間 r.GazeV = gazeV; // 注視点(視野カメラ座標) @@ -207,7 +208,8 @@ break; case (int)ECTMSG::CALIB_OK: // キャリブレーション成功 -// _AppStatus = APP_STATUS::IDLE; + _DataLog.StartRecord(Ect()->Subject(), Ect()->Visit(), true); // キャリブレーションログ開始 + this->ResetShift(); // キャリブレーションデータの初期化 Ect()->PStimulus()->PostMsg((int)ECTMSG::SOFTCALIB_START); this->EventLog(_T("Soft Calibration Start")); break; @@ -263,7 +265,7 @@ break; case (int)ECTMSG::EXP_NEXT: // 次の刺激に移動 - this->EventLog(_T("Next stimulation")); + //this->EventLog(_T("Next stimulation")); this->ResetParams(); break; diff --git a/ECTrainer2/Worker.h b/ECTrainer2/Worker.h index 7e1b2d5..46576db 100644 --- a/ECTrainer2/Worker.h +++ b/ECTrainer2/Worker.h @@ -98,4 +98,6 @@ void ClearShift() { _ShiftLog.clear(); } // キャリブレーションチェックの判定 bool IsCalibCheckOK(); + // 注視点のずれのリセット + void ResetShift() { _Shift = cv::Point2f(0, 0); } }; diff --git a/EcomAnalysis/LogData.cs b/EcomAnalysis/LogData.cs index 7923dd5..0b6d104 100644 --- a/EcomAnalysis/LogData.cs +++ b/EcomAnalysis/LogData.cs @@ -6,7 +6,10 @@ namespace EcomAnalysis { - struct Point2f { public float x; public float y; } + //struct Point2f { + // public float x; + // public float y; + //} class LogData { //public double ElapTime; // 経過時間