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
8d407ee5
Commit
8d407ee5
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Add options to control rendering
parent
f220dd2f
No related branches found
No related tags found
1 merge request
!88
Implements #146 upsampling option
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
applications/reconstruct/src/dibr.cu
+54
-8
54 additions, 8 deletions
applications/reconstruct/src/dibr.cu
applications/reconstruct/src/splat_render.cpp
+4
-0
4 additions, 0 deletions
applications/reconstruct/src/splat_render.cpp
with
58 additions
and
8 deletions
applications/reconstruct/src/dibr.cu
+
54
−
8
View file @
8d407ee5
...
...
@@ -67,7 +67,10 @@ __device__ inline bool isStable(const float3 &previous, const float3 &estimate,
if
(
camPos
.
z
<
params
.
camera
.
m_sensorDepthWorldMin
)
return
;
if
(
camPos
.
z
>
params
.
camera
.
m_sensorDepthWorldMax
)
return
;
const
int
upsample
=
min
(
UPSAMPLE_MAX
-
2
,
int
((
2.0
f
*
r
)
*
params
.
camera
.
fx
/
camPos
.
z
))
+
2
;
// TODO: Don't upsample so much that only minimum depth makes it through
// Consider also using some SDF style approach to accumulate and smooth a
// depth value between points
const
int
upsample
=
min
(
UPSAMPLE_MAX
-
2
,
int
(
0.01
*
params
.
camera
.
fx
/
camPos
.
z
))
+
3
;
const
float
interval
=
1.0
f
/
float
(
upsample
/
2
);
...
...
@@ -94,6 +97,35 @@ __device__ inline bool isStable(const float3 &previous, const float3 &estimate,
}
}
/*
* Pass 1: Directly render each camera into virtual view but with no upsampling
* for sparse points.
*/
__global__
void
dibr_merge_kernel
(
TextureObject
<
int
>
depth
,
int
cam
,
SplatParams
params
)
{
const
ftl
::
voxhash
::
DepthCameraCUDA
&
camera
=
c_cameras
[
cam
];
const
int
x
=
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
;
const
int
y
=
blockIdx
.
y
*
blockDim
.
y
+
threadIdx
.
y
;
const
float3
worldPos
=
make_float3
(
tex2D
<
float4
>
(
camera
.
points
,
x
,
y
));
if
(
worldPos
.
x
==
MINF
)
return
;
// Find the virtual screen position of current point
const
float3
camPos
=
params
.
m_viewMatrix
*
worldPos
;
if
(
camPos
.
z
<
params
.
camera
.
m_sensorDepthWorldMin
)
return
;
if
(
camPos
.
z
>
params
.
camera
.
m_sensorDepthWorldMax
)
return
;
const
float
d
=
camPos
.
z
;
const
uint2
screenPos
=
params
.
camera
.
cameraToKinectScreen
(
camPos
);
const
unsigned
int
cx
=
screenPos
.
x
;
const
unsigned
int
cy
=
screenPos
.
y
;
if
(
d
>
params
.
camera
.
m_sensorDepthWorldMin
&&
d
<
params
.
camera
.
m_sensorDepthWorldMax
&&
cx
<
depth
.
width
()
&&
cy
<
depth
.
height
())
{
// Transform estimated point to virtual cam space and output z
atomicMin
(
&
depth
(
cx
,
cy
),
d
*
1000.0
f
);
}
}
// ===== PASS 2 : Splat Visible Surface ========================================
/*
...
...
@@ -406,6 +438,7 @@ __global__ void OLD_dibr_visibility_kernel(TextureObject<int> depth, int cam, Sp
const
float3
point
=
params
.
camera
.
kinectDepthToSkeleton
(
x
+
u
,
y
+
v
,
float
(
point_in
.
tex2D
(
x
+
u
,
y
+
v
))
/
1000.0
f
);
// If it is close enough...
// TODO: We don't have camPos so distance if this pixel takes on same depth
if
(
length
(
point
-
camPos
)
<=
SPATIAL_SMOOTHING
)
{
// Append to neighbour list
unsigned
int
idx
=
atomicInc
(
&
nidx
[
warp
],
MAX_NEIGHBORS_2
-
1
);
...
...
@@ -625,20 +658,33 @@ void ftl::cuda::dibr(const TextureObject<int> &depth_out,
int
i
=
3
;
// Pass 1, gather and upsample depth maps
for
(
int
i
=
0
;
i
<
numcams
;
++
i
)
dibr_merge_upsample_kernel
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
tmp_depth
,
i
,
params
);
if
(
params
.
m_flags
&
ftl
::
render
::
kNoUpsampling
)
{
for
(
int
i
=
0
;
i
<
numcams
;
++
i
)
dibr_merge_kernel
<<<
gridSize
,
blockSize
,
0
,
stream
>>>
(
tmp_depth
,
i
,
params
);
}
else
{
for
(
int
i
=
0
;
i
<
numcams
;
++
i
)
dibr_merge_upsample_kernel
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
tmp_depth
,
i
,
params
);
}
if
(
params
.
m_flags
&
ftl
::
render
::
kNoSplatting
)
{
// Pass 3, accumulate all point contributions to pixels
for
(
int
i
=
0
;
i
<
numcams
;
++
i
)
dibr_attribute_contrib_kernel
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
tmp_depth
,
tmp_colour
,
normal_out
,
confidence_out
,
i
,
params
);
}
else
{
// Pass 2
dibr_visibility_principal_kernel2
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
tmp_depth
,
depth_out
,
params
);
// Pass 3, accumulate all point contributions to pixels
for
(
int
i
=
0
;
i
<
numcams
;
++
i
)
dibr_attribute_contrib_kernel
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
depth_out
,
tmp_colour
,
normal_out
,
confidence_out
,
i
,
params
);
}
// Pass 2
dibr_visibility_principal_kernel2
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
tmp_depth
,
depth_out
,
params
);
//
dibr_visibility_principal_kernel2<<<sgridSize, sblockSize, 0, stream>>>(tmp_depth, depth_out, params);
// Pass 2, merge a depth map from each camera.
//for (int i=0; i<numcams; ++i)
// dibr_visibility_principal_kernel<<<sgridSize, sblockSize, 0, stream>>>(depth_out, i, params);
// Pass 3, accumulate all point contributions to pixels
for
(
int
i
=
0
;
i
<
numcams
;
++
i
)
dibr_attribute_contrib_kernel
<<<
sgridSize
,
sblockSize
,
0
,
stream
>>>
(
depth_out
,
tmp_colour
,
normal_out
,
confidence_out
,
i
,
params
);
// Pass 4, normalise contributions
dibr_normalise_kernel
<<<
gridSize
,
blockSize
,
0
,
stream
>>>
(
tmp_colour
,
colour_out
,
normal_out
,
confidence_out
);
...
...
This diff is collapsed.
Click to expand it.
applications/reconstruct/src/splat_render.cpp
+
4
−
0
View file @
8d407ee5
...
...
@@ -46,6 +46,10 @@ void Splatter::render(ftl::rgbd::Source *src, cudaStream_t stream) {
// Parameters object to pass to CUDA describing the camera
SplatParams
params
;
params
.
m_flags
=
0
;
if
(
src
->
value
(
"splatting"
,
true
)
==
false
)
params
.
m_flags
|=
ftl
::
render
::
kNoSplatting
;
if
(
src
->
value
(
"upsampling"
,
true
)
==
false
)
params
.
m_flags
|=
ftl
::
render
::
kNoUpsampling
;
if
(
src
->
value
(
"texturing"
,
true
)
==
false
)
params
.
m_flags
|=
ftl
::
render
::
kNoTexturing
;
params
.
m_viewMatrix
=
MatrixConversion
::
toCUDA
(
src
->
getPose
().
cast
<
float
>
().
inverse
());
params
.
m_viewMatrixInverse
=
MatrixConversion
::
toCUDA
(
src
->
getPose
().
cast
<
float
>
());
params
.
voxelSize
=
scene_
->
getHashParams
().
m_virtualVoxelSize
;
...
...
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