diff --git a/ECTrainer1/ECTrainer1.vcxproj b/ECTrainer1/ECTrainer1.vcxproj index 6cf539f..67d570f 100644 --- a/ECTrainer1/ECTrainer1.vcxproj +++ b/ECTrainer1/ECTrainer1.vcxproj @@ -197,6 +197,7 @@ + @@ -208,6 +209,7 @@ Create Create + diff --git a/ECTrainer1/ECTrainer1.vcxproj.filters b/ECTrainer1/ECTrainer1.vcxproj.filters index eff4ee2..a66dfc3 100644 --- a/ECTrainer1/ECTrainer1.vcxproj.filters +++ b/ECTrainer1/ECTrainer1.vcxproj.filters @@ -36,6 +36,9 @@ ヘッダー ファイル + + ヘッダー ファイル + @@ -47,6 +50,9 @@ ソース ファイル + + ソース ファイル + diff --git a/ECTrainer1/ECTrainer1Dlg.cpp b/ECTrainer1/ECTrainer1Dlg.cpp index 25392b1..de0d709 100644 --- a/ECTrainer1/ECTrainer1Dlg.cpp +++ b/ECTrainer1/ECTrainer1Dlg.cpp @@ -9,6 +9,7 @@ #include "afxdialogex.h" #include #include +#include "RingBuffer.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -500,6 +501,7 @@ Point2f gp; std::ofstream ofs; int64 start = 0; + RingBuffer gpCx(DATA_MEAN_SIZE), gpCy(DATA_MEAN_SIZE); Sleep(500); // 最初のKeepAlive送信待ち @@ -518,7 +520,9 @@ if (gd.gidx > lastGidx) { if (gp.x > 0 && gp.y > 0 && !_homography.empty()) { // 座標変換 - _gpC = Point2f(gp.x * _frameSize.width, gp.y * _frameSize.height); + gpCx.Push(gp.x * _frameSize.width); + gpCy.Push(gp.y * _frameSize.height); + _gpC = Point2f(gpCx.Mean(), gpCy.Mean()); Mat gpCe = (cv::Mat_(3, 1) << _gpC.x, _gpC.y, 1); Mat gpWe = _homography * gpCe; double* pgpWe = gpWe.ptr(0); diff --git a/ECTrainer1/ECTrainer1Dlg.h b/ECTrainer1/ECTrainer1Dlg.h index 27f9d46..30a8253 100644 --- a/ECTrainer1/ECTrainer1Dlg.h +++ b/ECTrainer1/ECTrainer1Dlg.h @@ -8,9 +8,9 @@ #include #include "myOpenCV.h" -//#define ADDR "192.168.71.50" +#define ADDR "192.168.71.50" //#define ADDR "192.168.23.158" -#define ADDR "192.168.14.107" +//#define ADDR "192.168.14.107" const std::string KA_DATA_MSG = "{\"type\": \"live.data.unicast\", \"key\": \"some_GUID\", \"op\": \"start\"}"; @@ -33,6 +33,7 @@ static const int FRAMES = 2; static const int DURATION = 3000; // Time for one image (ms) static const int NOLOG = 1000; // Time for no logging (ms) + static const int DATA_MEAN_SIZE = 10; HICON _hIcon; bool _bRunning; diff --git a/ECTrainer1/RingBuffer.cpp b/ECTrainer1/RingBuffer.cpp new file mode 100644 index 0000000..76e1808 --- /dev/null +++ b/ECTrainer1/RingBuffer.cpp @@ -0,0 +1,2 @@ +#include "pch.h" +#include "RingBuffer.h" diff --git a/ECTrainer1/RingBuffer.h b/ECTrainer1/RingBuffer.h new file mode 100644 index 0000000..0201a42 --- /dev/null +++ b/ECTrainer1/RingBuffer.h @@ -0,0 +1,35 @@ +#pragma once + +#include + +class RingBuffer +{ + float *_buffer; + int _size; + int _next; + float _sum; + +public: + RingBuffer(int size) { + _size = size; + _next = 0; + _sum = 0; + _buffer = new float[_size]; + for (int i = 0; i < _size; i++) _buffer[i] = 0; + } + + ~RingBuffer() { + delete[] _buffer; + } + + void Push(float val) { + _sum -= _buffer[_next]; + _buffer[_next] = val; + _sum += val; + _next = (_next + 1) % _size; + } + + float Mean() { + return _sum / _size; + } +}; diff --git a/RESTtest/RESTtest.cpp b/RESTtest/RESTtest.cpp index 44827d9..91b1200 100644 --- a/RESTtest/RESTtest.cpp +++ b/RESTtest/RESTtest.cpp @@ -10,6 +10,9 @@ using namespace web::http; using namespace web::http::client; +//#define SERVER _T("http://192.168.14.107") +#define SERVER _T("http://192.168.71.50") + pplx::task Get() { return pplx::create_task([] @@ -118,13 +121,13 @@ try { - json::value json = POST_request(_T("http://192.168.14.107/api/projects")).extract_json().get(); + json::value json = POST_request(SERVER _T("/api/projects")).extract_json().get(); auto prId = json[_T("pr_id")].as_string(); std::wcout << "prId=" << prId << std::endl; json::value postData; postData[L"pa_project"] = json::value::string(prId); - json = POST_request(_T("http://192.168.14.107/api/participants"), postData).extract_json().get(); + json = POST_request(SERVER _T("/api/participants"), postData).extract_json().get(); auto paId = json[_T("pa_id")].as_string(); std::wcout << "paId=" << paId << std::endl; @@ -132,14 +135,14 @@ postData2[L"ca_project"] = json::value::string(prId); postData2[L"ca_type"] = json::value::string(L"default"); postData2[L"ca_participant"] = json::value::string(paId); - json = POST_request(_T("http://192.168.14.107/api/calibrations"), postData2).extract_json().get(); + json = POST_request(SERVER _T("/api/calibrations"), postData2).extract_json().get(); auto caId = json[_T("ca_id")].as_string(); std::wcout << "caId=" << caId << std::endl; - std::wstring url = _T("http://192.168.14.107/api/calibrations/") + caId + _T("/start"); + std::wstring url = SERVER _T("/api/calibrations/") + caId + _T("/start"); json = POST_request(url.c_str()).extract_json().get(); - url = _T("http://192.168.14.107/api/calibrations/") + caId + _T("/status"); + url = SERVER _T("/api/calibrations/") + caId + _T("/status"); std::vector values; values.push_back(_T("failed")); values.push_back(_T("calibrated"));