-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
96 lines (90 loc) · 2.82 KB
/
main.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
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
// #include "mainwindow.h"
// #include <QApplication>
#include "include/chessboardcalib.h"
#include "include/rectification.h"
#include "include/structurelightimages.h"
#include "include/graycode.h"
#include "include/wrapphase.h"
#include "include/unwrapphase.h"
#include "include/roi.h"
#include "include/match.h"
#include "include/triangulation.h"
#define ROW 1024
#define COL 1280
using namespace cv;
using namespace std;
int main(int argc, char *argv[])
{
//---------------1.camera calibration------------
#if 1
Chessboard cb(true, true);
Calib *c = &cb;
c->OneButtonCalib(); //在imagelist.h中修改标定图片目录, 内外参数目录
#endif
//---------------2.rectify image-----------------
#if 1
Rectification rect;
rect.OneButtonRectify();
#endif
#if 1
//---------------3.Structure Light Image handler----------
StructureLightImages sli;
sli.InitImages();
Graycode gcl(ROW,COL);
gcl.DecodeGray(sli.left_dec);
//imshow("test", gc.dec);
//waitKey(1000000);
WrapPhase wpl(ROW,COL);
wpl.DecodeWrapSave(sli.Left_cosin);
//imshow("test", wp.wrapped_phase);
//waitKey(1000000);
Roi rl(ROW,COL);
rl.SetRoi(sli.left_roi);
Mat leftroi = rl.roi;
//imshow("testl", rl.roi);
//waitKey(1000000);
UnwrapPhase uwpl(ROW,COL);
uwpl.GetPhraseSave(gcl.dec,wpl.wrapped_phase, rl.roi);
Mat leftphase = uwpl._phs;
Graycode gcr(ROW,COL);
WrapPhase wpr(ROW,COL);
Roi rr(ROW,COL);
UnwrapPhase uwpr(ROW,COL);
gcr.DecodeGray(sli.right_dec);
wpr.DecodeWrapSave(sli.right_cosin);
rr.SetRoi(sli.right_roi);
uwpr.GetPhraseSave(gcr.dec,wpr.wrapped_phase,rr.roi);
Mat rightphase = uwpr._phs;
Mat rightroi = rr.roi;
//phase testing
Mat test1;
Mat test2;
leftphase.convertTo(test1,CV_8UC3);
rightphase.convertTo(test2, CV_8UC3);
imwrite("leftphase.jpg",leftphase);
imwrite("rightphase.jpg", rightphase);
//imshow("test1",test1);
//imshow("test2",test2);
//waitKey(1000000);
//imshow("test",rr.roi);
//waitKey(1000000);
#endif
#if 1
//---------------4.stereo macth--------------------------
int64 t = getTickCount();
Match mc;
//mc.StereoCorrespond(leftphase,rightphase,leftroi,rightroi);
mc.StereoCorrespond(uwpl._phs,uwpr._phs,rl.roi,rr.roi);
t = getTickCount() - t;
cout << "Time elapsed: " << t*1000/getTickFrequency() << "ms" <<endl;
//---------------5.triangulate---------------------------
Triangulation tl(static_cast<int>(mc.leftpoints.size()));
tl.TriangulationPoints(sli.P1, sli.P2, mc.leftpoints,mc.rightpoints);
tl.Save("points.txt");
#endif
// QApplication a(argc, argv);
// MainWindow w;
// w.show();
// return a.exec();
return 1;
}