-
Notifications
You must be signed in to change notification settings - Fork 0
/
recognition.h
102 lines (89 loc) · 4.35 KB
/
recognition.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef RECOGNITION_H
#define RECOGNITION_H
#include <QObject>
#include <QDebug>
#include "segmenttrack.h"
#include "placedetection.h"
#include "utilTypes.h"
#include <string>
#include <sstream>
#include "TSC/utility.h"
#include <QDate>
extern "C" {
#include "cluster.h"
}
using namespace std;
enum RecognitionStatus {RECOGNITION_ERROR, NOT_RECOGNIZED, RECOGNIZED};
enum RecognitionMethod {REC_TYPE_SSG_NORMAL, REC_TYPE_SSG_VOTING, REC_TYPE_BD_NORMAL, REC_TYPE_BD_COLOR, REC_TYPE_BD_COLOR_LOG, REC_TYPE_BD_VOTING};
/////////////////////////////////////////////
//Performs recognition on hierarchical tree//
//SSGs are used as tree elements //
/////////////////////////////////////////////
class Recognition : public QObject
{
Q_OBJECT
public:
Parameters* params;
Dataset* dataset;
GraphMatch *gm;
Segmentation *seg;
vector<string> img_files;
int plot_offset;
int rec_method;
int showPlaceAsCircle;
int showInnerSSGs;
public:
Recognition(Parameters* params,
Dataset* dataset,
GraphMatch* gm,
Segmentation* seg);
~Recognition();
int performRecognition(vector<PlaceSSG>& places, PlaceSSG new_place, TreeNode** hierarchy);
int performRecognitionHybrid(vector<PlaceSSG>& places, PlaceSSG new_place, TreeNode** hierarchy, vector<vector<vector<pair<int,int> > > >& familiarities);
int performRecognitionHybridOld(vector<PlaceSSG>& places, PlaceSSG new_place, TreeNode** hierarchy);
void calculateRecPerformance(TreeNode* root);
void calculateN2NRecPerformance(TreeNode* root);
void calculateRecPerformanceWithHValues(TreeNode* root);
void calculateN2NTreeDistanceMatrix(TreeNode* root);
void calculateSSGDistanceMatrix(TreeNode* root);
void calculateBDDistanceMatrix(TreeNode* root);
void testRecognition();
void setRecognitionMethod(int method);
void setPlaceDisplayType(int isCircle);
void setInnerSSGDisplayType(int isShowInnerSSG);
double getDistance(PlaceSSG& p1, PlaceSSG& p2);
PlaceSSG* mergeSSGs(PlaceSSG* p1, PlaceSSG* p2, int id);
double** calculateDistanceMatrix(vector<PlaceSSG>& places);
void calculateRecPerformanceDist2Match(vector<PlaceSSG>& places, TreeNode* root);
void calculateRecPerformanceHybridWithoutTree(vector<PlaceSSG>& places);
vector<vector<int> > calculateBestSSGCandidates(vector<PlaceSSG>& places);
Node* solveSLink(int nrows, int ncols, double** data);
void generateRAGs(const Node* tree, int nTree, vector<vector<NodeSig> >& rags, vector<Mat>& images);
Mat saveRAG(const vector<NodeSig> ns, string name);
void drawTree(TreeNode* root_node, int size, int height, int width);
double calculateDistanceSSGVoting(SSG& old_place, SSG& detected_place);
double calculateDistanceTSC(SSG& old_place, SSG& detected_place);
TreeNode* findNodeWithPlaceLabel(int label, TreeNode* root);
TreeNode* findNodeWithSSGLabel(int site, int label, TreeNode* root);
TreeNode** convert2Tree(Node* tree, int nrNodes, int nrPlaces, vector<PlaceSSG>& places);
void sortTerminalNodes(TreeNode* node, int* last_pos);
void drawBranch(Mat& img, TreeNode* node, int height, double scale_x, double scale_y);
void processTree(Node* tree, int size);
void drawSSG(Mat& img, SSG ssg, Point coord);
void drawSSGWithImages(Mat& img, SSG ssg, Point coord);
void drawInnerSSG(Mat& img, SSG ssg, Point coord);
int calculateN2NTreeDistance(TreeNode* node1, TreeNode* node2);
void getTerminalNodes(TreeNode* node, vector<TreeNode*>& terminal_nodes);
int getNumberMatchedSSGNodes(PlaceSSG place1, PlaceSSG place2, float threshold);
bool getMatchStatus(int psite1, int place1, int psite2, int place2);
void calculateFamiliarityPerformance(vector<vector<vector<pair<int,int> > > >& familiarities);
int performRecognitionHybridNoRec(vector<PlaceSSG>& places, PlaceSSG new_place, TreeNode** hierarchy, vector<vector<vector<pair<int, int> > > >& familiarities,
vector<pair<pair<int,int>, pair<int,int> > >& recognized_places);
void calculateRecPerformance(vector<pair<pair<int,int>, pair<int,int> > >& recognized_places);
void calculateRecPerformanceCombined(vector<pair<pair<int,int>, pair<int,int> > >& recognized_places);
signals:
void showTree(QImage img);
void printMessage(QString str);
public slots:
};
#endif // RECOGNITION_H