You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.7 KiB
C++
79 lines
1.7 KiB
C++
#ifndef pointpair_h__
|
|
#define pointpair_h__
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2/opencv_modules.hpp>
|
|
#include <vector>
|
|
|
|
using std::vector;
|
|
using std::pair;
|
|
using namespace cv;
|
|
|
|
template<typename _Point>
|
|
class _PointPair : public pair<_Point, _Point>
|
|
{
|
|
public:
|
|
_PointPair()
|
|
: pair<_Point, _Point>(), mAver(0) {}
|
|
|
|
_PointPair(const _Point& p0, const _Point& p1)
|
|
: pair<_Point, _Point>(p0, p1), mAver(0) {}
|
|
|
|
_PointPair(const _PointPair<_Point>& pointPair)
|
|
: pair<_Point, _Point>(pointPair.first, pointPair.second)
|
|
, mAver(pointPair.aver())
|
|
, mStr(pointPair.getStr())
|
|
{}
|
|
|
|
void setAver(float val) { mAver = val; }
|
|
float aver() const { return mAver; }
|
|
|
|
std::string getStr() const { return mStr; }
|
|
void setStr(std::string iVal) { mStr = iVal; }
|
|
|
|
protected:
|
|
float mAver;
|
|
std::string mStr;
|
|
|
|
private:
|
|
};
|
|
|
|
typedef _PointPair<Point> PointPair;
|
|
typedef _PointPair<Point2f> PointfPair;
|
|
|
|
void convertPointPair2PointfPair(const vector<PointPair>& vec0,
|
|
vector<PointfPair>& vec1);
|
|
|
|
template<typename _Point>
|
|
double pointDis(const _Point& i, const _Point& j)
|
|
{
|
|
return norm(i - j);
|
|
}
|
|
|
|
template<typename _PointPair>
|
|
double pointPairXDis(const _PointPair& i, const _PointPair& j)
|
|
{
|
|
return (abs(i.first.x - j.first.x) +
|
|
abs(i.second.x - j.second.x)) / 2.0;
|
|
}
|
|
|
|
double pointPairDis(const PointPair& i, const PointPair& j);
|
|
|
|
template<typename _PointPair>
|
|
double pointPairLen(const _PointPair& p)
|
|
{
|
|
return pointDis(p.first, p.second);
|
|
}
|
|
|
|
template<typename _PointPair>
|
|
void addYToPointPairs(vector<_PointPair>& vec, int y)
|
|
{
|
|
for (auto i = vec.begin(); i != vec.end(); ++i)
|
|
{
|
|
i->first.y += y;
|
|
i->second.y += y;
|
|
}
|
|
}
|
|
|
|
#endif // pointpair_h__
|