-
Notifications
You must be signed in to change notification settings - Fork 1
/
jumpjump.h
102 lines (88 loc) · 3.23 KB
/
jumpjump.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 JUMPJUMP_H
#define JUMPJUMP_H
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <fstream>
#include <string>
#define CORRECTIONS_COUNT 100
class JumpJump
{
public:
JumpJump();
~JumpJump();
cv::Mat edgeImage;
cv::Mat outputImage;
cv::Point manLocationPoint();
cv::Mat returnInputImage() const;
void setInputImage(cv::Mat &inputMat);
void setTemplateImage(cv::Mat &templateImg);
void setPressScreenTimeParameter(double t);
void setEnableOutputLog(bool flag);
void updateEdgeImage();
void update();
bool isLoadInputImage();
int manLocationX() const;
int manLocationY() const;
int blockLocationX() const;
int blockLocationY() const;
double jumpDistance() const;
int getPressScreenTime() const;
double getPressScreenTimeParameter() const;
bool loadInifile(std::string path);
void fixCorrectionsBuffer(double delta, int index);
void setCorrectionsBuffer(double data, int index);
void setLeftClickedPos(int x,int y);
double* getCurrentJumpLog();
void saveCorrectionInFile(std::string path);
private:
void mainTask();
void getBinaryImage(const cv::Mat &src, cv::Mat &dst);
void getTemplatePos(cv::Mat &src, const cv::Mat &target, cv::Point &targetLocation, cv::Point &oriTargetLocation);
void drawAllPoints();
void removeManEdge(cv::Mat &edgeImg, const cv::Mat &manImg, const cv::Point &manPos);
void getBlockCornersPos(const cv::Mat &edgeImage, cv::Point &topCorner, cv::Point &leftCorner, cv::Point &rightCorner);
void getBlockCenterPos(const cv::Point &topCorner, const cv::Point &leftConer, const cv::Point &rightCorner, cv::Point ¢erPoint);
double getFixedPressScreenTimeParameterCorrection(double distance);
bool readCorrectionsFromIniFile(std::ifstream &reader);
void updateCurrentJumpLog(double (&log)[6], int index, double distance, double correction);
template<typename A>
void copyArray(const A (&src), A (&dst), int from, int to);
double distance = -1.0;
double pressScreenTimeParameter = 1.447;
double fixedPressScreenTimeParameter = -1.0;
cv::Point cvPointTemp;
double lineSlope = 0;
int pressScreenTime = 0;
int inputImageWidth;
int inputImageHeight;
cv::Mat inputImage;
cv::Mat roiImage;
cv::Mat templateImage;
cv::Mat copyOfDrawPointArea;
int lastAreaX1, lastAreaX2, lastAreaY1, lastAreaY2;
cv::Point manPosInRoiEdgeImage;
cv::Point manPos;
cv::Point blockLeftCornerPos;
cv::Point blockTopCornerPos;
cv::Point blockRightCornerPos;
cv::Point blockCenterPos;
bool isLoadImage = false;
bool isLoadTemplateImage = false;
bool isDrawPointAreaCopied = false;
bool isOutputLog = false;
int leftClickedPosX = -1;
int leftClickedPosY = -1;
std::ofstream outputTxtFile;
bool isOutputTxtFileOpened = false;
int jumpCount = 1;
std::ifstream iniLoader;
int distanceStep;
int correctionIndex = -1;
double correction = -1;
double corrections[CORRECTIONS_COUNT] = {0.0};
double correctionsBuffer[CORRECTIONS_COUNT] = {0.0};
bool isCorrectionsBufferLoaded = false;
double currentJumpLog[6] = {-1,-1,-1,-1,-1,-1};
};
#endif // JUMPJUMP_H