summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/tracker-wii/wii_frame.hpp
blob: 2bffa862e9e48956cc7094a766e152155cb5f100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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