forked from YinlinHu/CPM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (45 loc) · 1.14 KB
/
main.cpp
File metadata and controls
57 lines (45 loc) · 1.14 KB
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
#include "CPM.h"
void WriteMatches(const char *filename, cpm::FImage& inMat)
{
int len = inMat.height();
FILE *fid = fopen(filename, "w");
for (int i = 0; i < len; i++){
float x1 = inMat[4 * i + 0];
float y1 = inMat[4 * i + 1];
float x2 = inMat[4 * i + 2];
float y2 = inMat[4 * i + 3];
fprintf(fid, "%.0f %.0f %.0f %.0f\n", x1, y1, x2, y2);
//fprintf(fid, "%.3f %.3f %.3f %.3f 1 100\n", x1, y1, x2, y2);
}
fclose(fid);
}
int main(int argc, char** argv)
{
if (argc < 4){
printf("USAGE: CPM image1 image2 outMatchText <step>\n");
return -1;
}
cpm::FImage img1, img2;
img1.imread(argv[1]);
img2.imread(argv[2]);
char* outMatName = argv[3];
int step = 3;
if (argc >= 5){
step = atoi(argv[4]);
}
int w = img1.width();
int h = img1.height();
if (img2.width() != w || img2.height() != h){
printf("CPM can only handle images with the same dimension!\n");
return -1;
}
cpm::CTimer totalT;
cpm::FImage matches;
cpm::sCPMParameters l_CPMParam;
l_CPMParam.m_Step_i = step;
cpm::CPM cpm_obj(l_CPMParam);
cpm_obj.Matching(img1, img2, matches);
totalT.toc("total time: ");
WriteMatches(outMatName, matches);
return 0;
}