Mech-DLK SDK (C++) 3.0.0
Mech-DLK SDK (C++) Reference Documentation
 
Loading...
Searching...
No Matches
MBbox.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <string>
5#include "common/macro.h"
6
7namespace mmind {
8namespace dl {
9
10struct MPointF
11{
12 float x;
13 float y;
14
15 constexpr MPointF() : x(0.0), y(0) {}
16
17 constexpr MPointF(float x, float y) : x(x), y(y) {}
18
19 MPointF& operator+=(const MPointF& other) noexcept
20 {
21 x += other.x;
22 y += other.y;
23 return *this;
24 }
25};
26
27constexpr MPointF operator+(const MPointF& p1, const MPointF& p2)
28{
29 return {p1.x + p2.x, p1.y + p2.y};
30}
31
32struct MBbox
33{
34 MBbox() = default;
35 MBbox(float startX, float startY, float endX, float endY, float confidence, int labelIndex,
36 const std::string& labelName, bool recoverToFixedSize = false,
37 const std::vector<float>& confidenceSeq = {})
40 {
41 extraInfo.confidence = confidence;
42 extraInfo.labelIndex = labelIndex;
43 extraInfo.labelName = labelName;
44 extraInfo.confidenceSeq = confidenceSeq;
45 }
46 float width() const { return endX - startX; }
47 float height() const { return endY - startY; }
48 float area() const { return width() * height(); }
49 std::vector<float> centerPoint() const { return {(endX + startX) / 2, (endY + startY) / 2}; }
50
51 float startX{0.0};
52 float startY{0.0};
53 float endX{0.0};
54 float endY{0.0};
55
56 bool recoverToFixedSize{false};
57
58 struct ExtraInfo
59 {
60 float confidence{};
62 std::string labelName{};
63 std::vector<float> confidenceSeq{};
65};
66
74{
75 MRotatedBbox() = default;
76 MRotatedBbox(const MPointF& center, float width, float height, float angle, float confidence,
77 int labelIndex, const std::string& labelName);
78
79 MRotatedBbox(const MBbox& bbox);
80
81 std::vector<MPointF> toBboxPoints() const;
82
83 // only support bbox with no angle
84 MBbox toBbox() const;
85
86 MPointF center{0.0, 0.0};
87 float width{0.0};
88 float height{0.0};
89 float angle{0.0};
90
91 struct ExtraInfo
92 {
93 float confidence{};
95 std::string labelName{};
96 } extraInfo;
97};
98} // namespace dl
99} // namespace mmind
#define MMIND_DL_SDK_CC_API
Definition macro.h:21
constexpr MPointF operator+(const MPointF &p1, const MPointF &p2)
Definition MBbox.h:27
Definition MBbox.h:7
std::string labelName
Definition MBbox.h:62
std::vector< float > confidenceSeq
Definition MBbox.h:63
std::vector< float > centerPoint() const
Definition MBbox.h:49
float startY
Definition MBbox.h:52
float startX
Definition MBbox.h:51
float width() const
Definition MBbox.h:46
float area() const
Definition MBbox.h:48
bool recoverToFixedSize
Definition MBbox.h:56
struct mmind::dl::MBbox::ExtraInfo extraInfo
MBbox(float startX, float startY, float endX, float endY, float confidence, int labelIndex, const std::string &labelName, bool recoverToFixedSize=false, const std::vector< float > &confidenceSeq={})
Definition MBbox.h:35
float height() const
Definition MBbox.h:47
MPointF & operator+=(const MPointF &other) noexcept
Definition MBbox.h:19
constexpr MPointF()
Definition MBbox.h:15
constexpr MPointF(float x, float y)
Definition MBbox.h:17
std::vector< MPointF > toBboxPoints() const
MRotatedBbox(const MBbox &bbox)
MRotatedBbox(const MPointF &center, float width, float height, float angle, float confidence, int labelIndex, const std::string &labelName)