summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-17 11:24:12 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-17 11:24:12 +0200
commiteb1a95e3cea400340e5a64c2791a4a09ca3a0074 (patch)
tree238ad2f3a3e392074dfefb4abdf3437f867fa0c4
parent547b8f94b2f2814a6ef86e6022c6525b03fcbd2d (diff)
parent619d3d8010b3c093fba8e87f831cc438d8822479 (diff)
Merge commit 'f78b96a' into unstable
* commit 'f78b96a': gcc too much a piece of work often submit mapped data to filter, not raw nonsense drop decimal places for rot/trans in UI rotation below -99 didn't display, just froze add-comment
-rw-r--r--facetracknoir/facetracknoir.cpp6
-rw-r--r--facetracknoir/facetracknoir.h2
-rw-r--r--facetracknoir/facetracknoir.ui42
-rw-r--r--facetracknoir/options.h12
-rw-r--r--facetracknoir/tracker.cpp103
-rw-r--r--facetracknoir/tracker.h6
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp13
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.h2
8 files changed, 97 insertions, 89 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index f689cb5f..73dae199 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -353,6 +353,12 @@ void FaceTrackNoIR::showHeadPose()
if (mapping_widget)
mapping_widget->update();
+
+ for (int i = 0; i < 6; i++)
+ {
+ mapped[i] = (int) mapped[i];
+ raw[i] = (int) raw[i];
+ }
ui.lcdNumX->display(raw[TX]);
ui.lcdNumY->display(raw[TY]);
diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h
index d4c3a369..040bb170 100644
--- a/facetracknoir/facetracknoir.h
+++ b/facetracknoir/facetracknoir.h
@@ -91,6 +91,8 @@ public slots:
void shortcutRecentered();
void shortcutToggled();
private:
+ // XXX move the shit outta the _widget_, establish a class
+ // for running tracker state, etc -sh 20141014
Mappings pose;
Ui::OpentrackUI ui;
QTimer timUpdateHeadPose;
diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui
index ad968030..a201b643 100644
--- a/facetracknoir/facetracknoir.ui
+++ b/facetracknoir/facetracknoir.ui
@@ -95,7 +95,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Outline</enum>
@@ -117,7 +117,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Outline</enum>
@@ -165,7 +165,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Outline</enum>
@@ -187,7 +187,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Outline</enum>
@@ -247,7 +247,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Outline</enum>
@@ -295,7 +295,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Outline</enum>
@@ -341,14 +341,11 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
<property name="smallDecimalPoint">
<bool>true</bool>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
@@ -369,14 +366,11 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
<property name="smallDecimalPoint">
<bool>true</bool>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
@@ -413,14 +407,11 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
<property name="smallDecimalPoint">
<bool>true</bool>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
@@ -463,14 +454,11 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
<property name="smallDecimalPoint">
<bool>true</bool>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
@@ -529,14 +517,11 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
<property name="smallDecimalPoint">
<bool>true</bool>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
@@ -573,14 +558,11 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
- </property>
<property name="smallDecimalPoint">
<bool>true</bool>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
diff --git a/facetracknoir/options.h b/facetracknoir/options.h
index 7833ea41..d9667e4a 100644
--- a/facetracknoir/options.h
+++ b/facetracknoir/options.h
@@ -75,7 +75,7 @@ namespace options {
// snapshot of qsettings group at given time
class group {
private:
- map<string, QVariant> map;
+ map<string, QVariant> kvs;
string name;
static const QString ini_pathname()
{
@@ -93,7 +93,7 @@ namespace options {
{
auto tmp = k_.toUtf8();
string k(tmp);
- map[k] = conf.value(k_);
+ kvs[k] = conf.value(k_);
}
conf.endGroup();
}
@@ -104,7 +104,7 @@ namespace options {
QSettings s(ini_pathname(), QSettings::IniFormat);
auto q_name = QString::fromStdString(name);
s.beginGroup(q_name);
- for (auto& i : map)
+ for (auto& i : kvs)
{
auto k = QString::fromStdString(i.first);
s.setValue(k, i.second);
@@ -115,17 +115,17 @@ namespace options {
template<typename t>
t get(const string& k)
{
- return qcruft_to_t<t>(map[k]);
+ return qcruft_to_t<t>(kvs[k]);
}
void put(const string& s, const QVariant& d)
{
- map[s] = d;
+ kvs[s] = d;
}
bool contains(const string& s)
{
- return map.count(s) != 0;
+ return kvs.count(s) != 0;
}
};
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp
index 09edd45b..0f299153 100644
--- a/facetracknoir/tracker.cpp
+++ b/facetracknoir/tracker.cpp
@@ -36,14 +36,13 @@ Tracker::~Tracker()
wait();
}
-void Tracker::get_curve(double pos, double& out, Mapping& axis) {
+double Tracker::map(double pos, Mapping& axis) {
bool altp = (pos < 0) && axis.opts.altp;
axis.curve.setTrackingActive( !altp );
axis.curveAlt.setTrackingActive( altp );
auto& fc = altp ? axis.curveAlt : axis.curve;
- out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos);
-
- out += axis.opts.zero;
+ double invert = axis.opts.invert ? -1 : 1;
+ return invert * (fc.getValue(pos) + axis.opts.zero);
}
void Tracker::t_compensate(const double* input, double* output, bool rz)
@@ -82,24 +81,14 @@ void Tracker::t_compensate(const double* input, double* output, bool rz)
output[i] = ret(i);
}
-void Tracker::run() {
- Pose pose_offset, unstopped_pose;
-
- double newpose[6] = {0};
- const int sleep_ms = 3;
-
-#if defined(_WIN32)
- (void) timeBeginPeriod(1);
-#endif
+void Tracker::logic()
+{
+ Libraries->pTracker->GetHeadPoseData(newpose);
+
+ Pose final_raw;
- while (!should_quit)
+ if (enabledp)
{
- t.start();
-
- Libraries->pTracker->GetHeadPoseData(newpose);
-
- Pose final_raw, filtered;
-
for (int i = 0; i < 6; i++)
{
auto& axis = m(i);
@@ -109,37 +98,57 @@ void Tracker::run() {
// not really raw, after axis remap -sh
final_raw(i) = newpose[k];
}
+ unstopped_raw = final_raw;
+ }
+
+ Pose filtered_pose;
+
+ if (Libraries->pFilter)
+ Libraries->pFilter->FilterHeadPoseData(final_raw, filtered_pose);
+ else
+ filtered_pose = final_raw;
+
+ if (centerp)
+ {
+ centerp = false;
+ raw_center = final_raw;
+ }
+
+ Pose raw_centered = filtered_pose & raw_center;
+
+ Pose mapped_pose_precomp;
+
+ for (int i = 0; i < 6; i++)
+ mapped_pose_precomp(i) = map(raw_centered(i), m(i));
+
+ Pose mapped_pose;
+
+ if (s.tcomp_p)
+ t_compensate(mapped_pose_precomp, mapped_pose, s.tcomp_tz);
+ else
+ mapped_pose = mapped_pose_precomp;
- {
- if (enabledp)
- unstopped_pose = final_raw;
-
- if (Libraries->pFilter)
- Libraries->pFilter->FilterHeadPoseData(unstopped_pose, filtered);
- else
- filtered = unstopped_pose;
-
- if (centerp) {
- centerp = false;
- pose_offset = filtered;
- }
-
- filtered = filtered & pose_offset;
-
- for (int i = 0; i < 6; i++)
- get_curve(filtered(i), filtered(i), m(i));
- }
+ Libraries->pProtocol->sendHeadposeToGame(mapped_pose);
- if (s.tcomp_p)
- t_compensate(filtered, filtered, s.tcomp_tz);
+ {
+ QMutexLocker foo(&mtx);
+ output_pose = mapped_pose;
+ raw_6dof = unstopped_raw;
+ }
+}
- Libraries->pProtocol->sendHeadposeToGame(filtered);
+void Tracker::run() {
+ const int sleep_ms = 3;
- {
- QMutexLocker foo(&mtx);
- output_pose = filtered;
- raw_6dof = final_raw;
- }
+#if defined(_WIN32)
+ (void) timeBeginPeriod(1);
+#endif
+
+ while (!should_quit)
+ {
+ t.start();
+
+ logic();
double q = sleep_ms * 1000L;
q -= t.elapsed();
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h
index d65e1cf1..afb86802 100644
--- a/facetracknoir/tracker.h
+++ b/facetracknoir/tracker.h
@@ -23,12 +23,14 @@ private:
// XXX can be const-cast when functionconfig const-correct -sh 20141004
Mappings& m;
Timer t;
- Pose output_pose, raw_6dof;
+ Pose output_pose, raw_6dof, raw_center, unstopped_raw;
+ double newpose[6];
std::atomic<bool> centerp;
std::atomic<bool> enabledp;
std::atomic<bool> should_quit;
- static void get_curve(double pos, double& out, Mapping& axis);
+ double map(double pos, Mapping& axis);
+ void logic();
static void t_compensate(const double* input, double* output, bool rz);
protected:
void run() override;
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
index fd8a8ce1..87c5315e 100644
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
@@ -203,6 +203,12 @@ void Tracker::run()
auto tm = cv::getTickCount();
cv::Mat grayscale;
+ {
+ std::vector<cv::Mat> tmp;
+ cv::split(color, tmp);
+ // red only, best on CCD, also artifacts on blue ps3eye
+ grayscale = tmp[2];
+ }
cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY);
const int scale = frame.cols > 480 ? 2 : 1;
@@ -221,7 +227,7 @@ void Tracker::run()
std::vector< aruco::Marker > markers;
const double size_min = 0.04;
- const double size_max = 0.38;
+ const double size_max = 0.28;
bool roi_valid = false;
@@ -229,6 +235,7 @@ void Tracker::run()
{
detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width),
std::min(1.0, size_max * grayscale.cols / last_roi.width));
+
if (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false),
markers.size() == 1 && markers[0].size() == 4)
{
@@ -299,7 +306,7 @@ void Tracker::run()
cv::Vec3d rvec, tvec;
- cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, false, cv::P3P);
+ cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, false, cv::ITERATIVE);
std::vector<cv::Point2f> roi_projection(4);
@@ -324,7 +331,7 @@ void Tracker::run()
{
cv::Mat rvec_, tvec_;
- cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec_, tvec_, false, cv::P3P);
+ cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec_, tvec_, false, cv::ITERATIVE);
tvec = tvec_;
}
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
index 3d37dacd..090cf478 100644
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
@@ -43,7 +43,7 @@ struct settings {
class Tracker : protected QThread, public ITracker
{
Q_OBJECT
- static constexpr double c_search_window = 2.2;
+ static constexpr double c_search_window = 2.65;
public:
Tracker();
~Tracker() override;