Skip to content

Commit

Permalink
fix var hides class member, constructors with this->
Browse files Browse the repository at this point in the history
  • Loading branch information
diablodale committed Mar 16, 2023
1 parent 5988f96 commit c0b9735
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
5 changes: 1 addition & 4 deletions include/depthai-shared/common/Point2f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ namespace dai {
*/
struct Point2f {
Point2f() = default;
Point2f(float x, float y) {
this->x = x;
this->y = y;
}
Point2f(float x, float y) : x(x), y(y) {}
float x = 0, y = 0;
};

Expand Down
6 changes: 1 addition & 5 deletions include/depthai-shared/common/Point3f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ namespace dai {
*/
struct Point3f {
Point3f() = default;
Point3f(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
}
Point3f(float x, float y, float z) : x(x), y(y), z(z) {}
float x = 0, y = 0, z = 0;
};

Expand Down
36 changes: 15 additions & 21 deletions include/depthai-shared/common/Rect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ namespace dai {
struct Rect {
// default constructor
Rect() = default;
Rect(float x, float y, float width, float height) {
this->x = x;
this->y = y;
this->width = width;
this->height = height;
}

Rect(float x, float y, float width, float height) : x(x), y(y), width(width), height(height) {}
Rect(const Rect& r) : x(r.x), y(r.y), width(r.width), height(r.height) {}
Rect(const Point2f& org, const Size2f& sz) : x(org.x), y(org.y), width(sz.width), height(sz.height) {}
Rect(const Point2f& pt1, const Point2f& pt2) {
Expand Down Expand Up @@ -94,33 +88,33 @@ struct Rect {

/**
* Denormalize rectangle.
* @param width Destination frame width.
* @param height Destination frame height.
* @param dest_width Destination frame width.
* @param dest_height Destination frame height.
*/
Rect denormalize(int newWidth, int newHeight) {
Rect denormalize(int dest_width, int dest_height) {
if(isNormalized()) {
float _x = std::round(this->x * newWidth);
float _y = std::round(this->y * newHeight);
float _width = std::round(this->width * newWidth);
float _height = std::round(this->height * newHeight);
float _x = std::round(x * dest_width);
float _y = std::round(y * dest_height);
float _width = std::round(width * dest_width);
float _height = std::round(height * dest_height);
return Rect(_x, _y, _width, _height);
}
return *this;
}

/**
* Normalize rectangle.
* @param width Source frame width.
* @param height Source frame height.
* @param src_width Source frame width.
* @param src_height Source frame height.
*/
Rect normalize(int newWidth, int newHeight) {
Rect normalize(int src_width, int src_height) {
if(isNormalized()) {
return *this;
}
float _x = this->x / newWidth;
float _y = this->y / newHeight;
float _width = this->width / newWidth;
float _height = this->height / newHeight;
float _x = x / src_width;
float _y = y / src_height;
float _width = width / src_width;
float _height = height / src_height;
return Rect(_x, _y, _width, _height);
}

Expand Down
5 changes: 1 addition & 4 deletions include/depthai-shared/common/Size2f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ namespace dai {
*/
struct Size2f {
Size2f() = default;
Size2f(float width, float height) {
this->width = width;
this->height = height;
}
Size2f(float width, float height) : width(width), height(height) {}
float width = 0, height = 0;
};

Expand Down

0 comments on commit c0b9735

Please sign in to comment.