Skip to content

Commit 3ec4bf8

Browse files
author
WenxiaoCai
committed
upload codes and readme
1 parent fa766f3 commit 3ec4bf8

File tree

148 files changed

+26380
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+26380
-1
lines changed

Configure.h

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
2+
//#define DP_NO_LOG
3+
#define ASSESSMENT
4+
5+
6+
#ifndef __UglyMan_Stitiching__Configure__
7+
#define __UglyMan_Stitiching__Configure__
8+
9+
#include "./Debugger/ErrorController.h"
10+
#include "./Debugger/TimeCalculator.h"
11+
12+
#include <iostream>
13+
#include <fstream>
14+
#include <vector>
15+
#include <string>
16+
#include <set>
17+
#include "dirent.h" // NOTE: you may have to add dirent.h in project files and change <dirent.h> to "dirent.h". search for this .h file on internet
18+
#include <algorithm>
19+
#include <direct.h>
20+
using namespace std;
21+
22+
23+
#define _USE_MATH_DEFINES
24+
#include <cmath>
25+
26+
#include "opencv2/core/core.hpp"
27+
#include "opencv2/highgui/highgui.hpp"
28+
#include "opencv2/imgproc/imgproc.hpp"
29+
using namespace cv;
30+
#include "opencv2/ximgproc.hpp"
31+
32+
33+
#include <Eigen/SVD>
34+
#include <Eigen/IterativeLinearSolvers>
35+
#include <Eigen/Sparse>
36+
#include <unsupported/Eigen/SparseExtra>
37+
#include "opencv2/dnn.hpp"
38+
#include <opencv2/dnn/layer.details.hpp>
39+
using namespace Eigen;
40+
41+
#include "vl/sift.h"
42+
using namespace cv::dnn;
43+
44+
45+
/******************************/
46+
/******* you may adjust *******/
47+
/******************************/
48+
49+
const int RUN_TYPE = 2; //0:GSP 1:GES-GSP 2: Our GES-GSP + SAM
50+
const string TXT_NAME = "-STITCH-GRAPH.txt";
51+
52+
53+
/*** data setting ***/
54+
const int GRID_SIZE = 40;
55+
const int DOWN_SAMPLE_IMAGE_SIZE = 800 * 600;
56+
//Contour length/image shortest edge ratio
57+
const double CONTENT_LENGTH_THRESHOLD = 0.15;
58+
59+
//HED threshold
60+
const double HED_THRESHOLD = 0.5;
61+
const int threshold_value = 120;
62+
63+
/*** APAP ***/
64+
const double APAP_GAMMA = 0.0015;
65+
const double APAP_SIGMA = 8.5;
66+
67+
/*** matching method ***/
68+
const string FEATURE_RATIO_TEST_THRESHOLD_STRING = "15e-1";//15*10^-1=1.5
69+
const double FEATURE_RATIO_TEST_THRESHOLD = atof(FEATURE_RATIO_TEST_THRESHOLD_STRING.c_str());
70+
71+
/*** homography based ***/
72+
const double GLOBAL_HOMOGRAPHY_MAX_INLIERS_DIST = 5.;
73+
const double LOCAL_HOMOGRAPHY_MAX_INLIERS_DIST = 3.;
74+
const int LOCAL_HOMOGRAPHY_MIN_FEATURES_COUNT = 40;
75+
76+
/*** vlfeat sift ***/
77+
const int SIFT_LEVEL_COUNT = 3;
78+
const int SIFT_MINIMUM_OCTAVE_INDEX = 0;
79+
const double SIFT_PEAK_THRESH = 0.;
80+
const double SIFT_EDGE_THRESH = 10.;
81+
82+
/*** init feature ***/
83+
const double INLIER_TOLERANT_STD_DISTANCE = 4.25; /* mean + 4.25 * std */
84+
85+
/*** sRANSAC ***/
86+
const double GLOBAL_TRUE_PROBABILITY = 0.225;
87+
const double LOCAL_TRUE_PROBABILITY = 0.2;
88+
const double OPENCV_DEFAULT_CONFIDENCE = 0.995;
89+
90+
/*** sparse linear system ***/
91+
const double STRONG_CONSTRAINT = 1e4;
92+
93+
/*** bundle adjustment ***/
94+
const int CRITERIA_MAX_COUNT = 1000;
95+
const double CRITERIA_EPSILON = DBL_EPSILON;
96+
97+
/*** 2D Method ***/
98+
const double TOLERANT_ANGLE = 1.5;
99+
100+
/*** 3D Method ***/
101+
const double LAMBDA_GAMMA = 10;
102+
103+
/******************************/
104+
/******************************/
105+
/******************************/
106+
107+
/*** rotation method setting ***/
108+
enum GLOBAL_ROTATION_METHODS {
109+
GLOBAL_ROTATION_2D_METHOD = 0, GLOBAL_ROTATION_3D_METHOD, GLOBAL_ROTATION_METHODS_SIZE
110+
};
111+
const string GLOBAL_ROTATION_METHODS_NAME[GLOBAL_ROTATION_METHODS_SIZE] = {
112+
"[2D]", "[3D]"
113+
};
114+
115+
/* blending method setting */
116+
enum BLENDING_METHODS {
117+
BLEND_AVERAGE = 0, BLEND_LINEAR, BLEND_METHODS_SIZE
118+
};
119+
const string BLENDING_METHODS_NAME[BLEND_METHODS_SIZE] = {
120+
"[BLEND_AVERAGE]", "[BLEND_LINEAR]"
121+
};
122+
123+
124+
/* type */
125+
typedef float FLOAT_TYPE;
126+
typedef Size_<FLOAT_TYPE> Size2;
127+
typedef Point_<FLOAT_TYPE> Point2;
128+
typedef Rect_<FLOAT_TYPE> Rect2;
129+
130+
const int DIMENSION_2D = 2;
131+
const int HOMOGRAPHY_VARIABLES_COUNT = 9;
132+
133+
/* AutoStitch */
134+
enum AUTO_STITCH_WAVE_CORRECTS { WAVE_X = 0, WAVE_H, WAVE_V };
135+
const AUTO_STITCH_WAVE_CORRECTS WAVE_CORRECT = WAVE_H;
136+
const string AUTO_STITCH_WAVE_CORRECTS_NAME[] = { "", "[WAVE_H]", "[WAVE_V]" };
137+
138+
#endif /* defined(__UglyMan_Stitiching__Configure__) */

