-
Notifications
You must be signed in to change notification settings - Fork 0
/
VBBDDescriptor.h
240 lines (187 loc) · 6.62 KB
/
VBBDDescriptor.h
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#ifndef __LiDAR_POINT_PROCESS_TOPOLOGY_QUANTIFY_CLASS_DEFINE_H__
#define __LiDAR_POINT_PROCESS_TOPOLOGY_QUANTIFY_CLASS_DEFINE_H__
#include <math.h>
#include "ccPointCloud.h"
#include "DgmOctree.h"
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/PCLPointCloud2.h>
#include <vector>
#include "ccStdPluginInterface.h "
//#include "opencv2/shape.hpp"
//#include "opencv2/imgcodecs.hpp"
//#include "opencv2/highgui.hpp"
//#include "opencv2/imgproc.hpp"
//#include <opencv2/core/utility.hpp>
#include <iostream>
#include <string>
#include"VBBDDescriptorSC.h"
//std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> patches;//存储邻域列表
//typedef std::vector<double> FeatureList; //对于每个点存储它的特征编码的类型
//std::vector<FeatureList> CodingList; //存储编码列表
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void getBBofCCVector3list(QVector<CCVector3> *pts, CCVector3 *left_down, CCVector3 *right_up);
void PointCloud2ccPointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr input, ccPointCloud *output);
void ccPointCloud2PointCloud(ccPointCloud *input, pcl::PointCloud<pcl::PointXYZ>::Ptr output);
void CCVector2ccPointCloud(QVector<CCVector3> *input, ccPointCloud *output);
void ccPointCloud2CCVector(ccPointCloud *input, QVector<CCVector3> *output);
string DoubleToString(double Input);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void KM_algorithm(int n, int **weight);
void VBBDDescriptor_ISS(ccPointCloud *theCloud, ccPointCloud *TransCC);
void VBBDDescriptor_Harris3D(ccPointCloud *theCloud, ccPointCloud *TransCC);
void VBBDDescriptor_NARF(ccPointCloud *theCloud, ccPointCloud *TransCC);
void VBBDDescriptor_SIFT3D(ccPointCloud *theCloud, ccPointCloud *TransCC);
void VBBDDescriptor_NARF(ccPointCloud *theCloud, ccPointCloud *TransCC);
void ConstructLRF(ccPointCloud *theCloud, ccPointCloud *TransCC, ccPointCloud *Neighbor, ccPointCloud *KeyTrans);
CCVector3 TransformMultiScale(Eigen::MatrixXd m_IsPlaneVector);
void Coordinate_Transform(Eigen::MatrixXd &m_IsPlaneVector, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out);
void FeatureComputation(ccPointCloud *keypoints, double gridSize, double h);
void FeatureCoding(ccPointCloud *keypoints, double gridSize, double radius);
void BinaryCoding(ccPointCloud *keypoints);
pcl::Correspondences Large_Scaled_registration(HybridSC RP1, HybridSC RP2, double i_radius, double gridsize, double i_scale , Eigen::Matrix4f &best_transform, double _ratio);
pcl::Correspondences Small_Scaled_registration(HybridSC RP1, HybridSC RP2, double i_radius, double gridsize, double i_scale, Eigen::Matrix4f &best_transform);
void Registation_3DSC(ccPointCloud *model_cloud, ccPointCloud *scene_cloud,
ccPointCloud* model_key, ccPointCloud *scene_key,
ccPointCloud *model_corrs, ccPointCloud *scene_corrs,
ccPointCloud* scene_trans, ccPointCloud * point_cloud,
ccPointCloud * line_cloud, ccPointCloud * plane_cloud,
ccMainAppInterface* m_app,
int current_index,
int _radius ,
int _grid ,
int _sampling,
double _ratio);
double computeCloudResolution(const pcl::PointCloud<PointType>::ConstPtr &cloud);
//void Registation(ccPointCloud *scene_cloud, ccPointCloud *model_cloud, ccPointCloud* scene_key, ccPointCloud *model_key);
//
//int Compute_3DHoPD(ccPointCloud *scene_cloud, ccPointCloud *model_cloud, ccPointCloud* scene_key, ccPointCloud *model_key);
//
int compute(ccPointCloud *scene_cloud, ccPointCloud *model_cloud, ccPointCloud* scene_key, ccPointCloud *model_key, ccPointCloud *scene_trans);
int TransformationS();
Eigen::Matrix4f RANSAC_Corresponding(pcl::Correspondences corrs, HybridSC RP1, HybridSC RP2, double resolution, pcl::Correspondences corrs_1);
double CalculateAccuracy(pcl::PointCloud<pcl::PointXYZ> cloud_keypoints_1, pcl::PointCloud<pcl::PointXYZ> cloud_keypoints_2, double resolution, double *distance);
int CalulateMultiScalePairs(ccPointCloud *input_1, ccPointCloud* input_2, double resolution);
#include <cstdio>
#include <memory.h>
#include <algorithm> // 使用其中的 min 函数
using namespace std;
struct index_similarity
{
int index_i;
int index_j;
double similarity;
};
class Kuhn_Munkres
{
public:
int n; // X 的大小
std::vector<int> weight; // X 到 Y 的映射(权重)
std::vector<int> lx; // X标号
std::vector<int> ly; // Y标号
std::vector<bool> sx;// x是否被搜索过
std::vector<bool> sy;// y是否被搜索过
std::vector<int> match;// Y(i) 与 X(match [i]) 匹配
public:
bool path(int u)
{
sx[u] = true;
for (int v = 0; v < n; v++)
if (!sy[v] && lx[u] + ly[v] == weight[u*n + v])
{
sy[v] = true;
if (match[v] == -1 || path(match[v]))
{
match[v] = u;
return true;
}
}
return false;
}
int bestmatch(bool maxsum)
{
int i, j;
if (!maxsum)
{
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
weight[i*n +j] = -weight[i*n+j];
}
// 初始化标号
for (i = 0; i < n; i++)
{
lx[i]= -0x1FFFFFFF;
ly[i] = 0;
for (j = 0; j < n; j++)
if (lx[i] < weight[i*n+j])
lx[i] = weight[i*n +j];
}
for (int ix = 0; ix < n; ix++)
{
match.push_back(-1);
}
for (int u = 0; u < n; u++)
while (true)
{
for (int ix = 0; ix < n; ix++)
{
sx[ix]= 0;
}
for (int ix = 0; ix < n; ix++)
{
sy[ix] = 0;
}
if (path(u))
break;
// 修改标号
int dx = 0x7FFFFFFF;
for (i = 0; i < n; i++)
if (sx[i])
for (j = 0; j < n; j++)
if (!sy[j])
dx = min(lx[i] + ly[j] - weight[i*n+j], dx);
for (i = 0; i < n; i++)
{
if (sx[i])
lx[i] -= dx;
if (sy[i])
ly[i] += dx;
}
}
int sum = 0;
for (i = 0; i < n; i++)
sum += weight[match[i]*n+i];
if (!maxsum)
{
sum = -sum;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
weight[i*n+j] = -weight[i*n+j]; // 如果需要保持 weight [ ] [ ] 原来的值,这里需要将其还原
}
return sum;
}
std::vector<index_similarity> KM_algorithm()
{
std::vector<index_similarity> _final;
for (int ix = 0; ix < n; ix++)
{
match.push_back(-1);
ly.push_back(0);
lx.push_back(0);
sy.push_back(0);
sx.push_back(0);
}
int cost = bestmatch(true);
ccLog::Print(QString("[cost] ") + QString::fromStdString(DoubleToString((double)cost)));
for (int i = 0; i < n; i++)
{
index_similarity _current;
_current.index_i = match[i];
_current.index_j = i;
_current.similarity = weight[match[i] * n + i];
_final.push_back(_current);
}
return _final;
}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif