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
ea38539a
Commit
ea38539a
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Improve performance of mlsSmooth
parent
138fc9c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#12444
passed
5 years ago
Stage: all
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/reconstruct/src/depth_camera.cu
+17
-9
17 additions, 9 deletions
applications/reconstruct/src/depth_camera.cu
with
17 additions
and
9 deletions
applications/reconstruct/src/depth_camera.cu
+
17
−
9
View file @
ea38539a
...
@@ -140,7 +140,7 @@ __device__ float colordiffFloat2(const uchar4 &pa, const uchar4 &pb) {
...
@@ -140,7 +140,7 @@ __device__ float colordiffFloat2(const uchar4 &pa, const uchar4 &pb) {
return
ch
*
ch
*
ch
*
ch
;
return
ch
*
ch
*
ch
*
ch
;
}
}
#define WINDOW_RADIUS
9
#define WINDOW_RADIUS
5
__device__
float
mlsCamera
(
int
cam
,
const
float3
&
mPos
,
uchar4
c1
,
float3
&
wpos
)
{
__device__
float
mlsCamera
(
int
cam
,
const
float3
&
mPos
,
uchar4
c1
,
float3
&
wpos
)
{
const
ftl
::
voxhash
::
DepthCameraCUDA
&
camera
=
c_cameras
[
cam
];
const
ftl
::
voxhash
::
DepthCameraCUDA
&
camera
=
c_cameras
[
cam
];
...
@@ -190,13 +190,19 @@ __device__ float mlsCameraNoColour(int cam, const float3 &mPos, uchar4 c1, float
...
@@ -190,13 +190,19 @@ __device__ float mlsCameraNoColour(int cam, const float3 &mPos, uchar4 c1, float
//if (screenPos.x+u < width && screenPos.y+v < height) { //on creen
//if (screenPos.x+u < width && screenPos.y+v < height) { //on creen
float
depth
=
tex2D
<
float
>
(
camera
.
depth
,
screenPos
.
x
+
u
,
screenPos
.
y
+
v
);
float
depth
=
tex2D
<
float
>
(
camera
.
depth
,
screenPos
.
x
+
u
,
screenPos
.
y
+
v
);
const
float3
camPos
=
camera
.
params
.
kinectDepthToSkeleton
(
screenPos
.
x
+
u
,
screenPos
.
y
+
v
,
depth
);
const
float3
camPos
=
camera
.
params
.
kinectDepthToSkeleton
(
screenPos
.
x
+
u
,
screenPos
.
y
+
v
,
depth
);
// TODO:(Nick) dot product of normals < 0 means the point
// should be ignored with a weight of 0 since it is facing the wrong direction
// May be good to simply weight using the dot product to give
// a stronger weight to those whose normals are closer
float
weight
=
spatialWeighting
(
length
(
pf
-
camPos
),
h
);
float
weight
=
spatialWeighting
(
length
(
pf
-
camPos
),
h
);
if
(
weight
>
0.0
f
)
{
if
(
weight
>
0.0
f
)
{
uchar4
c2
=
tex2D
<
uchar4
>
(
camera
.
colour
,
screenPos
.
x
+
u
,
screenPos
.
y
+
v
);
uchar4
c2
=
tex2D
<
uchar4
>
(
camera
.
colour
,
screenPos
.
x
+
u
,
screenPos
.
y
+
v
);
if
(
colourWeighting
(
colordiffFloat2
(
c1
,
c2
))
>
0.0
f
)
{
if
(
colourWeighting
(
colordiffFloat2
(
c1
,
c2
))
>
0.0
f
)
{
w
pos
+=
weight
*
(
camera
.
pose
*
camPos
);
pos
+=
weight
*
camPos
;
//
(camera.pose * camPos);
weights
+=
weight
;
weights
+=
weight
;
}
}
}
}
...
@@ -204,7 +210,7 @@ __device__ float mlsCameraNoColour(int cam, const float3 &mPos, uchar4 c1, float
...
@@ -204,7 +210,7 @@ __device__ float mlsCameraNoColour(int cam, const float3 &mPos, uchar4 c1, float
}
}
}
}
//
wpos += (camera.pose * pos
)
;
if
(
weights
>
0.0
f
)
wpos
+=
(
camera
.
pose
*
(
pos
/
weights
))
*
weights
;
return
weights
;
return
weights
;
}
}
...
@@ -294,8 +300,8 @@ __global__ void mls_smooth_kernel(ftl::cuda::TextureObject<float4> output, HashP
...
@@ -294,8 +300,8 @@ __global__ void mls_smooth_kernel(ftl::cuda::TextureObject<float4> output, HashP
if
(
hashParams
.
m_flags
&
ftl
::
voxhash
::
kFlagMLS
)
{
if
(
hashParams
.
m_flags
&
ftl
::
voxhash
::
kFlagMLS
)
{
for
(
uint
cam2
=
0
;
cam2
<
numcams
;
++
cam2
)
{
for
(
uint
cam2
=
0
;
cam2
<
numcams
;
++
cam2
)
{
if
(
cam2
==
cam
)
weights
+=
mlsCameraNoColour
(
cam2
,
mPos
,
c1
,
wpos
,
c_hashParams
.
m_spatialSmoothing
*
0.1
f
);
//weights += 0.5*mlsCamera(cam2, mPos, c1, wpos);
//
if (cam2 == cam) weights += mlsCameraNoColour(cam2, mPos, c1, wpos, c_hashParams.m_spatialSmoothing*0.1f); //weights += 0.5*mlsCamera(cam2, mPos, c1, wpos);
weights
+=
mlsCameraNoColour
(
cam2
,
mPos
,
c1
,
wpos
,
c_hashParams
.
m_spatialSmoothing
*
5.0
f
);
weights
+=
mlsCameraNoColour
(
cam2
,
mPos
,
c1
,
wpos
,
c_hashParams
.
m_spatialSmoothing
);
//*((cam == cam2)? 0.1f :
5.0f)
)
;
// Previous approach
// Previous approach
//if (cam2 == cam) continue;
//if (cam2 == cam) continue;
...
@@ -309,10 +315,12 @@ __global__ void mls_smooth_kernel(ftl::cuda::TextureObject<float4> output, HashP
...
@@ -309,10 +315,12 @@ __global__ void mls_smooth_kernel(ftl::cuda::TextureObject<float4> output, HashP
//output(x,y) = (weights >= hashParams.m_confidenceThresh) ? make_float4(wpos, 0.0f) : make_float4(MINF,MINF,MINF,MINF);
//output(x,y) = (weights >= hashParams.m_confidenceThresh) ? make_float4(wpos, 0.0f) : make_float4(MINF,MINF,MINF,MINF);
const
uint2
screenPos
=
make_uint2
(
mainCamera
.
params
.
cameraToKinectScreenInt
(
mainCamera
.
poseInverse
*
wpos
));
if
(
weights
>=
hashParams
.
m_confidenceThresh
)
output
(
x
,
y
)
=
make_float4
(
wpos
,
0.0
f
);
if
(
screenPos
.
x
<
output
.
width
()
&&
screenPos
.
y
<
output
.
height
())
{
output
(
screenPos
.
x
,
screenPos
.
y
)
=
(
weights
>=
hashParams
.
m_confidenceThresh
)
?
make_float4
(
wpos
,
0.0
f
)
:
make_float4
(
MINF
,
MINF
,
MINF
,
MINF
);
//const uint2 screenPos = make_uint2(mainCamera.params.cameraToKinectScreenInt(mainCamera.poseInverse * wpos));
}
//if (screenPos.x < output.width() && screenPos.y < output.height()) {
// output(screenPos.x,screenPos.y) = (weights >= hashParams.m_confidenceThresh) ? make_float4(wpos, 0.0f) : make_float4(MINF,MINF,MINF,MINF);
//}
}
}
}
}
}
}
...
...
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