-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDimensionCalculator.h
36 lines (33 loc) · 1.07 KB
/
DimensionCalculator.h
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
#pragma once
#include "BBox.h"
namespace dimension
{
class DimensionCalculator
{
public:
DimensionCalculator() = default;
DimensionCalculator(
int imageWidth,
int imageHeight,
const dimension::BBox& bbox )
{
float xBoxCentre = ( ( bbox.m_Xmax + bbox.m_Xmin ) / 2 );
float yBoxCentre = ( ( bbox.m_Ymax + bbox.m_Ymin ) / 2 );
float boxWidth = ( bbox.m_Xmax - bbox.m_Xmin );
float boxHeight = ( bbox.m_Ymax - bbox.m_Ymin );
m_XCenter = xBoxCentre / imageWidth;
m_YCenter = yBoxCentre / imageHeight;
m_Width = boxWidth / imageWidth;
m_Height = boxHeight / imageHeight;
}
float GetXCentre() const { return m_XCenter; }
float GetYCentre() const { return m_YCenter; }
float GetWidth() const { return m_Width; }
float GetHeight() const { return m_Height; }
private:
float m_XCenter = 0;
float m_YCenter = 0;
float m_Width = 0;
float m_Height = 0;
};
}