Debug/GES_Stitching.log

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
D:\visual_studio_files\GES-GSP-Stitching-master\Code\GES_Stitching.vcxproj(114,5): error MSB4019: 找不到导入的项目“D:\visual_studio_files\Opencv_Debug.props”。请确认 Import 声明“..\..\Opencv_Debug.props”中的表达式正确,且文件位于磁盘上。

Debugger/ColorMap.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// ColorMap.cpp
3+
// UglyMan_Stitching
4+
//
5+
// Created by uglyman.nothinglo on 2015/8/15.
6+
// Copyright (c) 2015 nothinglo. All rights reserved.
7+
//
8+
9+
#include "ColorMap.h"
10+
11+
Scalar getBlueToRedScalar(double v, double vmin, double vmax) {
12+
Scalar c = { 1.0, 1.0, 1.0, 1.0 }; // white
13+
double dv;
14+
15+
if (v < vmin)
16+
v = vmin;
17+
if (v > vmax)
18+
v = vmax;
19+
dv = vmax - vmin;
20+
21+
if (v < (vmin + 0.25 * dv)) {
22+
c[2] = 0;
23+
c[1] = 4 * (v - vmin) / dv;
24+
}
25+
else if (v < (vmin + 0.5 * dv)) {
26+
c[2] = 0;
27+
c[0] = 1 + 4 * (vmin + 0.25 * dv - v) / dv;
28+
}
29+
else if (v < (vmin + 0.75 * dv)) {
30+
c[2] = 4 * (v - vmin - 0.5 * dv) / dv;
31+
c[0] = 0;
32+
}
33+
else {
34+
c[1] = 1 + 4 * (vmin + 0.75 * dv - v) / dv;
35+
c[0] = 0;
36+
}
37+
return c;
38+
}

Debugger/ColorMap.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
//
3+
// ColorMap.h
4+
// UglyMan_Stitching
5+
//
6+
// Created by uglyman.nothinglo on 2015/8/15.
7+
// Copyright (c) 2015 nothinglo. All rights reserved.
8+
//
9+
10+
#ifndef __UglyMan_Stitiching__ColorMap__
11+
#define __UglyMan_Stitiching__ColorMap__
12+
13+
#include "opencv2/core/core.hpp"
14+
#include "opencv2/highgui/highgui.hpp"
15+
#include "opencv2/imgproc/imgproc.hpp"
16+
17+
using namespace cv;
18+
19+
Scalar getBlueToRedScalar(double v, double vmin = -1, double vmax = 1);
20+
21+
#endif /* defined(__UglyMan_Stitiching_ColorMap__) */

Debugger/ErrorController.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ErrorController.cpp
3+
// UglyMan_Stitching
4+
//
5+
// Created by uglyman.nothinglo on 2015/8/15.
6+
// Copyright (c) 2015 nothinglo. All rights reserved.
7+
//
8+
9+
#include "ErrorController.h"
10+
11+
void printError(const string _error) {
12+
cerr << "[ERROR] " << _error << endl;
13+
}

Debugger/ErrorController.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
//
3+
// ErrorController.h
4+
// UglyMan_Stitching
5+
//
6+
// Created by uglyman.nothinglo on 2015/8/15.
7+
// Copyright (c) 2015 nothinglo. All rights reserved.
8+
//
9+
10+
#ifndef __UglyMan_Stitiching__ErrorController__
11+
#define __UglyMan_Stitiching__ErrorController__
12+
13+
#include <iostream>
14+
#include <string>
15+
16+
using namespace std;
17+
18+
void printError(const string _error);
19+
20+
#endif /* defined(__UglyMan_Stitiching__ErrorController__) */

