Added some getter and setter functions in rectangle.h file. Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
79 lines
2.7 KiB
C++
79 lines
2.7 KiB
C++
#ifndef RECTANGLE_H
|
|
#define RECTANGLE_H
|
|
|
|
#include <opencv2/core.hpp>
|
|
#include <vector>
|
|
|
|
// MAYBE MAKE TWOPTOBJECT A PARENT CLASS FOR BOTH LINE AND RECTANGLE?
|
|
|
|
class Rectangle {
|
|
private:
|
|
// properties of the rectangle
|
|
double pt1x;
|
|
double pt1y;
|
|
double pt2x;
|
|
double pt2y;
|
|
|
|
|
|
public:
|
|
// constructor/destructor functions
|
|
Rectangle(); //don't know if this should be here
|
|
|
|
Rectangle(cv::Rect rect);
|
|
Rectangle(cv::Point pt1, cv::Point pt2);
|
|
|
|
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr> // meant for an int/double/float or some other numeric return type
|
|
Rectangle(T pt1x, T pt1y, T pt2x, T pt2y);
|
|
|
|
~Rectangle();
|
|
|
|
private:
|
|
// private helper functions
|
|
|
|
|
|
public:
|
|
void overwriteTopLeft(cv::Point pt);
|
|
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr> // meant for an int/double/float or some other numeric return type
|
|
void overwriteTopLeft(T ptx, T pty);
|
|
|
|
void overwriteBottomRight(cv::Point pt);
|
|
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr> // meant for an int/double/float or some other numeric return type
|
|
void overwriteBottomRight(T ptx, T pty);
|
|
|
|
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr> // meant for an int/double/float or some other numeric return type
|
|
cv::Point_<T> topLeft();
|
|
|
|
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr> // meant for an int/double/float or some other numeric return type
|
|
cv::Point_<T> bottomRight();
|
|
|
|
template <typename T, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr>
|
|
T area(); // meant for an int/double/float or some other numeric return type
|
|
|
|
bool containsRect(Rectangle rect); // if this rectangle contains the other rectangle
|
|
|
|
// Might need to implement size or width/height retrievers
|
|
|
|
// INTERESTING NOTE, OPENCV ASSUMES THAT THE BOTTOM RIGHT BOUNDARY IS NOT INCLUSIVE
|
|
|
|
|
|
|
|
// DON'T KNOW WHAT rectscontaining(rect, outerrects) DOES OR HOW IT'S USED
|
|
// FOLLOW UP, IT'S PART OF A BRUTE FORCE IMPLEMENTATION FOR OVERLAPPING RECTANGLES
|
|
// MAYBE IMPLEMENT IT AS A PRIVATE HELPER FUNCTION OR JUST NOT AT ALL AND HAVE IT BE SEPERATE. IT USES containsRect AS IT'S MAIN PART
|
|
|
|
// NOT SURE WHAT TO DO ABOUT rotateRect(img, rect, angle, returnint=True, asRect=False) AS WELL
|
|
|
|
|
|
// general rectangle functions
|
|
static std::vector<Rectangle> biggestNRects(std::vector<Rectangle> rects, int n);
|
|
static Rectangle overlapRect(std::vector<Rectangle> rects);
|
|
static Rectangle mergeRects(std::vector<Rectangle> rects);
|
|
|
|
|
|
};
|
|
|
|
#endif //RECTANGLE_H
|
|
|
|
|
|
|
|
// MAYBE IMPLEMENT STUFF FOR LINES AS WELL?
|