-
Notifications
You must be signed in to change notification settings - Fork 9
/
mainTest.cpp
57 lines (49 loc) · 1.37 KB
/
mainTest.cpp
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
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include"proc.h"
#include"mSURF.h"
using namespace std;
int main()
{
int rows, cols;
unsigned char* srcImg1_ = ReadBMPFile(&rows, &cols, "3.bmp");
unsigned char* srcImg2_ = ReadBMPFile(&rows, &cols, "4.bmp");
double * srcImg1 = new double[rows*cols]();
double * srcImg2 = new double[rows*cols]();
for (int i = 0; i < rows*cols; i++)
{
srcImg1[i] = srcImg1_[i];
srcImg2[i] = srcImg2_[i];
}
const int Rows = rows;
const int Cols = cols;
//1.特征点检测和匹配
vector<Point2D> matchpoints1;
vector<Point2D> matchpoints2;
int matches_num = 150;
bool isFeatureDection =
mSURF_Detection(srcImg1, srcImg2, Rows, Cols, matchpoints1, matchpoints2, matches_num);
//2.变换模型选择与重映射
vector<double> transParameter;
transParameter = getRANSAC2(matchpoints1, matchpoints2, 9, 0);//【*透视矩阵】
if (!transParameter.size())
{
printf("透视变换矩阵求解错误!");
return 0;
}
printf("变换矩阵参数:\n");
for (int i = 0; i < transParameter.size(); i++)
{
printf("%lf ", transParameter[i]);
if ((i + 1) % 3 == 0)
{
printf("\n");
}
}
printf("1\n");
double * dstImg1_adj = new double[rows*cols]();
mWarpPerspective(srcImg1, dstImg1_adj, transParameter, Rows, Cols);
WriteBMPFile(dstImg1_adj, Rows, Cols, "registrated.bmp");
return 0;
}