Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
ROI.h
Go to the documentation of this file.
1 #ifndef ROI_H
2 #define ROI_H
3 
4 #include <string>
5 #include "Utility/Types.h"
6 
7 namespace SocCamera
8 {
9 
10 class ROI
11 {
12 public:
20  ROI(int32_t anStartRow,
21  int32_t anStartColumn,
22  int32_t anWidth,
23  int32_t anHeight);
24 
28  ROI();
29 
30  int32_t x() const { return mnStartColumn; }
31  int32_t y() const { return mnStartRow; }
32  int32_t width() const { return mnWidth; }
33  int32_t height() const { return mnHeight; }
34 
35  int32 mnStartRow; // Related to the y-axis (vertical)
36  int32 mnStartColumn; // Related to the x-axis (horizontal)
37  int32 mnWidth; // Related to the x-axis (horizontal)
38  int32 mnHeight; // Related to the y-axis (vertical)
39 
44  int32_t getEndRow() const { return mnStartRow + mnHeight - 1; }
45 
50  int32_t getEndColumn() const { return mnStartColumn + mnWidth - 1; }
51 
56  std::string toString() const;
57 
58  // Validation functions
59 
64  bool validateNonZero() const { return mnStartRow >= 0 && mnStartColumn >= 0 && mnWidth > 0 && mnHeight > 0; }
65 
72  bool validateBounds(int32_t anMaxWidth, int32_t anMaxHeight) const {
73  // Total size of frame within bounds
74  return (mnHeight + mnStartRow) <= anMaxHeight &&
75  (mnWidth + mnStartColumn) <= anMaxWidth;
76  }
77 
84  bool validateWidthIsMultiple(int32_t anStartColumnMultiple, int32_t anWidthMultiple) const {
85  return (mnStartColumn % anStartColumnMultiple) == 0 &&
86  (mnWidth % anWidthMultiple) == 0;
87  }
88 
94  bool validateWidthIsMultiple(int32_t anMultiple) const { return validateWidthIsMultiple(anMultiple, anMultiple); }
95 
102  bool validateHeightIsMultiple(int32_t anStartRowMultiple, int32_t anHeightMultiple) const {
103  return (mnStartRow % anStartRowMultiple) == 0 &&
104  (mnHeight % anHeightMultiple) == 0;
105  }
106 
112  bool validateHeightIsMultiple(int32_t anMultiple) const { return validateHeightIsMultiple(anMultiple, anMultiple); }
113 
119  bool validateWidthIsCentered(int32_t anMaxWidth) const { return (mnWidth + (2 * mnStartColumn)) == anMaxWidth; }
120 
126  bool validateHeightIsCentered(int32_t anMaxHeight) const { return (mnHeight + (2 * mnStartRow)) == anMaxHeight; }
127 };
128 
129 }
130 
131 #endif // ROI_H
SocCamera::ROI::getEndRow
int32_t getEndRow() const
getEndRow Get the end row coordinate. Related to the y-axis (vertical)
Definition: ROI.h:44
SocCamera::ROI::validateHeightIsCentered
bool validateHeightIsCentered(int32_t anMaxHeight) const
validateHeightIsCentered Validate if ROI is vertically centered
Definition: ROI.h:126
int32
int32_t int32
Definition: Types.h:8
SocCamera::ROI::ROI
ROI()
ROI Make an invalid ROI.
Definition: ROI.cpp:18
Types.h
SocCamera::ROI::validateNonZero
bool validateNonZero() const
validateNonZero Validate that all the parameters are positive and width/height are non-zero
Definition: ROI.h:64
SocCamera::ROI::getEndColumn
int32_t getEndColumn() const
getEndColumn Get the end column coordinate. Related to the x-axis (horizontal)
Definition: ROI.h:50
SocCamera::ROI::validateHeightIsMultiple
bool validateHeightIsMultiple(int32_t anMultiple) const
validateHeightIsMultiple Validate if height and start row is a multiple of anMultiple
Definition: ROI.h:112
SocCamera::ROI::validateWidthIsCentered
bool validateWidthIsCentered(int32_t anMaxWidth) const
validateWidthIsCentered Validate if ROI is horizontally centered
Definition: ROI.h:119
SocCamera::ROI::mnStartColumn
int32 mnStartColumn
Definition: ROI.h:36
SocCamera::ROI::validateBounds
bool validateBounds(int32_t anMaxWidth, int32_t anMaxHeight) const
validateBounds Validate that selected ROI is within sensor width/height
Definition: ROI.h:72
SocCamera::ROI::height
int32_t height() const
Definition: ROI.h:33
SocCamera::ROI::toString
std::string toString() const
toString Create printable string to describe this ROI for debug
Definition: ROI.cpp:26
SocCamera::ROI::validateWidthIsMultiple
bool validateWidthIsMultiple(int32_t anStartColumnMultiple, int32_t anWidthMultiple) const
validateWidthIsMultiple Validate if width and start column is a multiple of provided parameters
Definition: ROI.h:84
SocCamera
Definition: CameraTypes.h:7
SocCamera::ROI::width
int32_t width() const
Definition: ROI.h:32
SocCamera::ROI::y
int32_t y() const
Definition: ROI.h:31
SocCamera::ROI::validateWidthIsMultiple
bool validateWidthIsMultiple(int32_t anMultiple) const
validateWidthIsMultiple Validate if width and start column is a multiple of anMultiple
Definition: ROI.h:94
SocCamera::ROI
Definition: ROI.h:10
SocCamera::ROI::mnHeight
int32 mnHeight
Definition: ROI.h:38
SocCamera::ROI::mnWidth
int32 mnWidth
Definition: ROI.h:37
SocCamera::ROI::mnStartRow
int32 mnStartRow
Definition: ROI.h:35
SocCamera::ROI::validateHeightIsMultiple
bool validateHeightIsMultiple(int32_t anStartRowMultiple, int32_t anHeightMultiple) const
validateHeightIsMultiple Validate if height and start row is a multiple of provided parameters
Definition: ROI.h:102
SocCamera::ROI::x
int32_t x() const
Definition: ROI.h:30