-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.cpp
86 lines (63 loc) · 2.48 KB
/
test.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
#include <iostream>
#include <vector>
#include <string>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/common/transforms.h>
#include <nabo/nabo.h>
#include <opencv2/core/eigen.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/ml/ml.hpp>
#include "segmatch/SegMatch.h"
using namespace std;
using namespace cv;
using namespace pcl;
using namespace Nabo;
using namespace Eigen;
int main (int argc, char *argv[])
{
if(argc < 2)return -1;
SegMatchParam param = GetSegMatchParam("../param/segmatch.yaml");
PointCloud<PointXYZI>::Ptr target(new PointCloud<PointXYZI>);
PointCloud<PointXYZI>::Ptr source(new PointCloud<PointXYZI>);
PointCloud<PointXYZI>::Ptr source0(new PointCloud<PointXYZI>);
PointCloud<PointXYZI>::Ptr source1(new PointCloud<PointXYZI>);
PCDReader reader;
string file_name;
file_name = param.file_directory+param.map_name+"-fullmap.pcd";
reader.read(file_name, *target);
SegMatch segmatch(param);
segmatch.setTargetCloud(target);
Eigen::Isometry3f t0 = Eigen::Isometry3f::Identity();
t0.pretranslate(Eigen::Vector3f(0.0, 0.0, 50.0));
// t0.rotate(Eigen::AngleAxisf(3.1415926/4, Eigen::Vector3f::UnitZ ()));
cout<<t0.matrix()<<endl;
file_name = param.file_directory+param.map_name+"-sourcemap-"+argv[1]+".pcd";
reader.read(file_name, *source);
transformPointCloud(*source, *source0, t0);
segmatch.setSourceCloud(source0);
vector<Match> matches;
segmatch.findCandidates(matches, false);
vector<Match> filtered_matches;
Eigen::Matrix4f transformation;
segmatch.filterMatches(matches, filtered_matches, transformation);
transformPointCloud(*source0, *source1, transformation);
cout<<transformation.matrix()<<endl;
visualization::PCLVisualizer p;
PointCloudColorHandlerCustom<PointXYZI> h0(target, 255, 255, 255);
p.addPointCloud(target, h0, string("target"));
// PointCloudColorHandlerCustom<PointXYZI> h1(source, 200, 50, 50);
// p.addPointCloud(source, h1, string("source"));
PointCloudColorHandlerCustom<PointXYZI> h2(source0, 50, 50, 200);
p.addPointCloud(source0, h2, string("source0"));
PointCloudColorHandlerCustom<PointXYZI> h3(source1, 50, 200, 50);
p.addPointCloud(source1, h3, string("source1"));
p.setPointCloudRenderingProperties(PCL_VISUALIZER_POINT_SIZE, 2, "source1");
while(!p.wasStopped())
{
p.spinOnce(1000);
}
return 0;
}