diff options
author | Wei Shuai <cpuwolf@gmail.com> | 2018-01-26 22:02:07 +0800 |
---|---|---|
committer | Wei Shuai <cpuwolf@gmail.com> | 2018-01-26 22:02:07 +0800 |
commit | 4a2a1b636df7a67722b6b5764efa8cfc63c6a5e1 (patch) | |
tree | bd375c924fa72f9eb3ce1d78356785077836f3c1 /tracker-wii/wii_frame.hpp | |
parent | d057e5db1c9ca81d5f60b9cd8001f60dd155f145 (diff) |
tracker/wii: new home
Diffstat (limited to 'tracker-wii/wii_frame.hpp')
-rw-r--r-- | tracker-wii/wii_frame.hpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tracker-wii/wii_frame.hpp b/tracker-wii/wii_frame.hpp new file mode 100644 index 00000000..2bffa862 --- /dev/null +++ b/tracker-wii/wii_frame.hpp @@ -0,0 +1,64 @@ +/* +* 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" + +#include <opencv2/core.hpp> +#include <QImage> + + + +namespace pt_module { + +enum wii_camera_status : unsigned { wii_cam_wait_for_connect, wii_cam_data_no_change, wii_cam_data_change }; + +struct wii_info_points { + unsigned ux; + unsigned uy; + int isize; + bool bvis; +}; + +struct wii_info { + struct wii_info_points Points[4]; + bool bBatteryDrained; + unsigned char BatteryPercent; + float Pitch; + float Roll; + wii_camera_status status; +}; + +struct WIIFrame final : pt_frame +{ + cv::Mat mat; + struct wii_info wii; + + operator const cv::Mat&() const& { return mat; } + operator cv::Mat&() & { return mat; } +}; + +struct WIIPreview final : pt_preview +{ + WIIPreview(int w, int h); + + WIIPreview& operator=(const pt_frame& frame) override; + QImage get_bitmap() override; + void draw_head_center(double x, double y) override; + + operator cv::Mat&() { return frame_copy; } + operator cv::Mat const&() const { return frame_copy; } + +private: + static void ensure_size(cv::Mat& frame, int w, int h, int type); + + bool fresh = true; + cv::Mat frame_copy, frame_color, frame_resize, frame_out; +}; + +} // ns pt_module |