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
28867224
Commit
28867224
authored
4 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Use a mean check also
parent
d9e8ba02
No related branches found
Branches containing commit
No related tags found
1 merge request
!358
Updates to SDK and alternative fusion
Pipeline
#33668
passed
4 years ago
Stage: all
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/operators/src/fusion/fusion.cpp
+3
-0
3 additions, 0 deletions
components/operators/src/fusion/fusion.cpp
components/operators/src/fusion/smoothing/mls_multi_weighted.cu
+22
-12
22 additions, 12 deletions
...ents/operators/src/fusion/smoothing/mls_multi_weighted.cu
with
25 additions
and
12 deletions
components/operators/src/fusion/fusion.cpp
+
3
−
0
View file @
28867224
...
@@ -36,6 +36,9 @@ bool Fusion::apply(ftl::rgbd::FrameSet &in, ftl::rgbd::FrameSet &out, cudaStream
...
@@ -36,6 +36,9 @@ bool Fusion::apply(ftl::rgbd::FrameSet &in, ftl::rgbd::FrameSet &out, cudaStream
cv
::
cuda
::
cvtColor
(
col
,
temp_
,
cv
::
COLOR_BGRA2GRAY
,
0
,
cvstream
);
cv
::
cuda
::
cvtColor
(
col
,
temp_
,
cv
::
COLOR_BGRA2GRAY
,
0
,
cvstream
);
cv
::
cuda
::
resize
(
temp_
,
temp2_
,
d
.
size
(),
0
,
0
,
cv
::
INTER_LINEAR
,
cvstream
);
cv
::
cuda
::
resize
(
temp_
,
temp2_
,
d
.
size
(),
0
,
0
,
cv
::
INTER_LINEAR
,
cvstream
);
// TODO: Not the best since the mean is entirely lost here.
// Perhaps check mean also with greater smoothing value
ftl
::
cuda
::
mean_subtract
(
temp2_
,
weights_
[
i
],
3
,
stream
);
ftl
::
cuda
::
mean_subtract
(
temp2_
,
weights_
[
i
],
3
,
stream
);
}
}
...
...
This diff is collapsed.
Click to expand it.
components/operators/src/fusion/smoothing/mls_multi_weighted.cu
+
22
−
12
View file @
28867224
...
@@ -53,12 +53,17 @@ __device__ inline float featureWeight(int f1, int f2) {
...
@@ -53,12 +53,17 @@ __device__ inline float featureWeight(int f1, int f2) {
float
d0
=
depth_origin
[
x
+
y
*
dpitch_o
];
float
d0
=
depth_origin
[
x
+
y
*
dpitch_o
];
if
(
d0
<=
camera_origin
.
minDepth
||
d0
>=
camera_origin
.
maxDepth
)
return
;
if
(
d0
<=
camera_origin
.
minDepth
||
d0
>=
camera_origin
.
maxDepth
)
return
;
const
int
feature1
=
feature_origin
[
x
+
y
*
fpitch_o
];
const
uchar2
feature1
=
feature_origin
[
x
+
y
*
fpitch_o
];
float3
X
=
camera_origin
.
screenToCam
((
int
)(
x
),(
int
)(
y
),
d0
);
float3
X
=
camera_origin
.
screenToCam
((
int
)(
x
),(
int
)(
y
),
d0
);
int2
s
=
camera_in
.
camToScreen
<
int2
>
(
o_2_in
*
X
);
int2
s
=
camera_in
.
camToScreen
<
int2
>
(
o_2_in
*
X
);
// TODO: Could dynamically adjust the smoothing factors depending upon the
// number of matches. Meaning, if lots of good local and feature matches
// then be less likely to include poorer matches. Conversely, if only poor
// non-local or feature distance matches, then increase search range.
// Neighbourhood
// Neighbourhood
for
(
int
v
=-
SEARCH_RADIUS
;
v
<=
SEARCH_RADIUS
;
++
v
)
{
for
(
int
v
=-
SEARCH_RADIUS
;
v
<=
SEARCH_RADIUS
;
++
v
)
{
for
(
int
u
=-
SEARCH_RADIUS
;
u
<=
SEARCH_RADIUS
;
++
u
)
{
for
(
int
u
=-
SEARCH_RADIUS
;
u
<=
SEARCH_RADIUS
;
++
u
)
{
...
@@ -69,16 +74,19 @@ __device__ inline float featureWeight(int f1, int f2) {
...
@@ -69,16 +74,19 @@ __device__ inline float featureWeight(int f1, int f2) {
const
float3
Xi
=
in_2_o
*
camera_in
.
screenToCam
(
s
.
x
+
u
,
s
.
y
+
v
,
d
);
const
float3
Xi
=
in_2_o
*
camera_in
.
screenToCam
(
s
.
x
+
u
,
s
.
y
+
v
,
d
);
const
float3
Ni
=
make_float3
(
normals_in
[
s
.
x
+
u
+
(
s
.
y
+
v
)
*
npitch_in
]);
const
float3
Ni
=
make_float3
(
normals_in
[
s
.
x
+
u
+
(
s
.
y
+
v
)
*
npitch_in
]);
const
int
feature2
=
feature_in
[
s
.
x
+
y
+
(
s
.
y
+
v
)
*
fpitch_i
];
const
uchar2
feature2
=
feature_in
[
s
.
x
+
y
+
(
s
.
y
+
v
)
*
fpitch_i
];
// Gauss approx weighting functions
// Gauss approx weighting functions
// Rule: spatially close and feature close is strong
// Rule: spatially close and feature close is strong
// Spatially far or feature far, then poor.
// Spatially far or feature far, then poor.
// So take the minimum, must be close and feature close to get good value
// So take the minimum, must be close and feature close to get good value
const
float
w_feat
=
ftl
::
cuda
::
weighting
(
float
(
abs
(
feature1
-
feature2
)),
fsmoothing
);
const
float
w_high_int
=
ftl
::
cuda
::
weighting
(
float
(
abs
(
int
(
feature1
.
x
)
-
int
(
feature2
.
x
))),
fsmoothing
);
const
float
w_mean_int
=
ftl
::
cuda
::
weighting
(
float
(
abs
(
int
(
feature1
.
y
)
-
int
(
feature2
.
y
))),
100.0
f
);
const
float
w_space
=
ftl
::
cuda
::
spatialWeighting
(
X
,
Xi
,
smoothing
);
const
float
w_space
=
ftl
::
cuda
::
spatialWeighting
(
X
,
Xi
,
smoothing
);
// TODO: Distance from cam squared
// TODO: Angle from cam (dot of normal and ray)
const
float
w
=
(
length
(
Ni
)
>
0.0
f
)
const
float
w
=
(
length
(
Ni
)
>
0.0
f
)
?
min
(
w_space
,
w_fea
t
)
?
min
(
w_space
,
min
(
w_high_int
,
w_mean_in
t
)
)
:
0.0
f
;
:
0.0
f
;
aX
+=
Xi
*
w
;
aX
+=
Xi
*
w
;
...
@@ -208,8 +216,8 @@ void MLSMultiIntensity::gather(
...
@@ -208,8 +216,8 @@ void MLSMultiIntensity::gather(
normal_accum_
.
ptr
<
half4
>
(),
normal_accum_
.
ptr
<
half4
>
(),
depth_prime_
.
ptr
<
float
>
(),
depth_prime_
.
ptr
<
float
>
(),
depth_src
.
ptr
<
float
>
(),
depth_src
.
ptr
<
float
>
(),
intensity_prime_
.
ptr
<
uchar
>
(),
intensity_prime_
.
ptr
<
uchar
2
>
(),
intensity_src
.
ptr
<
uchar
>
(),
intensity_src
.
ptr
<
uchar
2
>
(),
centroid_accum_
.
ptr
<
float4
>
(),
centroid_accum_
.
ptr
<
float4
>
(),
weight_accum_
.
ptr
<
float
>
(),
weight_accum_
.
ptr
<
float
>
(),
smoothing
,
smoothing
,
...
@@ -225,8 +233,8 @@ void MLSMultiIntensity::gather(
...
@@ -225,8 +233,8 @@ void MLSMultiIntensity::gather(
depth_prime_
.
step1
(),
depth_prime_
.
step1
(),
depth_src
.
step1
(),
depth_src
.
step1
(),
normals_src
.
step1
()
/
4
,
normals_src
.
step1
()
/
4
,
intensity_prime_
.
step1
(),
intensity_prime_
.
step1
()
/
2
,
intensity_src
.
step1
()
intensity_src
.
step1
()
/
2
);
);
cudaSafeCall
(
cudaGetLastError
()
);
cudaSafeCall
(
cudaGetLastError
()
);
}
}
...
@@ -268,8 +276,9 @@ void MLSMultiIntensity::adjust(
...
@@ -268,8 +276,9 @@ void MLSMultiIntensity::adjust(
template
<
int
RADIUS
>
template
<
int
RADIUS
>
__global__
void
mean_subtract_kernel
(
__global__
void
mean_subtract_kernel
(
const
uchar
*
__restrict__
intensity
,
const
uchar
*
__restrict__
intensity
,
uchar
*
__restrict__
contrast
,
uchar
2
*
__restrict__
contrast
,
int
pitch
,
int
pitch
,
int
cpitch
,
int
width
,
int
width
,
int
height
int
height
)
{
)
{
...
@@ -288,7 +297,7 @@ __global__ void mean_subtract_kernel(
...
@@ -288,7 +297,7 @@ __global__ void mean_subtract_kernel(
mean
/=
float
((
2
*
RADIUS
+
1
)
*
(
2
*
RADIUS
+
1
));
mean
/=
float
((
2
*
RADIUS
+
1
)
*
(
2
*
RADIUS
+
1
));
float
diff
=
float
(
intensity
[
x
+
y
*
pitch
])
-
mean
;
float
diff
=
float
(
intensity
[
x
+
y
*
pitch
])
-
mean
;
contrast
[
x
+
y
*
pitch
]
=
max
(
0
,
min
(
254
,
int
(
diff
)
+
127
));
contrast
[
x
+
y
*
pitch
]
=
make_uchar2
(
max
(
0
,
min
(
254
,
int
(
diff
)
+
127
))
,
int
(
mean
))
;
}
}
}
}
...
@@ -304,12 +313,13 @@ void ftl::cuda::mean_subtract(
...
@@ -304,12 +313,13 @@ void ftl::cuda::mean_subtract(
const
dim3
gridSize
((
intensity
.
cols
+
THREADS_X
-
1
)
/
THREADS_X
,
(
intensity
.
rows
+
THREADS_Y
-
1
)
/
THREADS_Y
);
const
dim3
gridSize
((
intensity
.
cols
+
THREADS_X
-
1
)
/
THREADS_X
,
(
intensity
.
rows
+
THREADS_Y
-
1
)
/
THREADS_Y
);
const
dim3
blockSize
(
THREADS_X
,
THREADS_Y
);
const
dim3
blockSize
(
THREADS_X
,
THREADS_Y
);
contrast
.
create
(
intensity
.
size
(),
CV_8U
);
contrast
.
create
(
intensity
.
size
(),
CV_8U
C2
);
mean_subtract_kernel
<
3
><<<
gridSize
,
blockSize
,
0
,
stream
>>>
(
mean_subtract_kernel
<
3
><<<
gridSize
,
blockSize
,
0
,
stream
>>>
(
intensity
.
ptr
<
uchar
>
(),
intensity
.
ptr
<
uchar
>
(),
contrast
.
ptr
<
uchar
>
(),
contrast
.
ptr
<
uchar
2
>
(),
intensity
.
step1
(),
intensity
.
step1
(),
contrast
.
step1
()
/
2
,
intensity
.
cols
,
intensity
.
cols
,
intensity
.
rows
intensity
.
rows
);
);
...
...
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