Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
1a495bb5
Commit
1a495bb5
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
ICP on best estimate
parent
991975d3
No related branches found
No related tags found
1 merge request
!43
Partial completion of #95
Pipeline
#11723
passed
5 years ago
Stage: all
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
applications/registration/src/correspondances.cpp
+34
-5
34 additions, 5 deletions
applications/registration/src/correspondances.cpp
applications/registration/src/correspondances.hpp
+1
-0
1 addition, 0 deletions
applications/registration/src/correspondances.hpp
with
35 additions
and
5 deletions
applications/registration/src/correspondances.cpp
+
34
−
5
View file @
1a495bb5
...
...
@@ -136,10 +136,10 @@ bool Correspondances::capture(cv::Mat &rgb1, cv::Mat &rgb2) {
cv
::
imshow
(
"smooth d2"
,
d2_v
);
// Should be done in RGB-Depth source class
/*
cv::Ptr<cv::xphoto::WhiteBalancer> wb;
cv
::
Ptr
<
cv
::
xphoto
::
WhiteBalancer
>
wb
;
wb
=
cv
::
xphoto
::
createSimpleWB
();
wb
->
balanceWhite
(
rgb1
,
rgb1
);
wb->balanceWhite(rgb2, rgb2);
*/
wb
->
balanceWhite
(
rgb2
,
rgb2
);
// Build point clouds
clear
();
...
...
@@ -276,6 +276,30 @@ double Correspondances::icp() {
return
icp
.
getFitnessScore
();
}
double
Correspondances
::
icp
(
const
Eigen
::
Matrix4f
&
T_in
,
Eigen
::
Matrix4f
&
T_out
,
const
vector
<
int
>
&
idx
)
{
//pcl::PointCloud<pcl::PointXYZ>::Ptr tsrc_cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
final_cloud
(
new
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
);
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
targ_cloud
(
new
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
);
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
src_cloud
(
new
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
);
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
tsrc_cloud
(
new
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
);
for
(
int
i
=
0
;
i
<
idx
.
size
();
i
++
)
{
src_cloud
->
push_back
(
src_cloud_
->
at
(
src_feat_
[
idx
[
i
]]));
targ_cloud
->
push_back
(
targ_cloud_
->
at
(
targ_feat_
[
idx
[
i
]]));
}
pcl
::
transformPointCloud
(
*
src_cloud
,
*
tsrc_cloud
,
T_in
);
pcl
::
IterativeClosestPoint
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
icp
;
icp
.
setInputSource
(
tsrc_cloud
);
icp
.
setInputTarget
(
targ_cloud
);
icp
.
align
(
*
final_cloud
);
LOG
(
INFO
)
<<
"has converged:"
<<
icp
.
hasConverged
()
<<
" score: "
<<
icp
.
getFitnessScore
();
T_out
=
T_in
*
icp
.
getFinalTransformation
();
return
icp
.
getFitnessScore
();
}
static
std
::
default_random_engine
generator
;
void
Correspondances
::
convertToPCL
(
const
std
::
vector
<
std
::
tuple
<
int
,
int
,
int
,
int
>>
&
p
,
std
::
vector
<
std
::
pair
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>>
&
pp
)
{
...
...
@@ -326,7 +350,7 @@ void Correspondances::getTransformedFeatures2D(std::vector<Eigen::Vector2i> &f)
double
Correspondances
::
findBestSubset
(
Eigen
::
Matrix4f
&
tr
,
int
K
,
int
N
)
{
double
score
=
10000.0
f
;
vector
<
tuple
<
int
,
int
,
int
,
int
>
>
best
;
vector
<
int
>
best
;
Eigen
::
Matrix4f
bestT
;
std
::
mt19937
rng
(
std
::
chrono
::
steady_clock
::
now
().
time_since_epoch
().
count
());
...
...
@@ -348,8 +372,10 @@ double Correspondances::findBestSubset(Eigen::Matrix4f &tr, int K, int N) {
sidx
.
clear
();
tidx
.
clear
();
vector
<
int
>
idx
;
for
(
int
k
=
0
;
k
<
K
;
k
++
)
{
int
r
=
dice
();
idx
.
push_back
(
r
);
sidx
.
push_back
(
src_feat_
[
r
]);
tidx
.
push_back
(
targ_feat_
[
r
]);
}
...
...
@@ -360,14 +386,17 @@ double Correspondances::findBestSubset(Eigen::Matrix4f &tr, int K, int N) {
if
(
scoreT
<
score
)
{
score
=
scoreT
;
bestT
=
T
;
best
=
idx
;
}
}
return
icp
(
bestT
,
tr
,
best
);
// TODO Add these best points to actual clouds.
//log_ = best;
tr
=
bestT
;
//
tr = bestT;
//uptodate_ = true;
return
score
;
//
return score;
}
Eigen
::
Matrix4f
Correspondances
::
transform
()
{
...
...
This diff is collapsed.
Click to expand it.
applications/registration/src/correspondances.hpp
+
1
−
0
View file @
1a495bb5
...
...
@@ -69,6 +69,7 @@ class Correspondances {
double
findBestSubset
(
Eigen
::
Matrix4f
&
tr
,
int
K
,
int
N
);
double
icp
();
double
icp
(
const
Eigen
::
Matrix4f
&
T_in
,
Eigen
::
Matrix4f
&
T_out
,
const
std
::
vector
<
int
>
&
idx
);
void
convertToPCL
(
const
std
::
vector
<
std
::
tuple
<
int
,
int
,
int
,
int
>>
&
p
,
std
::
vector
<
std
::
pair
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>>
&
p2
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment