diff --git a/.gitignore b/.gitignore index abfc536..29b334a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ packages/ ECTrainer2/Log*.txt ECTrainer2/Log*.csv +images/ diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index ae367dc..4d35e1c 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -26,6 +26,7 @@ QUIT = WM_QUIT, SOFTWARE_START = WM_USER, // �\�t�g�E�F�A�N�� SOFTWARE_END, // �\�t�g�E�F�A�I�� + SYSTEM_ERROR, // �V�X�e���G���[ CALIB_START, // �L�����u���[�V�����J�n CALIB_OK, // �L�����u���[�V�������� CALIB_FAILED, // �L�����u���[�V�������s @@ -37,7 +38,7 @@ MOVIE_START, // ����Đ��J�n MOVIE_STOP, // ����Đ���~ MOVIE_END, // ����Đ��I�� - MOVIE_ERROR, // ����G���[ + IMAGE_SHOW, // �摜�\�� FB_OK, // �t�B�[�h�o�b�N�FOK FB_GOOD, // �t�B�[�h�o�b�N�FGood FB_NICE, // �t�B�[�h�o�b�N�FNice diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index 0aa488b..a8a6da8 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -55,7 +55,7 @@ cv::moveWindow(WIN_MAIN, displays[0].left + 100, displays[0].top + 100); } _blank = cv::Mat(DISP_SIZE, CV_8UC3, cv::Scalar(0)); - _Logo = cv::imread("../images/ECTLogo2_1480l.png"); + _Logo = cv::imread(HEADER_FILE); _pEct->PDSMovie()->Init(displays[0]); @@ -110,9 +110,9 @@ //cvui::printf("Img Gaze %.2f, %.2f", _pEct->GetGazeI().x, _pEct->GetGazeI().y); cvui::text(_pEct->PMarker()->IsDetected() ? "AR Markers OK" : "AR Markers NG"); cvui::printf("Battery %d %%", _pEct->PTobiiREST()->GetBatteryLevel()); - if (_pEct->PDSMovie()->IsPlaying()) { + if (_pEct->PStimulus()->GetStimNo() >= 0) { cvui::printf("%s", _pEct->PStimulus()->GetStimFile().c_str()); - cvui::printf("Movie pos: %.1f", _pEct->PDSMovie()->GetPlayPos()); + cvui::printf("Showing %.1f s", _pEct->PStimulus()->GetStimTime() / 1000.F); } bool snapshot = cvui::button(140, 30, "SNAPSHOT"); if (cvui::button(140, 30, "QUIT")) { @@ -139,7 +139,6 @@ if (_pEct->PStimulus()->IsNewMovie()) { std::wstring movie = _pEct->PStimulus()->GetMovie(); if (movie.size() < 1 || movie == L"STOP") { - _pEct->PDSMovie()->StopMovie(); mwut::DebugPrintf(_T("ECTMSG::MOVIE_STOP [%s]\n"), movie.c_str()); ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::MOVIE_STOP); } else { @@ -147,7 +146,7 @@ ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::MOVIE_START); } else { _pEct->PDSMovie()->StopMovie(); - ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::MOVIE_ERROR); + ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::SYSTEM_ERROR); } } } @@ -179,13 +178,25 @@ // �C�x���g���� bool ECTrainerGUI::EventProc(MSG& msg) { switch (msg.message) { - case WM_CHAR: + + case WM_CHAR: // �L�[���� if (msg.wParam == 27) { #ifdef _DEBUG ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::SOFTWARE_END); #endif } break; + + case (int)ECTMSG::MOVIE_START: + break; + + case (int)ECTMSG::MOVIE_STOP: + _pEct->PDSMovie()->StopMovie(); + break; + + case (int)ECTMSG::IMAGE_SHOW: + break; + default: //mwut::DebugPrintf(_T("Event %04X\n"), msg.message); break; diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index d158236..1c0f3a5 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -11,6 +11,7 @@ private: const cv::String WIN_DISP = "ECTrainer Display"; const cv::String WIN_MAIN = "Eye Contact Trainer"; + const cv::String HEADER_FILE = "../images/Header1480.png"; const cv::String SNAPSHOT_FILE = "snapshot.jpg"; const cv::Size MAIN_FRAME_SIZE = cv::Size(1480, 620); // ���C���E�C���h�E�̃T�C�Y const cv::Point SCENE_BUFFER_POS = cv::Point(170, 120); // ����摜�\���ʒu diff --git a/ECTrainer2/StimConfig.txt b/ECTrainer2/StimConfig.txt index e1b539e..e86cb7f 100644 --- a/ECTrainer2/StimConfig.txt +++ b/ECTrainer2/StimConfig.txt @@ -1 +1,6 @@ +1,../images/CalibCheck1.png,4,_ +1,../images/CalibCheck2.png,4,_ +1,../images/CalibCheck3.png,4,_ +1,../images/CalibCheck4.png,4,_ +1,../images/visit01_004.png,5,_ 2,../movies/visit01_004.avi,30,../movies/visit01_004.csv diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index b04182e..df3e470 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -68,37 +68,20 @@ return true; } -// ���̎h���ֈړ� -bool Stimulus::MoveNext() { - if (_StimNo < 0) return false; - - if (_StimInfoSet[_StimNo].type == 2) { - _Movie.Put(L"STOP"); - mwut::DebugPrintf(L"movie put stop.\n"); - } - if (_StimNo + 1 < (int)_StimInfoSet.size()) { - SetStimulus(_StimNo + 1); - ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::EXP_NEXT); - } else { - ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::EXP_END); - } - return true; -} - // �C�x���g���� bool Stimulus::EventProc(MSG& msg) { switch (msg.message) { case (int)ECTMSG::CALIB_START: // �L�����u���[�V�����J�n - _Display.Put(cv::imread(CALIB_FILE)); + this->SetImage(CALIB_FILE); break; case (int)ECTMSG::CALIB_OK: // �L�����u���[�V�������� - _Display.Put(cv::imread(CALIB_COMPLETE_FILE)); + this->SetImage(CALIB_COMPLETE_FILE); break; case (int)ECTMSG::CALIB_FAILED: // �L�����u���[�V�������s case (int)ECTMSG::CALIB_ERR: // �L�����u���[�V�����G���[ - _Display.Put(cv::imread(CALIB_FAILED_FILE)); + this->SetImage(CALIB_FAILED_FILE); break; case (int)ECTMSG::EXP_START: // �����J�n @@ -107,7 +90,17 @@ case (int)ECTMSG::EXP_STOP: // ������~ _StimNo = -1; - _Display.Put(cv::imread(OPENING_FILE)); + this->SetImage(EXP_STOP_FILE); + break; + + case (int)ECTMSG::EXP_END: // �����I�� + _StimNo = -1; + this->SetImage(EXP_DONE_FILE); + break; + + case (int)ECTMSG::SYSTEM_ERROR: // �V�X�e���G���[ + _StimNo = -1; + this->SetImage(ERROR_FILE); break; case (int)ECTMSG::MOVIE_END: // ����Đ��������ɓ��B @@ -117,6 +110,23 @@ return true; } +// ���̎h���ֈړ� +bool Stimulus::MoveNext() { + if (_StimNo < 0) return false; + + if (_StimInfoSet[_StimNo].type == 2) { + if (_cap.isOpened()) _cap.release(); + ((BaseProcess*)_pEct->PECTrainerGUI())->PostMsg(ECTMSG::MOVIE_STOP); + } + if (_StimNo + 1 < (int)_StimInfoSet.size()) { + SetStimulus(_StimNo + 1); + ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::EXP_NEXT); + } else { + ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::EXP_END); + } + return true; +} + // �h���� bool Stimulus::SetStimulus(int newStimNo) { if (newStimNo < 0 || newStimNo >= _StimInfoSet.size()) return false; @@ -127,11 +137,17 @@ } if (_StimInfoSet[newStimNo].type == 1) { - _Display.Put(cv::imread(_StimInfoSet[newStimNo].filepath)); + this->SetImage(_StimInfoSet[newStimNo].filepath); } else { - _Movie.Put(mwut::Multi2Wide(_StimInfoSet[newStimNo].filepath)); - if (_cap.isOpened()) _cap.release(); _cap.open(_StimInfoSet[newStimNo].filepath); + if (!_cap.isOpened()) { + mwut::DebugPrintf(_T("Can't open movie file: %s\n"), + mwut::Multi2Wide(_StimInfoSet[newStimNo].filepath).c_str()); + ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::SYSTEM_ERROR); + return false; + } + _Movie.Put(mwut::Multi2Wide(_StimInfoSet[newStimNo].filepath)); + ((BaseProcess*)_pEct->PECTrainerGUI())->PostMsg(ECTMSG::MOVIE_START); } _StimTimer.Reset(); @@ -139,7 +155,21 @@ return true; } -// CSV�ǂݍ��� +// �摜�ǂݍ��� +bool Stimulus::SetImage(cv::String imageFile) { + auto img = cv::imread(imageFile); + if (img.empty()) { + mwut::DebugPrintf(_T("Can't open image file: %s\n"), + mwut::Multi2Wide(imageFile).c_str()); + ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::SYSTEM_ERROR); + return false; + } + _Display.Put(img); + ((BaseProcess*)_pEct->PECTrainerGUI())->PostMsg(ECTMSG::IMAGE_SHOW); + return true; +} + +// ����I�u�W�F�N�g�̓ǂݍ��� void Stimulus::LoadMovieObject(int stimNo) { int nFrames = _pMovieObject->SetData(_StimInfoSet[stimNo].csvfile); diff --git a/ECTrainer2/Stimulus.h b/ECTrainer2/Stimulus.h index cdd7529..7765884 100644 --- a/ECTrainer2/Stimulus.h +++ b/ECTrainer2/Stimulus.h @@ -26,11 +26,14 @@ public: private: const std::string STIM_CONFIG_FILE = "StimConfig.txt"; - const cv::String OPENING_FILE = "../images/ECT_toppage.png"; - const cv::String CALIB_FILE = "../images/calib.png"; - const cv::String CALIB_COMPLETE_FILE = "../images/CalibComplete.png"; + const cv::String OPENING_FILE = "../images/StartPage.png"; + const cv::String CALIB_FILE = "../images/TobiiCalib.png"; + const cv::String CALIB_COMPLETE_FILE = "../images/CalibOK.png"; const cv::String CALIB_FAILED_FILE = "../images/CalibFailed.png"; - const cv::String WHITE_FILE = "../images/white.png"; + const cv::String WHITE_FILE = "../images/White.png"; + const cv::String ERROR_FILE = "../images/SystemError.png"; + const cv::String EXP_STOP_FILE = "../images/ExpStop.png"; + const cv::String EXP_DONE_FILE = "../images/ExpDone.png"; std::vector _StimInfoSet; // �����ݒ� MovieObject* _pMovieObject; // �^�[�Q�b�g��� @@ -42,7 +45,7 @@ // �h����ݒ� bool SetStimulus(int newStimNo); - // ����I�u�W�F�N�g�� + // ����I�u�W�F�N�g�̓ǂݍ��� void LoadMovieObject(int stimNo); // ��{���� bool Routine(); @@ -50,6 +53,8 @@ bool EventProc(MSG& msg); // ���̎h���ֈړ� bool MoveNext(); + // �摜�ǂݍ��� + bool SetImage(cv::String imageFile); // �摜�Ƀ}�[�J�[��`�� //void StimWithMarker(); diff --git a/ECTrainer2/TobiiREST.cpp b/ECTrainer2/TobiiREST.cpp index fe05a63..029e77d 100644 --- a/ECTrainer2/TobiiREST.cpp +++ b/ECTrainer2/TobiiREST.cpp @@ -59,6 +59,8 @@ case (int)ECTMSG::CALIB_START: // �L�����u���[�V���� if (StartCalib()) { QueryCalibResult(); + } else { + ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::CALIB_ERR); } break; } @@ -111,10 +113,8 @@ #endif if (status == _T("failed")) { ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::CALIB_FAILED); - mwut::DebugPrintf(_T("Calibration failed\n")); } else { ((BaseProcess*)_pEct->PWorker())->PostMsg(ECTMSG::CALIB_OK); - mwut::DebugPrintf(_T("Calibration successful\n")); } return true; } diff --git a/ECTrainer2/Worker.cpp b/ECTrainer2/Worker.cpp index d25e18d..db0d27f 100644 --- a/ECTrainer2/Worker.cpp +++ b/ECTrainer2/Worker.cpp @@ -69,18 +69,20 @@ double dtMin = 0; int fb = 0; std::vector elems = _pEct->PStimulus()->GetMovieObject(); - if (stimNo >= 0 && elems.size() > 0) { + if (stimNo >= 0) { cv::Mat stimImg = _pEct->PStimulus()->GetDisplay().clone(); - for (int e = 0; e < elems.size(); e++) { - // �^�[�Q�b�g�`�� - auto target = cv::Point2f(elems[e].x, elems[e].y); - cv::circle(stimImg, target, (int)elems[e].d, CV_RGB(255, 0, 0), 2); - if (gazeI.x >= 0) { - // �^�[�Q�b�g���� - auto dt = cv::norm(gazeI - target); - if (dt < elems[e].d && (hit < 0 || dt < dtMin)) { - hit = e; - dtMin = dt; + if (elems.size() > 0) { + for (int e = 0; e < elems.size(); e++) { + // �^�[�Q�b�g�`�� + auto target = cv::Point2f(elems[e].x, elems[e].y); + cv::circle(stimImg, target, (int)elems[e].d, CV_RGB(255, 0, 0), 2); + if (gazeI.x >= 0) { + // �^�[�Q�b�g���� + auto dt = cv::norm(gazeI - target); + if (dt < elems[e].d && (hit < 0 || dt < dtMin)) { + hit = e; + dtMin = dt; + } } } } @@ -201,7 +203,7 @@ case (int)ECTMSG::EXP_END: // �����I�� if (_AppStatus == APP_STATUS::STIM) { _AppStatus = APP_STATUS::IDLE; - ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::EXP_STOP); + ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::EXP_END); this->EventLog(_T("Experiment Finished")); } break; @@ -211,22 +213,28 @@ this->ResetParams(); break; - case (int)ECTMSG::MOVIE_START: // ����Đ��J�n - this->EventLog(_T("Movie Start")); + case (int)ECTMSG::SYSTEM_ERROR: // ���̎h���Ɉړ� + this->EventLog(_T("System Error")); + ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::SYSTEM_ERROR); + ((BaseProcess*)_pEct->PECTrainerGUI())->PostMsg(ECTMSG::MOVIE_STOP); break; - case (int)ECTMSG::MOVIE_STOP: // ����Đ���~ - this->EventLog(_T("Movie Stopped")); - break; + //case (int)ECTMSG::MOVIE_START: // ����Đ��J�n + // this->EventLog(_T("Movie Start")); + // break; - case (int)ECTMSG::MOVIE_END: // ����Đ��I�� - this->EventLog(_T("Movie End")); - ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::MOVIE_END); - break; + //case (int)ECTMSG::MOVIE_STOP: // ����Đ���~ + // this->EventLog(_T("Movie Stopped")); + // break; - case (int)ECTMSG::MOVIE_ERROR: // ����G���[ - this->EventLog(_T("Movie Error")); - break; + //case (int)ECTMSG::MOVIE_END: // ����Đ��I�� + // this->EventLog(_T("Movie End")); + // ((BaseProcess*)_pEct->PStimulus())->PostMsg(ECTMSG::MOVIE_END); + // break; + + //case (int)ECTMSG::MOVIE_ERROR: // ����G���[ + // this->EventLog(_T("Movie Error")); + // break; case (int)ECTMSG::FB_OK: // �t�B�[�h�o�b�N�FOK PlaySound(SOUND_OK, NULL, SND_FILENAME | SND_ASYNC); diff --git a/images/CalibCheck1.png b/images/CalibCheck1.png deleted file mode 100644 index 5d0d005..0000000 --- a/images/CalibCheck1.png +++ /dev/null Binary files differ diff --git a/images/CalibCheck2.png b/images/CalibCheck2.png deleted file mode 100644 index 831b557..0000000 --- a/images/CalibCheck2.png +++ /dev/null Binary files differ diff --git a/images/CalibCheck3.png b/images/CalibCheck3.png deleted file mode 100644 index e815873..0000000 --- a/images/CalibCheck3.png +++ /dev/null Binary files differ diff --git a/images/CalibCheck4.png b/images/CalibCheck4.png deleted file mode 100644 index 8a9af92..0000000 --- a/images/CalibCheck4.png +++ /dev/null Binary files differ diff --git a/images/CalibComplete.png b/images/CalibComplete.png deleted file mode 100644 index d062a42..0000000 --- a/images/CalibComplete.png +++ /dev/null Binary files differ diff --git a/images/CalibFailed.png b/images/CalibFailed.png index a5c6a93..ea3c95a 100644 --- a/images/CalibFailed.png +++ b/images/CalibFailed.png Binary files differ diff --git a/images/ECTLogo2_1480l.png b/images/ECTLogo2_1480l.png deleted file mode 100644 index dd46029..0000000 --- a/images/ECTLogo2_1480l.png +++ /dev/null Binary files differ diff --git a/images/ECT_toppage.png b/images/ECT_toppage.png deleted file mode 100644 index b06d6d9..0000000 --- a/images/ECT_toppage.png +++ /dev/null Binary files differ diff --git a/images/LookEyes.png b/images/LookEyes.png deleted file mode 100644 index 64720da..0000000 --- a/images/LookEyes.png +++ /dev/null Binary files differ diff --git a/images/LookNose.png b/images/LookNose.png deleted file mode 100644 index 88cd356..0000000 --- a/images/LookNose.png +++ /dev/null Binary files differ diff --git a/images/calib.png b/images/calib.png deleted file mode 100644 index a9cbe26..0000000 --- a/images/calib.png +++ /dev/null Binary files differ diff --git a/images/finish.jpg b/images/finish.jpg deleted file mode 100644 index d2ea015..0000000 --- a/images/finish.jpg +++ /dev/null Binary files differ diff --git a/images/illust.jpg b/images/illust.jpg deleted file mode 100644 index eb8c62f..0000000 --- a/images/illust.jpg +++ /dev/null Binary files differ diff --git a/images/instruction.png b/images/instruction.png deleted file mode 100644 index 4deec0c..0000000 --- a/images/instruction.png +++ /dev/null Binary files differ diff --git a/images/lena.jpg b/images/lena.jpg deleted file mode 100644 index 0fdf25d..0000000 --- a/images/lena.jpg +++ /dev/null Binary files differ diff --git a/images/other.jpg b/images/other.jpg deleted file mode 100644 index 3acc397..0000000 --- a/images/other.jpg +++ /dev/null Binary files differ diff --git a/images/praise2.jpg b/images/praise2.jpg deleted file mode 100644 index 5362a36..0000000 --- a/images/praise2.jpg +++ /dev/null Binary files differ diff --git a/images/visit01_004.png b/images/visit01_004.png deleted file mode 100644 index df2ae82..0000000 --- a/images/visit01_004.png +++ /dev/null Binary files differ diff --git a/images/white.png b/images/white.png index f9c0393..1266fe2 100644 --- a/images/white.png +++ b/images/white.png Binary files differ diff --git "a/voices/takada\050great\051.wav" "b/voices/takada\050great\051.wav" deleted file mode 100644 index 8e6bc65..0000000 --- "a/voices/takada\050great\051.wav" +++ /dev/null Binary files differ diff --git "a/voices/tang\050fight\051.wav" "b/voices/tang\050fight\051.wav" deleted file mode 100644 index 40c8350..0000000 --- "a/voices/tang\050fight\051.wav" +++ /dev/null Binary files differ 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 15b4bad..f76264d 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