summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-06-18 08:48:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-06-18 08:48:46 +0200
commit4209d8a9c4b4cb36054203a263063cc61fe2c3a4 (patch)
treef2320924036060020fe78ae917be4bc1e94ccc1b
parent47a512da1e98b88cd96fc761c567cef4eadd376c (diff)
parenta001c2b6de41f4593ae94005ed5449ef5589ab4d (diff)
Merge branch 'unstable' into trackhat-ui
Conflicts: ftnoir_tracker_pt/point_extractor.cpp
-rw-r--r--cmake/mingw-w64-debug.cmake38
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.h1
-rw-r--r--opentrack/simple-mat.hpp27
-rw-r--r--opentrack/state.hpp6
4 files changed, 55 insertions, 17 deletions
diff --git a/cmake/mingw-w64-debug.cmake b/cmake/mingw-w64-debug.cmake
new file mode 100644
index 00000000..7a371e5d
--- /dev/null
+++ b/cmake/mingw-w64-debug.cmake
@@ -0,0 +1,38 @@
+# this file only serves as toolchain file when specified so explicitly
+# when building the software. from repository's root directory:
+# mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=$(pwd)/../cmake/mingw-w64.cmake
+# -sh 20140922
+
+SET(CMAKE_SYSTEM_NAME Windows)
+SET(CMAKE_SYSTEM_VERSION 1)
+
+# specify the cross compiler
+set(c i686-w64-mingw32-)
+
+SET(CMAKE_C_COMPILER ${c}gcc)
+SET(CMAKE_CXX_COMPILER ${c}g++)
+set(CMAKE_RC_COMPILER ${c}windres)
+set(CMAKE_LINKER ${c}ld)
+set(CMAKE_AR ${c}gcc-ar CACHE STRING "" FORCE)
+set(CMAKE_NM ${c}gcc-nm CACHE STRING "" FORCE)
+set(CMAKE_RANLIB ${c}gcc-ranlib CACHE STRING "" FORCE)
+
+SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
+
+# search for programs in the host directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+# don't poison with system compile-time data
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+set(cpu "-O2 -march=i686 -mtune=corei7-avx -ffast-math -mfpmath=both -msse -msse2 -mno-sse3 -mno-avx")
+set(rice "-ggdb")
+
+set(CFLAGS-OVERRIDE "" CACHE STRING "")
+
+set(CMAKE_C_FLAGS_RELEASE "${rice} ${cpu} ${CFLAGS-OVERRIDE}" CACHE STRING "" FORCE)
+set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE)
+set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${cpu} ${CFLAGS-OVERRIDE}" CACHE STRING "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} CACHE STRING "" FORCE)
+set(CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} CACHE STRING "" FORCE)
+set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "" FORCE)
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
index 771631cd..3b9f1648 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
@@ -22,7 +22,6 @@
#include <QMutex>
#include <QMutexLocker>
#include <QTime>
-#include <opencv2/core/core.hpp>
#include <atomic>
#ifndef OPENTRACK_API
# include <boost/shared_ptr.hpp>
diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp
index 5ee9029c..1cea967e 100644
--- a/opentrack/simple-mat.hpp
+++ b/opentrack/simple-mat.hpp
@@ -2,6 +2,7 @@
#include <algorithm>
#include <initializer_list>
#include <type_traits>
+#include <cmath>
namespace {
// last param to fool SFINAE into overloading
@@ -215,22 +216,20 @@ struct Mat
static dmat<3, 1> rmat_to_euler(const dmat<3, 3>& R)
{
static constexpr double pi = 3.141592653;
- const double up = 90 * pi / 180.;
- static constexpr double bound = 1. - 2e-4;
- if (R(0, 2) > bound)
+ const double pitch_1 = asin(-R(0, 2));
+ const double pitch_2 = pi - pitch_1;
+ const double cos_p1 = cos(pitch_1), cos_p2 = cos(pitch_2);
+ const double roll_1 = atan2(R(1, 2) / cos_p1, R(2, 2) / cos_p1);
+ const double roll_2 = atan2(R(1, 2) / cos_p2, R(2, 2) / cos_p2);
+ const double yaw_1 = atan2(R(0, 1) / cos_p1, R(0, 0) / cos_p1);
+ const double yaw_2 = atan2(R(0, 1) / cos_p2, R(0, 0) / cos_p2);
+ if (std::abs(pitch_1) + std::abs(roll_1) + std::abs(yaw_1) > std::abs(pitch_2) + std::abs(roll_2) + std::abs(yaw_2))
{
- double roll = atan(R(1, 0) / R(2, 0));
- return dmat<3, 1>({0., up, roll});
+ bool fix_neg_pitch = pitch_1 < 0;
+ return dmat<3, 1>({yaw_2, std::fmod(fix_neg_pitch ? -pi - pitch_1 : pitch_2, pi), roll_2});
}
- if (R(0, 2) < -bound)
- {
- double roll = atan(R(1, 0) / R(2, 0));
- return dmat<3, 1>({0., -up, roll});
- }
- double pitch = asin(-R(0, 2));
- double roll = atan2(R(1, 2), R(2, 2));
- double yaw = atan2(R(0, 1), R(0, 0));
- return dmat<3, 1>({yaw, pitch, roll});
+ else
+ return dmat<3, 1>({yaw_1, pitch_1, roll_1});
}
// tait-bryan angles, not euler
diff --git a/opentrack/state.hpp b/opentrack/state.hpp
index a9f66241..bfbf113e 100644
--- a/opentrack/state.hpp
+++ b/opentrack/state.hpp
@@ -1,11 +1,13 @@
+#pragma once
+
#include <vector>
#include "opentrack/options.hpp"
using namespace options;
#include "opentrack/plugin-support.hpp"
#include "opentrack/main-settings.hpp"
#include "opentrack/mappings.hpp"
-
-struct Work;
+#include "opentrack/selected-libraries.hpp"
+#include "opentrack/work.hpp"
struct State {
State() :