diff --git a/ECTrainer2/ECTrainer2.vcxproj b/ECTrainer2/ECTrainer2.vcxproj index b12ed55..d6d983d 100644 --- a/ECTrainer2/ECTrainer2.vcxproj +++ b/ECTrainer2/ECTrainer2.vcxproj @@ -145,6 +145,7 @@ + @@ -152,6 +153,7 @@ + diff --git a/ECTrainer2/ECTrainer2.vcxproj.filters b/ECTrainer2/ECTrainer2.vcxproj.filters index 2d1e91e..e0d22b8 100644 --- a/ECTrainer2/ECTrainer2.vcxproj.filters +++ b/ECTrainer2/ECTrainer2.vcxproj.filters @@ -30,6 +30,9 @@ ソース ファイル + + ソース ファイル + @@ -50,5 +53,8 @@ ヘッダー ファイル + + ヘッダー ファイル + \ No newline at end of file diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp index 26e48c0..7cee977 100644 --- a/ECTrainer2/ECTrainerGUI.cpp +++ b/ECTrainer2/ECTrainerGUI.cpp @@ -19,7 +19,7 @@ GetDisplayInfo(); // GUI�E�C���h�E cvui::init(WIN_MAIN); - _MainFrame.create(cv::Size(640, 400), CV_8UC3); + _MainFrame.create(MAIN_FRAME_SIZE, CV_8UC3); // �h���񎦃E�C���h�E cv::namedWindow(WIN_DISP, cv::WINDOW_NORMAL | cv::WINDOW_OPENGL); if (_Displays.size() > 1) { diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h index 735f859..b6a5431 100644 --- a/ECTrainer2/ECTrainerGUI.h +++ b/ECTrainer2/ECTrainerGUI.h @@ -12,7 +12,10 @@ private: const cv::String WIN_DISP = "ECTrainer Display"; const cv::String WIN_MAIN = "Eye Contact Trainer"; - const cv::Size SCENE_BUFFER_SIZE = cv::Size(320, 180); + //const cv::Size MAIN_FRAME_SIZE = cv::Size(640, 400); + //const cv::Size SCENE_BUFFER_SIZE = cv::Size(320, 180); + const cv::Size MAIN_FRAME_SIZE = cv::Size(1600, 1000); + const cv::Size SCENE_BUFFER_SIZE = cv::Size(1280, 720); const int KEY_ESC = 27; ECTrainer* _pEct; diff --git a/ECTrainer2/Marker.cpp b/ECTrainer2/Marker.cpp new file mode 100644 index 0000000..ea43524 --- /dev/null +++ b/ECTrainer2/Marker.cpp @@ -0,0 +1,25 @@ +#include "Marker.h" + +void Marker::Generate(cv::Size imgsize) { + // �萔�̌v�Z + float width = imgsize.height * HEIGHT / imgsize.width; + float itvX = (1.0 - 2 * MARGIN.x - width) / 2; + float itvY = (1.0 - 2 * MARGIN.y - HEIGHT) / 2; + // ���W�v�Z + for (int iy = 0; iy < 3; iy++) { + for (int ix = 0; ix < 3; ix++) { + if (ix == 1 && iy == 1) continue; // ���S�ɂ̓}�[�J�[��u���Ȃ� + + std::vector marker; + marker.push_back(cv::Point2f( + MARGIN.x + itvX * ix, MARGIN.y + itvY * iy)); + marker.push_back(cv::Point2f( + MARGIN.x + itvX * ix + width, MARGIN.y + itvY * iy)); + marker.push_back(cv::Point2f( + MARGIN.x + itvX * ix + width, MARGIN.y + itvY * iy + HEIGHT)); + marker.push_back(cv::Point2f( + MARGIN.x + itvX * ix, MARGIN.y + itvY * iy + HEIGHT)); + _Corners.push_back(marker); + } + } +} diff --git a/ECTrainer2/Marker.h b/ECTrainer2/Marker.h new file mode 100644 index 0000000..c532f22 --- /dev/null +++ b/ECTrainer2/Marker.h @@ -0,0 +1,13 @@ +#pragma once + +#include "myOpenCV.h" +#include + +class Marker +{ + std::vector> _Corners; + const cv::Point2f MARGIN = cv::Size2f(0.5, 0.5); + const float HEIGHT = 0.1F; +public: + void Generate(cv::Size imgsize); +}; diff --git a/ECTrainer2/SceneCamera.cpp b/ECTrainer2/SceneCamera.cpp index bbcddfe..52f54fd 100644 --- a/ECTrainer2/SceneCamera.cpp +++ b/ECTrainer2/SceneCamera.cpp @@ -29,6 +29,20 @@ // �V�[���B�e cv::Mat scene; _SceneCam >> scene; + + cv::Ptr dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); + std::vector mids; + std::vector> corners; + cv::Ptr parameters = cv::aruco::DetectorParameters::create(); + cv::aruco::detectMarkers(scene, dictionary, corners, mids, parameters); + cv::aruco::drawDetectedMarkers(scene, corners, mids); + if (corners.size() > 0) { + cv::putText(scene, "0", cv::Point((int)corners[0][0].x, (int)corners[0][0].y), cv::FONT_HERSHEY_PLAIN, 2.0, CV_RGB(255, 0, 0)); + cv::putText(scene, "1", corners[0][1], cv::FONT_HERSHEY_PLAIN, 2.0, CV_RGB(255, 0, 0)); + cv::putText(scene, "2", corners[0][2], cv::FONT_HERSHEY_PLAIN, 2.0, CV_RGB(255, 0, 0)); + cv::putText(scene, "3", corners[0][3], cv::FONT_HERSHEY_PLAIN, 2.0, CV_RGB(255, 0, 0)); + } + _pEct->SetSceneBuffer(scene); } diff --git a/ECTrainer2/Stimulus.cpp b/ECTrainer2/Stimulus.cpp index d3c3144..5be6491 100644 --- a/ECTrainer2/Stimulus.cpp +++ b/ECTrainer2/Stimulus.cpp @@ -30,6 +30,13 @@ // �h���摜�J�n void Stimulus::StartImage() { - cv::Mat img = cv::imread("../images/lena.jpg"); + //cv::Mat img = cv::imread("../images/lena.jpg"); + cv::Mat img = cv::imread("../images/face_F_L_E.png"); _pEct->SetDispBuffer(img); } + +// �摜�Ƀ}�[�J�[��t�^ +void Stimulus::AddMarker(cv::Mat& img) { + cv::Ptr dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50); + cv::aruco::drawMarker(dictionary, 23, 200, img, 1); +} diff --git a/ECTrainer2/Stimulus.h b/ECTrainer2/Stimulus.h index cd877ab..a61245a 100644 --- a/ECTrainer2/Stimulus.h +++ b/ECTrainer2/Stimulus.h @@ -14,6 +14,7 @@ Stimulus(ECTrainer* pEct); bool Init(); bool MainLoop(); + void AddMarker(cv::Mat& img); void StartCalib(); void StartImage(); void StartMovie(); diff --git a/ECTrainer2/myOpenCV.h b/ECTrainer2/myOpenCV.h index b21806a..e53a66e 100644 --- a/ECTrainer2/myOpenCV.h +++ b/ECTrainer2/myOpenCV.h @@ -7,6 +7,7 @@ // �w�b�_�[�t�@�C�� #pragma warning(disable: 4819) #include +#include #pragma warning(default: 4819) // �o�[�W�����擾