summaryrefslogtreecommitdiffhomepage
path: root/tracker-easy/preview.h
blob: 785d76d4206a4b130643b452473dddb872e13e90 (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
/*
 * Copyright (c) 2019 Stephane Lenclud
 *
 * 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 "tracker-easy-api.h"

#include <opencv2/core.hpp>
#include <QImage>

namespace EasyTracker
{

    struct Preview
    {
        Preview(int w, int h);

        Preview& operator=(const cv::Mat& frame);
        QImage get_bitmap();
        void draw_head_center(numeric_types::f x, numeric_types::f y);

        operator cv::Mat&() { return iFrameResized; }
        operator cv::Mat const&() const { return iFrameResized; }

    private:
        static void ensure_size(cv::Mat& frame, int w, int h, int type);

    public:
        // Frame with an 8 bits channel size
        cv::Mat iFrameChannelSizeOne;
        // Frame with three channels for RGB
        cv::Mat iFrameRgb;
        // Frame rezised to widget dimension
        cv::Mat iFrameResized;
        // Frame ready to be packed in a QImage for use in our widget
        cv::Mat iFrameWidget;
        
    };

}