#ifndef pointpair_h__ #define pointpair_h__ #include #include #include using std::vector; using std::pair; using namespace cv; template 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 PointPair; typedef _PointPair PointfPair; void convertPointPair2PointfPair(const vector& vec0, vector& vec1); template double pointDis(const _Point& i, const _Point& j) { return norm(i - j); } template 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 double pointPairLen(const _PointPair& p) { return pointDis(p.first, p.second); } template 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__