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.
83 lines
1.9 KiB
C++
83 lines
1.9 KiB
C++
#ifndef OneDollarRec_h__
|
|
#define OneDollarRec_h__
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
#include <vector>
|
|
#include "CVUtils.h"
|
|
|
|
using std::vector;
|
|
using namespace cv;
|
|
|
|
namespace pagic
|
|
{
|
|
struct RecResult
|
|
{
|
|
int m_templateID;
|
|
double m_dis;
|
|
int m_score;
|
|
double m_length;
|
|
double m_damageScale;
|
|
};
|
|
class OneDollarRec
|
|
{
|
|
public:
|
|
OneDollarRec(bool enableTotalResample = true);
|
|
RecResult recognize(const vector<Point2d>& tarPosVec);
|
|
vector<Point2d> getTemplatePath(int id) {
|
|
if(id >= 0 && id < m_templates.size()) {
|
|
return m_templates[id];
|
|
} else {
|
|
return vector<Point2d>();
|
|
}
|
|
|
|
}
|
|
|
|
vector<Point2d> getCurResampledPath() const { return m_curResampledPath; }
|
|
//
|
|
// static void resample(vector<Point>& tarPosVec, int n);
|
|
// static double pathLength(const vector<Point>& posVec);
|
|
|
|
protected:
|
|
int normalizeScore(double val);
|
|
|
|
|
|
void rotateAlign(vector<Point2d>& tarPosVec);
|
|
|
|
void scaleTranslateAlign(vector<Point2d>& tarPosVec, Sized tarSized);
|
|
void scaleTranslateAlign(vector<Point2d>& tarPosVec, int templateID);
|
|
|
|
double distance(const vector<Point2d>& tarPosVec, int templateID);
|
|
//double distance(const vector<Point>& tarPosVec, const vector<Point>& tempPosVec);
|
|
|
|
|
|
void normalizeTemplate(vector<Point2d>& vec);
|
|
|
|
//void xmirror(vector<Point>& vec);
|
|
//void ymirror(vector<Point>& vec);
|
|
|
|
void addNewTemplate(const vector<Point2d>& vec);
|
|
|
|
Sized getNormalizedSized();
|
|
|
|
vector< vector<Point2d> > m_templates;
|
|
vector< vector<Point2d> > m_xmTemplates;
|
|
vector< vector<Point2d> > m_ymTemplates;
|
|
vector< vector<Point2d> > m_rTemplates;
|
|
vector< vector<Point2d> > m_xmrTemplates;
|
|
vector< vector<Point2d> > m_ymrTemplates;
|
|
|
|
vector<double> m_templateLengthVec;
|
|
int m_totalResampleNum;
|
|
|
|
bool m_enableTotalResample;
|
|
|
|
vector<Point2d> m_curResampledPath;
|
|
|
|
void setCurResampledPath(vector<Point2d> val) { m_curResampledPath = val; }
|
|
private:
|
|
};
|
|
|
|
}
|
|
|
|
#endif // OneDollarRec_h__
|