From 81e2c265c795d9eda41ebed6550e1f7954db9bc5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 9 Dec 2013 00:53:26 +0100 Subject: move translation compensation to its own function Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 6c48b17a..b65ccde8 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -50,6 +50,39 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { out += axis.zero; } +static void t_compensate(double* input, double* output) +{ + const auto H = input[Yaw] * M_PI / 180; + const auto P = input[Pitch] * M_PI / 180; + const auto B = input[Roll] * M_PI / 180; + + const auto cosH = cos(H); + const auto sinH = sin(H); + const auto cosP = cos(P); + const auto sinP = sin(P); + const auto cosB = cos(B); + const auto sinB = sin(B); + + double foo[] = { + cosH * cosB - sinH * sinP * sinB, + - sinB * cosP, + sinH * cosB + cosH * sinP * sinB, + cosH * sinB + sinH * sinP * cosB, + cosB * cosP, + sinB * sinH - cosH * sinP * cosB, + - sinH * cosP, + - sinP, + cosH * cosP, + }; + + cv::Mat rmat(3, 3, CV_64F, foo); + const cv::Mat tvec(3, 1, CV_64F, input); + cv::Mat ret = rmat * tvec; + + for (int i = 0; i < 3; i++) + output[i] = ret.at(i); +} + /** QThread run method @override **/ void Tracker::run() { T6DOF offset_camera, gameoutput_camera, target_camera; @@ -129,37 +162,7 @@ void Tracker::run() { } if (compensate) - { - const auto H = output_camera.axes[Yaw] * M_PI / 180; - const auto P = output_camera.axes[Pitch] * M_PI / 180; - const auto B = output_camera.axes[Roll] * M_PI / 180; - - const auto cosH = cos(H); - const auto sinH = sin(H); - const auto cosP = cos(P); - const auto sinP = sin(P); - const auto cosB = cos(B); - const auto sinB = sin(B); - - double foo[] = { - cosH * cosB - sinH * sinP * sinB, - - sinB * cosP, - sinH * cosB + cosH * sinP * sinB, - cosH * sinB + sinH * sinP * cosB, - cosB * cosP, - sinB * sinH - cosH * sinP * cosB, - - sinH * cosP, - - sinP, - cosH * cosP, - }; - - cv::Mat rmat(3, 3, CV_64F, foo); - cv::Mat tvec(3, 1, CV_64F, output_camera.axes); - cv::Mat ret = rmat * tvec; - - for (int i = 0; i < 3; i++) - output_camera.axes[i] = ret.at(i); - } + t_compensate(output_camera.axes, output_camera.axes); if (Libraries->pProtocol) { gameoutput_camera = output_camera; -- cgit v1.2.3 From a225aac16f8ed9047792597c9993c24e0a20031b Mon Sep 17 00:00:00 2001 From: usrusr Date: Tue, 10 Dec 2013 01:59:06 +0100 Subject: fork info --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index fbbead33..8475ecfe 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + Windows binary builds are available at Source code access available at @@ -56,3 +57,9 @@ compatible with it unless resides in separate address space. It's recommended to submit new code under ISC license, it's a shorter boilerplate header than MIT/X11 or new BSD. + +# this fork/branch: usrusr/opentrack feature/pt-hysteresis + +Per pixel hysteresis for point tracker: sacrifice some precision, cpu and sensitivity to minor movements for greatly reduced jitter from pixel noise at full responsivity (usable without postprocessing filters!) +-- Ulf Schreiber +Ulf Schreiber -- cgit v1.2.3