summaryrefslogtreecommitdiffhomepage
path: root/tracker-wii/wii_point_extractor.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-06-17 11:58:04 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-06-17 12:19:25 +0200
commit2aee2a94ea53620e3da7f976875ca4101eec780d (patch)
treef2ff98bbf54040c9dcf48a7edb77248755d27f50 /tracker-wii/wii_point_extractor.cpp
parent3f273418b564f8ca93ec687fa8ab7809099e6c67 (diff)
tracker/wii: clean up a little
Diffstat (limited to 'tracker-wii/wii_point_extractor.cpp')
-rw-r--r--tracker-wii/wii_point_extractor.cpp77
1 files changed, 38 insertions, 39 deletions
diff --git a/tracker-wii/wii_point_extractor.cpp b/tracker-wii/wii_point_extractor.cpp
index 6f86da1d..4f1f92b9 100644
--- a/tracker-wii/wii_point_extractor.cpp
+++ b/tracker-wii/wii_point_extractor.cpp
@@ -27,7 +27,6 @@ using namespace pt_module;
WIIPointExtractor::WIIPointExtractor(const QString& module_name) : s(module_name)
{
-
}
//define a temp draw function
@@ -35,8 +34,8 @@ void WIIPointExtractor::draw_point(cv::Mat& preview_frame, const vec2& p, const
{
static constexpr int len = 9;
- cv::Point p2(iround(p[0] * preview_frame.cols + preview_frame.cols / 2.f),
- iround(-p[1] * preview_frame.cols + preview_frame.rows / 2.f));
+ cv::Point p2(iround(p[0] * preview_frame.cols + preview_frame.cols / 2.f),
+ iround(-p[1] * preview_frame.cols + preview_frame.rows / 2.f));
cv::line(preview_frame,
cv::Point(p2.x - len, p2.y),
@@ -48,7 +47,7 @@ void WIIPointExtractor::draw_point(cv::Mat& preview_frame, const vec2& p, const
cv::Point(p2.x, p2.y + len),
color,
thickness);
-};
+}
void WIIPointExtractor::draw_points(cv::Mat& preview_frame, const struct wii_info& wii)
{
@@ -75,11 +74,11 @@ void WIIPointExtractor::draw_points(cv::Mat& preview_frame, const struct wii_inf
void WIIPointExtractor::draw_bg(cv::Mat& preview_frame, const struct wii_info& wii)
{
//draw battery status
- cv::line(preview_frame,
- cv::Point(0, 0),
- cv::Point(preview_frame.cols*wii.BatteryPercent / 100, 0),
- (wii.bBatteryDrained ? cv::Scalar(255, 0, 0) : cv::Scalar(0, 140, 0)),
- 2);
+ cv::line(preview_frame,
+ cv::Point(0, 0),
+ cv::Point(preview_frame.cols*wii.BatteryPercent / 100, 0),
+ (wii.bBatteryDrained ? cv::Scalar(255, 0, 0) : cv::Scalar(0, 140, 0)),
+ 2);
//draw horizon
int pdelta = iround(preview_frame.rows / 4.f * tan(wii.Pitch * pi / 180.f));
@@ -100,38 +99,38 @@ void WIIPointExtractor::extract_points(const pt_frame& frame_,
const struct wii_info& wii = frame_.as_const<WIIFrame>()->wii;
cv::Mat& preview_frame = *preview_frame_.as<WIIPreview>();
- map_points(wii, points);
- if (preview_visible && wii.status == wii_cam_data_change)
- {
- draw_bg(preview_frame, wii);
- draw_points(preview_frame, wii);
- }
+ map_points(wii, points);
+ if (preview_visible && wii.status == wii_cam_data_change)
+ {
+ draw_bg(preview_frame, wii);
+ draw_points(preview_frame, wii);
+ }
}
bool WIIPointExtractor::map_points(const struct wii_info& wii, std::vector<vec2>& points)
{
- constexpr int W = 1024;
- constexpr int H = 768;
- points.reserve(4);
- points.clear();
-
- for (unsigned index = 0; index < 4; index++) // NOLINT(modernize-loop-convert)
- {
- const struct wii_info_points &dot = wii.Points[index];
- if (dot.bvis) {
- //qDebug() << "wii:" << dot.RawX << "+" << dot.RawY;
- //anti-clockwise rotate the 2D point
- const float RX = W - dot.ux;
- const float RY = H - dot.uy;
- //vec2 dt((dot.RawX - W / 2.0f) / W, -(dot.RawY - H / 2.0f) / W);
- //vec2 dt((RX - W / 2.0f) / W, -(RY - H / 2.0f) / W);
- //vec2 dt((2.0f*RX - W) / W, -(2.0f*RY - H ) / W);
- vec2 dt;
- std::tie(dt[0], dt[1]) = to_screen_pos(RX, RY, W, H);
-
- points.push_back(dt);
- }
- }
-
- return points.size() >= PointModel::N_POINTS;
+ constexpr int W = 1024;
+ constexpr int H = 768;
+ points.reserve(4);
+ points.clear();
+
+ for (unsigned index = 0; index < 4; index++) // NOLINT(modernize-loop-convert)
+ {
+ const struct wii_info_points &dot = wii.Points[index];
+ if (dot.bvis) {
+ //qDebug() << "wii:" << dot.RawX << "+" << dot.RawY;
+ //anti-clockwise rotate the 2D point
+ const float RX = W - dot.ux;
+ const float RY = H - dot.uy;
+ //vec2 dt((dot.RawX - W / 2.0f) / W, -(dot.RawY - H / 2.0f) / W);
+ //vec2 dt((RX - W / 2.0f) / W, -(RY - H / 2.0f) / W);
+ //vec2 dt((2.0f*RX - W) / W, -(2.0f*RY - H ) / W);
+ vec2 dt;
+ std::tie(dt[0], dt[1]) = to_screen_pos(RX, RY, W, H);
+
+ points.push_back(dt);
+ }
+ }
+
+ return points.size() >= PointModel::N_POINTS;
}