summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tracker-pt/tracker-wii/wii_camera.cpp24
-rw-r--r--tracker-pt/tracker-wii/wii_camera.h15
-rw-r--r--tracker-pt/tracker-wii/wii_frame.cpp5
-rw-r--r--tracker-pt/tracker-wii/wii_frame.hpp7
-rw-r--r--tracker-pt/tracker-wii/wii_module.cpp7
-rw-r--r--tracker-pt/tracker-wii/wii_point_extractor.cpp29
-rw-r--r--tracker-pt/tracker-wii/wii_point_extractor.h16
7 files changed, 61 insertions, 42 deletions
diff --git a/tracker-pt/tracker-wii/wii_camera.cpp b/tracker-pt/tracker-wii/wii_camera.cpp
index 21ff998d..514c71ae 100644
--- a/tracker-pt/tracker-wii/wii_camera.cpp
+++ b/tracker-pt/tracker-wii/wii_camera.cpp
@@ -1,11 +1,10 @@
-/* Copyright (c) 2012 Patrick Ruoff
- * Copyright (c) 2015-2016 Stanislaw Halik <sthalik@misaki.pl>
- * Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
+/*
+* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*/
#include "wii_camera.h"
@@ -77,8 +76,8 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_)
pt_camera_open_status WIICamera::start(int idx, int fps, int res_x, int res_y)
{
- m_pDev = new wiimote;
- if (m_pDev == NULL)
+ m_pDev = std::make_unique<wiimote>();
+ if (!m_pDev)
{
stop();
return cam_open_error;
@@ -97,7 +96,7 @@ void WIICamera::stop()
m_pDev->Disconnect();
Beep(1000, 200);
if (m_pDev) {
- delete m_pDev;
+ m_pDev=nullptr;
m_pDev = NULL;
}
@@ -140,6 +139,7 @@ bool WIICamera::_get_points(struct wii_info& wii)
{
bool dot_sizes = (m_pDev->IR.Mode == wiimote_state::ir::EXTENDED);
bool ret = false;
+ int point_count = 0;
for (unsigned index = 0; index < 4; index++)
{
@@ -153,6 +153,7 @@ bool WIICamera::_get_points(struct wii_info& wii)
wii.Points[index].isize = 1;
}
wii.Points[index].bvis = dot.bVisible;
+ point_count++;
ret = true;
} else {
wii.Points[index].ux = 0;
@@ -161,6 +162,7 @@ bool WIICamera::_get_points(struct wii_info& wii)
wii.Points[index].bvis = dot.bVisible;
}
}
+ m_pDev->SetLEDs(3 - point_count);
return ret;
}
diff --git a/tracker-pt/tracker-wii/wii_camera.h b/tracker-pt/tracker-wii/wii_camera.h
index a7ac9c14..6518de91 100644
--- a/tracker-pt/tracker-wii/wii_camera.h
+++ b/tracker-pt/tracker-wii/wii_camera.h
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012 Patrick Ruoff
- * Copyright (c) 2015-2016 Stanislaw Halik <sthalik@misaki.pl>
+/*
* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -26,7 +25,13 @@
#include "wii_frame.hpp"
namespace pt_module {
-
+#if 0
+struct WIICameraInfo final : pt_camera_info
+{
+ WIICameraInfo() {}
+ double get_focal_length() const { return 42.; }
+};
+#endif
struct WIICamera final : pt_camera
{
WIICamera(const QString& module_name);
@@ -41,14 +46,14 @@ struct WIICamera final : pt_camera
QString get_desired_name() const override;
QString get_active_name() const override;
- operator bool() const override { return (m_pDev); }
+ operator bool() const override { return m_pDev && (!m_pDev->ConnectionLost()); }
void set_fov(double value) override { fov = value; }
void show_camera_settings() override;
private:
- wiimote * m_pDev;
+ std::unique_ptr<wiimote> m_pDev;
static void on_state_change(wiimote &remote,
state_change_flags changed,
const wiimote_state &new_state);
diff --git a/tracker-pt/tracker-wii/wii_frame.cpp b/tracker-pt/tracker-wii/wii_frame.cpp
index 25228d57..9e367926 100644
--- a/tracker-pt/tracker-wii/wii_frame.cpp
+++ b/tracker-pt/tracker-wii/wii_frame.cpp
@@ -1,6 +1,9 @@
/*
-* Copyright (c) 2015-2016 Stanislaw Halik <sthalik@misaki.pl>
* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
*/
#include "wii_frame.hpp"
diff --git a/tracker-pt/tracker-wii/wii_frame.hpp b/tracker-pt/tracker-wii/wii_frame.hpp
index 4e3f0c95..2bffa862 100644
--- a/tracker-pt/tracker-wii/wii_frame.hpp
+++ b/tracker-pt/tracker-wii/wii_frame.hpp
@@ -1,6 +1,9 @@
-/*
-* Copyright (c) 2015-2016 Stanislaw Halik <sthalik@misaki.pl>
+/*
* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
*/
#pragma once
diff --git a/tracker-pt/tracker-wii/wii_module.cpp b/tracker-pt/tracker-wii/wii_module.cpp
index 2f04ec9a..aa8a5c99 100644
--- a/tracker-pt/tracker-wii/wii_module.cpp
+++ b/tracker-pt/tracker-wii/wii_module.cpp
@@ -1,3 +1,10 @@
+/*
+* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*/
#include "ftnoir_tracker_pt.h"
#include "api/plugin-api.hpp"
diff --git a/tracker-pt/tracker-wii/wii_point_extractor.cpp b/tracker-pt/tracker-wii/wii_point_extractor.cpp
index 7f90fb18..f1fc013d 100644
--- a/tracker-pt/tracker-wii/wii_point_extractor.cpp
+++ b/tracker-pt/tracker-wii/wii_point_extractor.cpp
@@ -1,11 +1,10 @@
-/* Copyright (c) 2012 Patrick Ruoff
- * Copyright (c) 2015-2017 Stanislaw Halik <sthalik@misaki.pl>
- * Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
+/*
+* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*/
#include "wii_point_extractor.h"
@@ -62,6 +61,8 @@ void WIIPointExtractor::_draw_point(cv::Mat& preview_frame, const vec2& p, const
bool WIIPointExtractor::_draw_points(cv::Mat& preview_frame, const struct wii_info &wii, std::vector<vec2>& points)
{
+ const float W = 1024.0f;
+ const float H = 768.0f;
points.reserve(4);
points.clear();
@@ -70,14 +71,14 @@ bool WIIPointExtractor::_draw_points(cv::Mat& preview_frame, const struct wii_in
const struct wii_info_points &dot = wii.Points[index];
if (dot.bvis) {
//qDebug() << "wii:" << dot.RawX << "+" << dot.RawY;
-
- const float W = 1024.0f;
- const float H = 768.0f;
+ //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);
- //anti-clockwise rotate 2D point
- vec2 dt((RX - W / 2.0f) / W, -(RY - 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);
_draw_point(preview_frame, dt, cv::Scalar(0, 255, 0), dot.isize);
@@ -98,7 +99,7 @@ void WIIPointExtractor::_draw_bg(cv::Mat& preview_frame, const struct wii_info &
2);
//draw horizon
- int pdelta = iround((preview_frame.rows / 2) * tan((wii.Pitch)* M_PI / 180.0f));
+ int pdelta = iround((preview_frame.rows / 4) * tan((wii.Pitch)* M_PI / 180.0f));
int rdelta = iround((preview_frame.cols / 4) * tan((wii.Roll)* M_PI / 180.0f));
cv::line(preview_frame,
diff --git a/tracker-pt/tracker-wii/wii_point_extractor.h b/tracker-pt/tracker-wii/wii_point_extractor.h
index 290d1018..be0e5f45 100644
--- a/tracker-pt/tracker-wii/wii_point_extractor.h
+++ b/tracker-pt/tracker-wii/wii_point_extractor.h
@@ -1,12 +1,10 @@
-/* Copyright (c) 2012 Patrick Ruoff
- * Copyright (c) 2015-2016 Stanislaw Halik <sthalik@misaki.pl>
- * Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-
+/*
+* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*/
#pragma once
#include "pt-api.hpp"