diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index c348586..6b982ef 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -53,6 +53,8 @@ // �C�x���g���[�v bool ECTrainerGUI::MainLoop() { + bool fShowEyes = false; + while (_pEct->IsRunning() && cv::getWindowProperty(WIN_MAIN, 0) >= 0) { // ���C���E�C���h�E�t���[���N���A @@ -67,6 +69,11 @@ } else { _pEct->SetGazeV(cv::Point(-1, -1)); } + cv::Point2f imagePos = cv::Point2f(-1.F, -1.F); + if (cvui::iarea(DISP_IMAGE_POS.x, DISP_IMAGE_POS.y, IMAGE_WIDTH, _DispImageHeight) == cvui::OVER) { + imagePos.x = (float)(mp.x - DISP_IMAGE_POS.x) / IMAGE_WIDTH; + imagePos.y = (float)(mp.y - DISP_IMAGE_POS.y) / _DispImageHeight; + } // �h���摜 if (_pEct->GetGazeI().x >= 0) { @@ -80,9 +87,11 @@ cvui::beginColumn(_MainFrame, 10, 100, 140, -1, 10); if (cvui::button(140, 30, "CALIBRATION")) _pEct->Calib(); if (cvui::button(140, 30, "START")) _pEct->Start(); - cvui::printf("Mouse %d,%d", mp.x, mp.y); - cvui::printf("View Gaze %d,%d", _pEct->GetGazeV().x, _pEct->GetGazeV().y); - cvui::printf("Img Gaze %.2f,%.2f", _pEct->GetGazeI().x, _pEct->GetGazeI().y); + cvui::checkbox("Show Eyes", &fShowEyes); + cvui::printf("Mouse W %d, %d", mp.x, mp.y); + cvui::printf("Mouse L %.2f, %.2f", imagePos.x, imagePos.y); + cvui::printf("View Gaze %d, %d", _pEct->GetGazeV().x, _pEct->GetGazeV().y); + cvui::printf("Img Gaze %.2f, %.2f", _pEct->GetGazeI().x, _pEct->GetGazeI().y); cvui::text(_pEct->GetHomographyStatus() ? "Homography OK" : "No homography"); bool snapshot = cvui::button(140, 30, "SNAPSHOT"); if (cvui::button(140, 30, "QUIT")) _pEct->Stop(); diff --git a/ECTrainer2/StimData.txt b/ECTrainer2/StimData.txt new file mode 100644 index 0000000..0ba342f --- /dev/null +++ b/ECTrainer2/StimData.txt @@ -0,0 +1 @@ +../images/lena.jpg 0.49 0.45 0.57 0.45 diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index 332ca08..9f71279 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -1,17 +1,36 @@ #include "Stimulus.h" - #include "ECTrainer.h" #include "Marker.h" +#include +#include +#include +#include // �R���X�g���N�^ Stimulus::Stimulus(ECTrainer* pEct, Marker* pMarker) - :BaseProcess(pEct), _pMarker(pMarker) { + :BaseProcess(pEct) + , _pMarker(pMarker) + , _StimNo(0) +{ } // ������ bool Stimulus::Init() { _DispBuffer = cv::imread(OPENING_FILE); + + std::ifstream ifs(DATA_FILE); + if (!ifs) + { + OutputDebugString(_T("Can't open stim data file.")); + return false; + } + while (!ifs.eof()) { + StimImage st; + ifs >> st.filename >> st.eyes[0].x >> st.eyes[0].y >> st.eyes[1].x >> st.eyes[1].y; + _StimImages.push_back(st); + } + return true; } @@ -34,7 +53,13 @@ // �h���摜�J�n void Stimulus::StartImage() { - _DispBuffer = cv::imread("../images/lena.jpg"); + _StimNo = 0; + SetStimulus(); +} + +// �h�����Z�b�g +void Stimulus::SetStimulus() { + _DispBuffer = cv::imread(_StimImages[_StimNo].filename); _pMarker->Generate(_DispBuffer.size()); _pMarker->DrawMarker(_DispBuffer); } diff --git a/ECTrainer2/Stimulus.h b/ECTrainer2/Stimulus.h index edec8eb..cccb8a7 100644 --- a/ECTrainer2/Stimulus.h +++ b/ECTrainer2/Stimulus.h @@ -2,16 +2,27 @@ #include "myOpenCV.h" #include "BaseProcess.h" +#include +#include class Marker; +struct StimImage { + cv::String filename; + cv::Point2f eyes[2]; +}; + class Stimulus : public BaseProcess { const cv::String OPENING_FILE = "../images/ECTrainerLogo640x91.png"; const cv::String CALIB_FILE = "../images/calib.png"; + const std::string DATA_FILE = "StimData.txt"; Marker* _pMarker; cv::Mat _DispBuffer; + std::vector _StimImages; + int _StimNo; + void SetStimulus(); public: Stimulus(ECTrainer* pEct, Marker* pMarker); bool Init(); diff --git "a/voices/takada\050great\051.wav" "b/voices/takada\050great\051.wav" new file mode 100644 index 0000000..8e6bc65 --- /dev/null +++ "b/voices/takada\050great\051.wav" Binary files differ diff --git "a/voices/tang\050fight\051.wav" "b/voices/tang\050fight\051.wav" new file mode 100644 index 0000000..40c8350 --- /dev/null +++ "b/voices/tang\050fight\051.wav" Binary files differ diff --git a/voices/voice1.wav b/voices/voice1.wav new file mode 100644 index 0000000..fbaf2d5 --- /dev/null +++ b/voices/voice1.wav Binary files differ diff --git a/voices/voice2.wav b/voices/voice2.wav new file mode 100644 index 0000000..7ddbfd8 --- /dev/null +++ b/voices/voice2.wav Binary files differ