added Pad class
This commit is contained in:
parent
cc4ca84fb3
commit
7550fa1c78
2 changed files with 40 additions and 0 deletions
13
pad.cpp
Normal file
13
pad.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "pad.h"
|
||||
|
||||
Pad::Pad(const Point &p) :
|
||||
RotatedRect(p, Size(), 0)
|
||||
{
|
||||
points(vertexes);
|
||||
}
|
||||
|
||||
Pad::Pad(const RotatedRect &p) :
|
||||
RotatedRect(p)
|
||||
{
|
||||
points(vertexes);
|
||||
}
|
27
pad.h
Normal file
27
pad.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef PAD_H
|
||||
#define PAD_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
class Pad : public RotatedRect
|
||||
{
|
||||
public:
|
||||
Pad(const Point &p);
|
||||
Pad(const RotatedRect &p);
|
||||
|
||||
double getArea() const { return size.area(); }
|
||||
double getRatio() const { return qMax(size.width, size.height) / qMin(size.width, size.height); }
|
||||
Point2f getCenter() const { return center; }
|
||||
Point2f const * getVertexes() const { return vertexes; }
|
||||
|
||||
operator Point2f() const { return center; }
|
||||
|
||||
protected:
|
||||
Point2f vertexes[4];
|
||||
};
|
||||
|
||||
#endif // PAD_H
|
Loading…
Add table
Reference in a new issue