Debugger/ImageDebugger.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// ImageDebugger.cpp
3+
// UglyMan_Stitching
4+
//
5+
// Created by uglyman.nothinglo on 2015/8/15.
6+
// Copyright (c) 2015 nothinglo. All rights reserved.
7+
//
8+
9+
#include "ImageDebugger.h"
10+
11+
/// <summary>
12+
/// 将两张图像和特征点,画圈和线
13+
/// </summary>
14+
/// <param name="img1">第一张图像</param>
15+
/// <param name="img2">第二张图像</param>
16+
/// <param name="f1">第一张的特征点</param>
17+
/// <param name="f2">第二张的特征点</param>
18+
/// <returns>画好的图像</returns>
19+
Mat getImageOfFeaturePairs(const Mat& img1,
20+
const Mat& img2,
21+
const vector<Point2>& f1,
22+
const vector<Point2>& f2) {
23+
assert(f1.size() == f2.size());
24+
assert(img1.type() == img2.type());
25+
26+
const int CIRCLE_RADIUS = 5;
27+
const int CIRCLE_THICKNESS = 1;
28+
const int LINE_THICKNESS = 1;
29+
const int RGB_8U_RANGE = 256;
30+
31+
Mat result = Mat::zeros(max(img1.rows, img2.rows), img1.cols + img2.cols, CV_8UC3);
32+
Mat left(result, Rect(0, 0, img1.cols, img1.rows));
33+
Mat right(result, Rect(img1.cols, 0, img2.cols, img2.rows));
34+
35+
Mat img1_8UC3, img2_8UC3;
36+
37+
if (img1.type() == CV_8UC3) {
38+
img1_8UC3 = img1;
39+
img2_8UC3 = img2;
40+
}
41+
else {
42+
img1.convertTo(img1_8UC3, CV_8UC3);
43+
img2.convertTo(img2_8UC3, CV_8UC3);
44+
}
45+
img1_8UC3.copyTo(left);
46+
img2_8UC3.copyTo(right);
47+
48+
for (int i = 0; i < f1.size(); ++i) {
49+
Scalar color(rand() % RGB_8U_RANGE, rand() % RGB_8U_RANGE, rand() % RGB_8U_RANGE);
50+
circle(result, f1[i], CIRCLE_RADIUS, color, CIRCLE_THICKNESS, LINE_AA);
51+
line(result, f1[i], f2[i] + Point2(img1.cols, 0), color, LINE_THICKNESS, LINE_AA);
52+
circle(result, f2[i] + Point2(img1.cols, 0), CIRCLE_RADIUS, color, CIRCLE_THICKNESS, LINE_AA);
53+
}
54+
return result;
55+
}

Debugger/ImageDebugger.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// ImageDebugger.h
3+
// UglyMan_Stitching
4+
//
5+
// Created by uglyman.nothinglo on 2015/8/15.
6+
// Copyright (c) 2015 nothinglo. All rights reserved.
7+
//
8+
9+
#ifndef __UglyMan_Stitiching__ImageDebugger__
10+
#define __UglyMan_Stitiching__ImageDebugger__
11+
12+
#include "../Configure.h"
13+
14+
Mat getImageOfFeaturePairs(const Mat& img1,
15+
const Mat& img2,
16+
const vector<Point2>& f1,
17+
const vector<Point2>& f2);
18+
19+
#endif /* defined(__UglyMan_Stitiching__ImageDebugger__) */

Debugger/TimeCalculator.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// TimeCalculator.cpp
3+
// UglyMan_Stitching
4+
//
5+
// Created by uglyman.nothinglo on 2015/8/15.
6+
// Copyright (c) 2015 nothinglo. All rights reserved.
7+
//
8+
9+
#include "TimeCalculator.h"
10+
11+
void TimeCalculator::start() {
12+
begin_time = omp_get_wtime();
13+
}
14+
double TimeCalculator::end(const string output) const {
15+
double result = omp_get_wtime() - begin_time;
16+
if (output.empty() == false) {
17+
printf("[TIME] %.4fs : %s\n", result, output.c_str());
18+
}
19+
return result;
20+
}

Debugger/TimeCalculator.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// TimeCalculator.cpp
3+
// UglyMan_Stitching
4+
//
5+
// Created by uglyman.nothinglo on 2015/8/15.
6+
// Copyright (c) 2015 nothinglo. All rights reserved.
7+
//
8+
9+
#ifndef __UglyMan_Stitiching__TimeCalculator__
10+
#define __UglyMan_Stitiching__TimeCalculator__
11+
12+
#include <iostream>
13+
#include <string>
14+
#include <stdio.h>
15+
#include <omp.h> /* wall-clock time */
16+
17+
using namespace::std;
18+
19+
class TimeCalculator {
20+
public:
21+
void start();
22+
double end(const string output) const;
23+
private:
24+
double begin_time;
25+
};
26+
27+
#endif /* defined(__UglyMan_Stitiching__TimeCalculator__) */

0 commit comments

Comments
 (0)