aboutsummaryrefslogtreecommitdiff
path: root/tests/ObjectDetectionCommon.hpp
blob: ee3afb5788dd62240d974c57e76e6e8da71eee12 (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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once

#include <string>
#include <utility>

namespace
{

struct BoundingBox
{
    BoundingBox()
        : BoundingBox(0.0f, 0.0f, 0.0f, 0.0f)
    {}

    BoundingBox(float xMin, float yMin, float xMax, float yMax)
        : m_XMin(xMin)
        , m_YMin(yMin)
        , m_XMax(xMax)
        , m_YMax(yMax)
    {}

    float m_XMin;
    float m_YMin;
    float m_XMax;
    float m_YMax;
};

struct DetectedObject
{
    DetectedObject(float detectedClass,
                   const BoundingBox& boundingBox,
                   float confidence)
        : m_Class(detectedClass)
        , m_BoundingBox(boundingBox)
        , m_Confidence(confidence)
    {}

    bool operator<(const DetectedObject& other) const
    {
        return m_Confidence < other.m_Confidence ||
            (m_Confidence == other.m_Confidence && m_Class < other.m_Class);
    }

    float        m_Class;
    BoundingBox  m_BoundingBox;
    float        m_Confidence;
};

using ObjectDetectionInput = std::pair<std::string, std::vector<DetectedObject>>;

} // anonymous namespace