-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagestitcher.h
98 lines (84 loc) · 2.75 KB
/
imagestitcher.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
#ifndef IMAGESTITCHER_H
#define IMAGESTITCHER_H
#include <QMetaType>
#include <QThread>
#include <QStringList>
#include <QMutex>
#include <opencv2/opencv.hpp>
// This has to be a QObject so it can be passed through signals/slots
class StitchingUpdateData : public QObject {
Q_OBJECT
public:
StitchingUpdateData();
cv::Mat currentScene;
cv::Mat currentFeatureMatches;
cv::Mat homography;
int curIndex;
int totalImages;
bool success;
};
class StitchingMatchesUpdateData {
public:
StitchingMatchesUpdateData() {}
cv::Mat object;
cv::Mat scene;
std::vector<cv::KeyPoint> objFeatures;
std::vector<cv::KeyPoint> sceneFeatures;
std::vector<cv::DMatch> matches;
};
class ImageStitcher : public QThread
{
Q_OBJECT
public:
enum FeatureDetector
{
SURF,
ORB
};
enum FeatcherMatcher{
FLANN,
BRUTE_FORCE
};
enum AlgorithmType {
CUMULATIVE,
COMPOUND_HOMOGRAPHY,
REDUCE,
FULL_MATCHES
};
ImageStitcher(QStringList inputFiles,
double scaleFactor, double roiSize, double angleStdDevs, double lenStdDevs, double distMins,
ImageStitcher::FeatureDetector featureDetector, ImageStitcher::FeatcherMatcher featureMatcher,
bool stepModeState, AlgorithmType type, QObject *parent = 0);
void nextStep(double angle, double length, double heuristic);
void setStepMode(bool inputStepMode);
static std::vector<cv::DMatch> pruneMatches(const std::vector<cv::DMatch>& allMatches,
const std::vector<cv::KeyPoint> &keypoints_object, const std::vector<cv::KeyPoint> &keypoints_scene,
double angleThreshold, double distanceThreshold, double heuristicThreshold);
signals:
void stitchingUpdate(StitchingUpdateData* data);
void stitchingUpdateMatches(StitchingMatchesUpdateData data);
public slots:
protected:
void run();
private:
QStringList inputFiles;
const double SCALE_FACTOR;
//TODO for now keeping old values in here but eventually should just make good ones default
const double ROI_SIZE; // = 1.5;
double STD_ANGLE_DEVS_TO_KEEP; // = 1.5;
double STD_LEN_DEVS_TO_KEEP; // = 3;
double NUM_MIN_DIST_TO_KEEP; // = 3;
const ImageStitcher::FeatureDetector F_DETECTOR;
const ImageStitcher::FeatcherMatcher F_MATCHER;
QMutex lock;
bool currentlyPaused; // protected by lock
bool stepMode; // protected by lock
bool useROI;
cv::Rect roi;
AlgorithmType algorithm;
StitchingUpdateData* stitchImages(cv::Mat &objImage, cv::Mat &sceneImage);
void pauseThreadUntilReady();
};
Q_DECLARE_METATYPE(StitchingUpdateData*)
Q_DECLARE_METATYPE(StitchingMatchesUpdateData)
#endif // IMAGESTITCHER_H