-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
97 lines (83 loc) · 2.89 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
97
/*
* 3calibration.cpp -- Calibrate 3 cameras in a horizontal line together.
*/
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include <opencv2/ccalib/multicalib.hpp>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <iostream>
using namespace cv;
using namespace cv::xfeatures2d;
using namespace cv::multicalib;
int main(int argc, char** argv)
{
int camera_count;
int verbose;
int minMatch;
int showExtraction;
int termCount;
std::string inputFilename = "";
std::string outputFilename = "";
int patternWidth;
int patternHeight;
cv::CommandLineParser parser(argc, argv,
"{m|100|}{c||}{v|0|}{e|0|}{w||}{h||}{tc|10|}{@input||}"
"{@output||}");
camera_count = parser.get<int>("c");
verbose = parser.get<int>("v");
showExtraction = parser.get<int>("e");
patternWidth = parser.get<int>("w");
patternHeight = parser.get<int>("h");
minMatch = parser.get<int>("m");
termCount = parser.get<int>("tc");
std::cout << "camera_count=" << camera_count << std::endl;
std::cout << "patternWidth=" << patternWidth << std::endl;
std::cout << "patternHeight=" << patternHeight << std::endl;
inputFilename = parser.get<std::string>("@input");
outputFilename = parser.get<std::string>("@output");
if (!parser.check())
{
std::cout << "Usage: ./multicalibration -[m|c|v|e|w|h|tc] file_list.xml calibration_result.xml\nm - min matches (default 100)\nv - verbose (default false)\ne - show feature extraction (default false)\ntc - termination count (default 10)\nc - number of cameras\nw - physical width of pattern in user defined unit (usually mm)\nh - physical height of pattern in user defined unit (usually mm)" << std::endl;
parser.printErrors();
return -1;
}
if (inputFilename.empty())
{
std::cout << "Error: the input image list is not specified, or can not be read\n" << std::endl;
return -1;
}
//-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
int metrixThreshold = 200; //minHessian
int numberOfOctaves = 8;
int numScaleLevels = 4; // nOctavesLayer
Ptr<SURF> detector = SURF::create(metrixThreshold, numberOfOctaves, numScaleLevels);
Ptr<SURF> descriptor = detector;
MultiCameraCalibration multiCalib(
MultiCameraCalibration::PINHOLE,
camera_count,
inputFilename,
patternWidth,
patternHeight,
verbose,
showExtraction,
minMatch,
0,
cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, termCount, 10e-5),
detector,
descriptor,
DescriptorMatcher::create(DescriptorMatcher::FLANNBASED)
/*cv::AKAZE::create(cv::AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.005f),
cv::AKAZE::create(cv::AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.005f),
cv::DescriptorMatcher::create("BruteForce-L1")*/
);
multiCalib.run();
multiCalib.writeParameters(outputFilename);
return 0;
}