diff --git a/ECTrainer2/ECTrainer.h b/ECTrainer2/ECTrainer.h index c9b9b9b..f8d0bfd 100644 --- a/ECTrainer2/ECTrainer.h +++ b/ECTrainer2/ECTrainer.h @@ -4,6 +4,8 @@ #include "myOpenCV.h" #define ADDR "192.168.71.50" +//#define EYEDEVICE_GLASS2 +#define EYEDEVICE_NONE class BaseProcess; class ECTrainerGUI; diff --git a/ECTrainer2/EyeTrack.cpp b/ECTrainer2/EyeTrack.cpp index 507cecf..aba6369 100644 --- a/ECTrainer2/EyeTrack.cpp +++ b/ECTrainer2/EyeTrack.cpp @@ -20,6 +20,7 @@ // ���C�����[�v bool EyeTrack::MainLoop() { +#if defined(EYEDEVICE_GLASS2) int slen = _pEct->PKeepAlive()->GetSocketAddrLen(); char buf[KeepAlive::SOCKET_BUF_LEN]; int lastGidx = 0; @@ -63,6 +64,12 @@ } if (gd.isPDR && gd.s == 0) _pupilD.r = gd.pdr; } +#elif defined(EYEDEVICE_NONE) + while (_pEct->IsAppRun()) { + _GazeV.Put(cv::Point2f(-1.F, -1.F)); + Sleep(10); + } +#endif return true; } diff --git a/ECTrainer2/KeepAlive.cpp b/ECTrainer2/KeepAlive.cpp index 6045559..c732032 100644 --- a/ECTrainer2/KeepAlive.cpp +++ b/ECTrainer2/KeepAlive.cpp @@ -15,6 +15,7 @@ // ������ bool KeepAlive::Init() { +#if defined(EYEDEVICE_GLASS2) // Initialize winsock WSADATA wsa; if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) { @@ -32,12 +33,14 @@ _socketAddr.sin_family = AF_INET; _socketAddr.sin_port = htons(PORT); InetPton(_socketAddr.sin_family, _T(ADDR), &_socketAddr.sin_addr.S_un.S_addr); +#endif return true; } // ���C�����[�v bool KeepAlive::MainLoop() { +#if defined(EYEDEVICE_GLASS2) const std::string KA_DATA_MSG = "{\"type\": \"live.data.unicast\", \"key\": \"some_GUID\", \"op\": \"start\"}"; char message[SOCKET_BUF_LEN]; strcpy_s(message, SOCKET_BUF_LEN, KA_DATA_MSG.c_str()); @@ -54,6 +57,7 @@ _sent = true; } } +#endif return true; } diff --git a/ECTrainer2/SceneCamera.cpp b/ECTrainer2/SceneCamera.cpp index 62b71bc..85bb27d 100644 --- a/ECTrainer2/SceneCamera.cpp +++ b/ECTrainer2/SceneCamera.cpp @@ -14,8 +14,11 @@ // ������ bool SceneCamera::Init() { // ���E�J�����ɐڑ� +#if defined(EYEDEVICE_GLASS2) _SceneCam.open("rtsp://" ADDR ":8554/live/scene"); - //_SceneCam.open(0); +#elif defined(EYEDEVICE_NONE) + _SceneCam.open(0); +#endif if (!_SceneCam.isOpened()) { MessageBox(NULL, _T("cannot open camera " ADDR), NULL, 0); return false; diff --git a/ECTrainer2/TobiiREST.cpp b/ECTrainer2/TobiiREST.cpp index 976e2c2..c88a635 100644 --- a/ECTrainer2/TobiiREST.cpp +++ b/ECTrainer2/TobiiREST.cpp @@ -11,6 +11,7 @@ bool TobiiREST::Init() { try { +#if defined(EYEDEVICE_GLASS2) json::value json = REST_Handler::POST_Request(SERVER _T("/api/projects")).extract_json().get(); _ProjectID = json[_T("pr_id")].as_string(); std::wcout << "prId=" << _ProjectID << std::endl; @@ -20,6 +21,7 @@ json = REST_Handler::POST_Request(SERVER _T("/api/participants"), postData).extract_json().get(); _ParticipantID = json[_T("pa_id")].as_string(); std::wcout << "paId=" << _ParticipantID << std::endl; +#endif return true; } @@ -49,6 +51,7 @@ bool TobiiREST::StartCalibration() { try { +#if defined(EYEDEVICE_GLASS2) json::value postData; postData[L"ca_project"] = json::value::string(_ProjectID); postData[L"ca_type"] = json::value::string(L"default"); @@ -60,6 +63,7 @@ std::wstring url = SERVER _T("/api/calibrations/") + _CalibrationID + _T("/start"); json = REST_Handler::POST_Request(url.c_str()).extract_json().get(); std::wcout << "Calibration start" << std::endl; +#endif return true; } catch (const std::exception& e) @@ -74,6 +78,7 @@ int TobiiREST::GetCalibResult() { try { +#if defined(EYEDEVICE_GLASS2) std::wstring url = SERVER _T("/api/calibrations/") + _CalibrationID + _T("/status"); std::vector values; values.push_back(_T("failed")); @@ -84,6 +89,7 @@ return -1; } std::wcout << _T("Calibration successful.") << std::endl; +#endif return 1; } catch (const std::exception & e) @@ -97,11 +103,14 @@ // �o�b�e���[�c�ʎ擾 int TobiiREST::BatteryLevel() { try { +#if defined(EYEDEVICE_GLASS2) std::wstring url = SERVER _T("/api/system/status"); auto response = REST_Handler::GET_Request(url.c_str()); json::value json = response.extract_json().get(); return json[L"sys_battery"][L"level"].as_integer(); - +#elif defined(EYEDEVICE_NONE) + return 999; +#endif } catch (const std::exception & e) { std::cout << "Error " << e.what() << std::endl; return 0;