-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
58 lines (47 loc) · 1.18 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
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <string>
#include <vector>
#include <iostream>
#include "sfm/Utility.h"
#include "sfm/Calibration.h"
#include "sfm/FindCameraMatrices.h"
#include "sfm/Triangulation.h"
#include "sfm/Visualizer.h"
bool calib_bool = false;
int main(int argc, char **argv) {
std::vector<std::string> filenames;
if (argc > 1) {
sfm::listFiles(std::string(argv[1]), filenames);
} else {
std::cout << "\nusage: main [path]" << std::endl;
return -1;
}
std::vector<cv::Mat> images;
sfm::readFiles(filenames, images);
// Camera calibration
cv::Mat K, distCoeffs;
if (calib_bool) {
sfm::writeCalibration(filenames, 1.0f, 9, 6);
return 0;
} else
sfm::readCalibration(K, distCoeffs);
// Calculate Camera matrix
cv::Matx34d P0, P1;
std::vector<cv::KeyPoint> keypointsL, keypointsR;
sfm::findCameraMatrix(
images[1],
images[2],
K,
P0,
P1,
keypointsL,
keypointsR);
// Triangulation
std::vector<cv::Point3d> pointcloud;
sfm::TriangulatePoints(keypointsL,keypointsR,P0,P1,pointcloud);
// Visualization
sfm::Visualizer *visualizer(new sfm::Visualizer());
visualizer->spinOnce(pointcloud);
return 0;
}