forked from KIT-MRT/stargazer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdemo.cpp
More file actions
61 lines (51 loc) · 2.1 KB
/
Copy pathdemo.cpp
File metadata and controls
61 lines (51 loc) · 2.1 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
58
59
60
61
#include <CeresLocalizer.h>
#include <DebugVisualizer.h>
#include "LandmarkFinder.h"
using namespace stargazer;
using namespace std;
int main(int argc, char** argv) {
if (argc != 3) {
cout << " Usage: " << argv[0] << " <image_file> <config_file>" << endl;
return -1;
}
cv::Mat input_image = cv::imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
DebugVisualizer debugVisualizer;
debugVisualizer.SetWaitTime(-1); // Wait until user has pressed key
debugVisualizer.SetWindowMode(CV_WINDOW_NORMAL);
LandmarkFinder landmarkFinder(argv[2]);
std::vector<ImgLandmark> detected_landmarks;
landmarkFinder.DetectLandmarks(input_image, detected_landmarks);
cout << "Displaying images, press any key to continue.... " << endl;
// Invert images for better visibilty
cv::bitwise_not(landmarkFinder.grayImage_, landmarkFinder.grayImage_);
debugVisualizer.ShowImage(landmarkFinder.grayImage_, "0 Gray Image");
// Draw detections
debugVisualizer.ShowImage(
debugVisualizer.DrawPoints(landmarkFinder.grayImage_, landmarkFinder.points_),
"1 Points");
debugVisualizer.ShowImage(
debugVisualizer.DrawClusters(landmarkFinder.grayImage_, landmarkFinder.clusteredPoints_),
"2 Clusters");
debugVisualizer.ShowImage(debugVisualizer.DrawLandmarkHypotheses(
landmarkFinder.grayImage_, landmarkFinder.landmarkHypotheses_),
"3 Hypotheses");
debugVisualizer.ShowImage(
debugVisualizer.DrawLandmarks(landmarkFinder.grayImage_, detected_landmarks),
"4 Landmarks");
// Localize
const std::string args(argv[2]);
CeresLocalizer localizer(args);
localizer.UpdatePose(detected_landmarks, 0.0);
cout << localizer.getSummary().FullReport() << endl << endl;
pose_t pose = localizer.getPose();
// clang-format off
cout << "Pose is"
<< " x=" << pose[(int)POSE::X]
<< " y=" << pose[(int)POSE::Y]
<< " z=" << pose[(int)POSE::Z]
<< " rx=" << pose[(int)POSE::Rx]
<< " ry=" << pose[(int)POSE::Ry]
<< " rz=" << pose[(int)POSE::Rz] << endl;
// clang-format on
return EXIT_SUCCESS;
}