summaryrefslogtreecommitdiffhomepage
path: root/tracker-easy/tracker-easy-api.h
blob: 40e472d49766e16a1d552d25b879ec2e90dc3ae2 (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
65
#pragma once

#include "pt-settings.hpp"

#include "cv/numeric.hpp"
#include "options/options.hpp"
#include "video/camera.hpp"

#include <tuple>
#include <type_traits>
#include <memory>

#include <opencv2/core.hpp>

#include <QImage>
#include <QString>

#ifdef __clang__
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wweak-vtables"
#endif

const int KPointCount = 3;

///
/// Utility class providing coordinates conversion functionalities
///
struct Coordinates final
{
    using f = numeric_types::f;

    static std::tuple<f, f> to_pixel_pos(f x, f y, int w, int h);
    static std::tuple<f, f> to_screen_pos(f px, f py, int w, int h);
};


struct pt_point_extractor
{
    using vec2 = numeric_types::vec2;
    using f = numeric_types::f;

    pt_point_extractor();
    virtual ~pt_point_extractor();
    virtual void extract_points(const cv::Mat& image, cv::Mat& preview_frame, std::vector<vec2>& points, std::vector<vec2>& imagePoints) = 0;

    static f threshold_radius_value(int w, int h, int threshold);
};

struct pt_runtime_traits
{
    template<typename t> using pointer = std::shared_ptr<t>;

    pt_runtime_traits();
    virtual ~pt_runtime_traits();

    virtual pointer<pt_point_extractor> make_point_extractor() const = 0;
    virtual QString get_module_name() const = 0;
};

template<typename t>
using pt_pointer = typename pt_runtime_traits::pointer<t>;

#ifdef __clang__
#   pragma clang diagnostic pop
#endif