summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-03-21 16:42:17 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-03-21 16:59:09 +0100
commit69137c3d2b583b30b76f3e4a103fba6b9abd97fe (patch)
treeac7d8c8e85cee0a1b41e8711da4aeaec6c5a4139
parent4896a8a8cdce0a6da8379b3ee167773c97fc7131 (diff)
tracker/pt: hardcode trackmouse settings
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp17
-rw-r--r--tracker-pt/ftnoir_tracker_pt_dialog.cpp1
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.h69
-rw-r--r--tracker-pt/point_extractor.cpp2
-rw-r--r--tracker-pt/point_tracker.cpp28
5 files changed, 63 insertions, 54 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index e35acc0e..8a5950f2 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -24,8 +24,13 @@ Tracker_PT::Tracker_PT() :
ever_success(false)
{
connect(s.b.get(), SIGNAL(saving()), this, SLOT(maybe_reopen_camera()), Qt::DirectConnection);
+#if 0
connect(&s.fov, SIGNAL(valueChanged(int)), this, SLOT(set_fov(int)), Qt::DirectConnection);
set_fov(s.fov);
+#endif
+
+ static constexpr int fov = 75;
+ set_fov(fov);
}
Tracker_PT::~Tracker_PT()
@@ -85,10 +90,13 @@ void Tracker_PT::run()
if (success)
{
+ const bool dynamic_pose = s.active_model_panel == settings_pt::model::cap;
+ static constexpr int init_phase_timeout = 1500;
+
point_tracker.track(points,
PointModel(s),
cam_info,
- s.dynamic_pose ? s.init_phase_timeout : 0);
+ dynamic_pose ? init_phase_timeout : 0);
ever_success = true;
}
@@ -131,12 +139,15 @@ void Tracker_PT::maybe_reopen_camera()
{
QMutexLocker l(&camera_mtx);
- Camera::open_status status = camera.start(camera_name_to_index(s.camera_name), s.cam_fps, s.cam_res_x, s.cam_res_y);
+ static constexpr int cam_fps = 60, cam_res_x = 640, cam_res_y = 480;
+ static const QString camera_name = "PS3Eye Camera";
+
+ Camera::open_status status = camera.start(camera_name_to_index(camera_name), cam_fps, cam_res_x, cam_res_y);
switch (status)
{
case Camera::open_error:
- qDebug() << "can't start camera" << s.camera_name;
+ qDebug() << "can't start camera" << camera_name;
break;
case Camera::open_ok_change:
frame = cv::Mat();
diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp
index 6851e3fd..67b2ff93 100644
--- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp
+++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp
@@ -63,6 +63,7 @@ TrackerDialog_PT::TrackerDialog_PT()
tie_setting(s.auto_threshold, ui.auto_threshold);
+ tie_setting(s.active_model_panel, ui.model_used);
connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)));
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.h b/tracker-pt/ftnoir_tracker_pt_settings.h
index d890bbd2..7efbe0c3 100644
--- a/tracker-pt/ftnoir_tracker_pt_settings.h
+++ b/tracker-pt/ftnoir_tracker_pt_settings.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2012 Patrick Ruoff
- * Copyright (c) 2014-2015 Stanislaw Halik <sthalik@misaki.pl>
+ * Copyright (c) 2014-2017 Stanislaw Halik <sthalik@misaki.pl>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -9,60 +9,51 @@
#pragma once
#include "options/options.hpp"
+#include <opencv2/core.hpp>
+
using namespace options;
struct settings_pt : opts
{
- value<QString> camera_name;
- value<int> cam_res_x,
- cam_res_y,
- cam_fps,
- threshold;
- value<double> min_point_size, max_point_size;
+ enum model {
+ clip_right, clip_left, cap,
+ };
- value<int> m01_x, m01_y, m01_z;
- value<int> m02_x, m02_y, m02_z;
+ value<int> threshold;
+ value<double> min_point_size, max_point_size;
value<int> t_MH_x, t_MH_y, t_MH_z;
- value<int> clip_ty, clip_tz, clip_by, clip_bz;
- value<int> active_model_panel, cap_x, cap_y, cap_z;
-
- value<int> fov;
-
- value<bool> dynamic_pose;
- value<int> init_phase_timeout;
- value<bool> auto_threshold;
+ value<int> active_model_panel;
settings_pt() :
opts("tracker-pt"),
- camera_name(b, "camera-name", ""),
- cam_res_x(b, "camera-res-width", 640),
- cam_res_y(b, "camera-res-height", 480),
- cam_fps(b, "camera-fps", 30),
threshold(b, "threshold-primary", 128),
min_point_size(b, "min-point-size", 1),
max_point_size(b, "max-point-size", 50),
- m01_x(b, "m_01-x", 0),
- m01_y(b, "m_01-y", 0),
- m01_z(b, "m_01-z", 0),
- m02_x(b, "m_02-x", 0),
- m02_y(b, "m_02-y", 0),
- m02_z(b, "m_02-z", 0),
t_MH_x(b, "model-centroid-x", 0),
t_MH_y(b, "model-centroid-y", 0),
t_MH_z(b, "model-centroid-z", 0),
- clip_ty(b, "clip-ty", 40),
- clip_tz(b, "clip-tz", 30),
- clip_by(b, "clip-by", 70),
- clip_bz(b, "clip-bz", 80),
- active_model_panel(b, "active-model-panel", 0),
- cap_x(b, "cap-x", 40),
- cap_y(b, "cap-y", 60),
- cap_z(b, "cap-z", 100),
- fov(b, "camera-fov", 56),
- dynamic_pose(b, "dynamic-pose-resolution", true),
- init_phase_timeout(b, "init-phase-timeout", 500),
- auto_threshold(b, "automatic-threshold", true)
+ active_model_panel(b, "active-model-panel", 0)
{}
+
+ cv::Vec3d get_model_offset()
+ {
+ cv::Vec3d offset(t_MH_x, t_MH_y, t_MH_z);
+ if (offset[0] == 0 && offset[1] == 0 && offset[2] == 0)
+ {
+ int m = active_model_panel;
+ switch (model(m))
+ {
+ default:
+ // cap
+ case cap: offset[0] = 0; offset[1] = 0; offset[2] = 0; break;
+ // clip
+ case clip_right: offset[0] = 135; offset[1] = 0; offset[2] = 0; break;
+ // left clip
+ case clip_left: offset[0] = -135; offset[1] = 0; offset[2] = 0; break;
+ }
+ }
+ return offset;
+ }
};
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 4bd92d44..f2550f6b 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -96,7 +96,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
const double region_size_min = s.min_point_size;
const double region_size_max = s.max_point_size;
- if (!s.auto_threshold)
+ if (false)
{
const int thres = s.threshold;
cv::threshold(frame_gray, frame_bin, thres, 255, cv::THRESH_BINARY);
diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp
index cae68bf3..7e95ab9a 100644
--- a/tracker-pt/point_tracker.cpp
+++ b/tracker-pt/point_tracker.cpp
@@ -48,21 +48,27 @@ PointModel::PointModel(settings_pt& s)
void PointModel::set_model(settings_pt& s)
{
- switch (s.active_model_panel)
+ using m = settings_pt::model;
+
+ switch (m(s.active_model_panel()))
{
- case Clip:
- M01 = vec3(0, static_cast<f>(s.clip_ty), -static_cast<f>(s.clip_tz));
- M02 = vec3(0, -static_cast<f>(s.clip_by), -static_cast<f>(s.clip_bz));
- break;
- case Cap:
- M01 = vec3(-static_cast<f>(s.cap_x), -static_cast<f>(s.cap_y), -static_cast<f>(s.cap_z));
- M02 = vec3(static_cast<f>(s.cap_x), -static_cast<f>(s.cap_y), -static_cast<f>(s.cap_z));
+ default:
+ case m::cap:
+ {
+ const double x = 60, y = 90, z = 95;
+ M01 = cv::Vec3d(-x, -y, z);
+ M02 = cv::Vec3d(x, -y, z);
break;
- case Custom:
- M01 = vec3(s.m01_x, s.m01_y, s.m01_z);
- M02 = vec3(s.m02_x, s.m02_y, s.m02_z);
+ }
+ case m::clip_left:
+ case m::clip_right:
+ {
+ const double a = 27, b = 43, c = 62, d = 74;
+ M01 = cv::Vec3d(0, b, -a);
+ M02 = cv::Vec3d(0, -c, -d);
break;
}
+ }
}
void PointModel::get_d_order(const vec2* points, unsigned* d_order, const vec2& d) const