diff --git a/ECTrainer2/ECTrainer.cpp b/ECTrainer2/ECTrainer.cpp index 2f99c08..3a4995e 100644 --- a/ECTrainer2/ECTrainer.cpp +++ b/ECTrainer2/ECTrainer.cpp @@ -69,12 +69,17 @@ // �L�����u���[�V���� void ECTrainer::Calib() { - _pStimulus->StartCalib(); + _pStimulus->Calibration(); } // �J�n void ECTrainer::Start() { - _pStimulus->StartImage(); + _pStimulus->Start(); +} + +// ���� +void ECTrainer::Next() { + _pStimulus->Next(); } // ����摜�o�b�t�@�ɉ摜��ݒ� @@ -125,3 +130,13 @@ cv::Point2f ECTrainer::GetGazeI() { return _pEyeTrack->GetGazeI(); } + +// �E�ڂ̈ʒu�擾 +cv::Point2f ECTrainer::GetEyeR() { + return _pStimulus->GetEyeR(); +} + +// �E�ڂ̈ʒu�擾 +cv::Point2f ECTrainer::GetEyeL() { + return _pStimulus->GetEyeL(); +} diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index 426a7d8..2a298fc 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -34,11 +34,15 @@ bool Process(); void Calib(); void Start(); + void Next(); void SetSceneBuffer(cv::Mat& img); void SetDispBuffer(cv::Mat& img); void SetGazeV(cv::Point gazeV); cv::Point GetGazeV(); cv::Point2f GetGazeI(); + cv::Point2f GetEyeR(); + cv::Point2f GetEyeL(); + // �C�����C���֐� bool IsRunning() { return _Running; } void Stop() { _Running = false; } diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index 6b982ef..0414528 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -53,7 +53,9 @@ // �C�x���g���[�v bool ECTrainerGUI::MainLoop() { - bool fShowEyes = false; + bool fShowEyesPos = true; + bool fStimulus = false; + float targetSize = 1.0; while (_pEct->IsRunning() && cv::getWindowProperty(WIN_MAIN, 0) >= 0) { @@ -76,18 +78,35 @@ } // �h���摜 + float dist; if (_pEct->GetGazeI().x >= 0) { cv::circle(_DispImage, cv::Point((int)(_DispImage.cols * _pEct->GetGazeI().x), (int)(_DispImage.rows * _pEct->GetGazeI().y)), (int)(_DispImage.rows * 0.03), CV_RGB(0, 0, 255), 1); } + if (fStimulus && fShowEyesPos) { + cv::circle(_DispImage, + cv::Point((int)(_DispImage.cols * _pEct->GetEyeR().x), (int)(_DispImage.rows * _pEct->GetEyeR().y)), + (int)(_DispImage.rows * 0.03), CV_RGB(0, 128, 0), 1); + cv::circle(_DispImage, + cv::Point((int)(_DispImage.cols * _pEct->GetEyeL().x), (int)(_DispImage.rows * _pEct->GetEyeL().y)), + (int)(_DispImage.rows * 0.03), CV_RGB(0, 128, 0), 1); + } // UI�`�� cvui::image(_MainFrame, 0, 0, _Logo); 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::checkbox("Show Eyes", &fShowEyes); + if (fStimulus) { + if (cvui::button(140, 30, "STOP")) fStimulus = false; + if (cvui::button(140, 30, "NEXT")) _pEct->Next(); + cvui::trackbar(140, &targetSize, (float)0, (float)3.0); + cvui::checkbox("Show Eyes", &fShowEyesPos); + } else { + if (cvui::button(140, 30, "CALIBRATION")) _pEct->Calib(); + if (cvui::button(140, 30, "START")) { + _pEct->Start(); fStimulus = true; + } + } 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); diff --git a/ECTrainer2/Marker.cpp b/ECTrainer2/Marker.cpp index 950d8b0..3c401c1 100644 --- a/ECTrainer2/Marker.cpp +++ b/ECTrainer2/Marker.cpp @@ -19,6 +19,7 @@ float itvX = (1.0F - 2.0F * MARGIN.x - width) / 2.0F; float itvY = (1.0F - 2.0F * MARGIN.y - HEIGHT) / 2.0F; // ���W�v�Z + _Corners.clear(); for (int iy = 0; iy < 3; iy++) { for (int ix = 0; ix < 3; ix++) { if (ix == 1 && iy == 1) continue; // ���S�ɂ̓}�[�J�[��u���Ȃ� diff --git a/ECTrainer2/Marker.h b/ECTrainer2/Marker.h index caee3a8..5202645 100644 --- a/ECTrainer2/Marker.h +++ b/ECTrainer2/Marker.h @@ -5,7 +5,7 @@ class Marker { - const cv::Point2f MARGIN = cv::Size2f(0.02F, 0.02F); + const cv::Point2f MARGIN = cv::Size2f(0.03F, 0.03F); const float OUTER_MARGIN = 0.01F; const float HEIGHT = 0.1F; diff --git a/ECTrainer2/StimData.txt b/ECTrainer2/StimData.txt index 0ba342f..edb50ac 100644 --- a/ECTrainer2/StimData.txt +++ b/ECTrainer2/StimData.txt @@ -1 +1,3 @@ +../images/illust.jpg 0.46 0.43 0.55 0.43 ../images/lena.jpg 0.49 0.45 0.57 0.45 +../images/other.jpg 0.52 0.43 0.67 0.40 diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index 9f71279..4b68258 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -28,7 +28,8 @@ 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); + std::cout << st.filename << st.eyes[0] << st.eyes[1] << std::endl; + if (st.filename.size() > 0) _StimImages.push_back(st); } return true; @@ -47,19 +48,26 @@ // �L�����u���[�V�����J�n -void Stimulus::StartCalib() { +void Stimulus::Calibration() { _DispBuffer = cv::imread(CALIB_FILE); } -// �h���摜�J�n -void Stimulus::StartImage() { +// �J�n +void Stimulus::Start() { _StimNo = 0; SetStimulus(); } +// ���� +void Stimulus::Next() { + _StimNo = (_StimNo + 1) % _StimImages.size(); + SetStimulus(); +} + // �h�����Z�b�g void Stimulus::SetStimulus() { - _DispBuffer = cv::imread(_StimImages[_StimNo].filename); - _pMarker->Generate(_DispBuffer.size()); - _pMarker->DrawMarker(_DispBuffer); + cv::Mat img = cv::imread(_StimImages[_StimNo].filename); + _pMarker->Generate(img.size()); + _pMarker->DrawMarker(img); + img.copyTo(_DispBuffer); } diff --git a/ECTrainer2/Stimulus.h b/ECTrainer2/Stimulus.h index cccb8a7..809c1d6 100644 --- a/ECTrainer2/Stimulus.h +++ b/ECTrainer2/Stimulus.h @@ -27,7 +27,9 @@ Stimulus(ECTrainer* pEct, Marker* pMarker); bool Init(); bool MainLoop(); - void StartCalib(); - void StartImage(); - void StartMovie(); + void Calibration(); + void Start(); + void Next(); + cv::Point2f GetEyeR() { return _StimImages[_StimNo].eyes[0]; } + cv::Point2f GetEyeL() { return _StimImages[_StimNo].eyes[1]; } }; diff --git a/images/finish.jpg b/images/finish.jpg new file mode 100644 index 0000000..d2ea015 --- /dev/null +++ b/images/finish.jpg Binary files differ diff --git a/images/illust.jpg b/images/illust.jpg new file mode 100644 index 0000000..eb8c62f --- /dev/null +++ b/images/illust.jpg Binary files differ diff --git a/images/other.jpg b/images/other.jpg new file mode 100644 index 0000000..3acc397 --- /dev/null +++ b/images/other.jpg Binary files differ diff --git a/images/praise2.jpg b/images/praise2.jpg new file mode 100644 index 0000000..5362a36 --- /dev/null +++ b/images/praise2.jpg Binary files differ