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
Admin message
Maintenance on Friday 28.3. at 13:00. ETA 60 - 90 minutes.
Show more breadcrumbs
Nicolas Pope
ftl
Commits
43f32841
Commit
43f32841
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
WIP Depth camera normals calc
parent
7aa42052
No related branches found
No related tags found
1 merge request
!71
Implements #130 for optional MLS merging
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
applications/reconstruct/include/ftl/depth_camera.hpp
+11
-62
11 additions, 62 deletions
applications/reconstruct/include/ftl/depth_camera.hpp
applications/reconstruct/src/depth_camera.cpp
+58
-0
58 additions, 0 deletions
applications/reconstruct/src/depth_camera.cpp
with
69 additions
and
62 deletions
applications/reconstruct/include/ftl/depth_camera.hpp
+
11
−
62
View file @
43f32841
...
...
@@ -36,66 +36,16 @@ struct DepthCamera {
// Host part //
///////////////
__host__
DepthCamera
()
{
/*d_depthData = NULL;
d_colorData = NULL;
d_depthArray = NULL;
d_colorArray = NULL;*/
depth_mat_
=
nullptr
;
colour_mat_
=
nullptr
;
point_mat_
=
nullptr
;
normal_mat_
=
nullptr
;
depth_tex_
=
nullptr
;
colour_tex_
=
nullptr
;
normal_tex_
=
nullptr
;
}
__host__
void
alloc
(
const
DepthCameraParams
&
params
,
bool
withNormals
=
false
)
{
//! todo resizing???
depth_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_32FC1
);
colour_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_8UC4
);
depth_tex_
=
new
ftl
::
cuda
::
TextureObject
<
float
>
((
cv
::
cuda
::
PtrStepSz
<
float
>
)
*
depth_mat_
);
colour_tex_
=
new
ftl
::
cuda
::
TextureObject
<
uchar4
>
((
cv
::
cuda
::
PtrStepSz
<
uchar4
>
)
*
colour_mat_
);
data
.
depth
=
depth_tex_
->
cudaTexture
();
data
.
colour
=
colour_tex_
->
cudaTexture
();
data
.
params
=
params
;
if
(
withNormals
)
{
point_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_32FC3
);
normal_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_32FC4
);
normal_tex_
=
new
ftl
::
cuda
::
TextureObject
<
float4
>
((
cv
::
cuda
::
PtrStepSz
<
float4
>
)
*
normal_mat_
);
data
.
normal
=
normal_tex_
->
cudaTexture
();
}
else
{
data
.
normal
=
0
;
}
}
//__host__
//void updateParams(const DepthCameraParams& params) {
// updateConstantDepthCameraParams(params);
//}
__host__
void
updateData
(
const
cv
::
Mat
&
depth
,
const
cv
::
Mat
&
rgb
,
cv
::
cuda
::
Stream
&
stream
)
{
depth_mat_
->
upload
(
depth
,
stream
);
colour_mat_
->
upload
(
rgb
,
stream
);
}
__host__
void
free
()
{
if
(
depth_mat_
)
delete
depth_mat_
;
if
(
colour_mat_
)
delete
colour_mat_
;
if
(
point_mat_
)
delete
point_mat_
;
if
(
normal_mat_
)
delete
normal_mat_
;
delete
depth_tex_
;
delete
colour_tex_
;
if
(
normal_tex_
)
delete
normal_tex_
;
}
// TODO(Nick) Should not need to pass all these pointers to device
__host__
DepthCamera
();
__host__
void
alloc
(
const
DepthCameraParams
&
params
,
bool
withNormals
=
false
);
__host__
void
updateData
(
const
cv
::
Mat
&
depth
,
const
cv
::
Mat
&
rgb
,
cv
::
cuda
::
Stream
&
stream
);
__host__
void
free
();
__host__
void
_computeNormals
(
cudaStream_t
stream
);
cv
::
cuda
::
GpuMat
*
depth_mat_
;
cv
::
cuda
::
GpuMat
*
colour_mat_
;
cv
::
cuda
::
GpuMat
*
point_mat_
;
...
...
@@ -103,9 +53,8 @@ struct DepthCamera {
ftl
::
cuda
::
TextureObject
<
float
>
*
depth_tex_
;
ftl
::
cuda
::
TextureObject
<
uchar4
>
*
colour_tex_
;
ftl
::
cuda
::
TextureObject
<
float4
>
*
normal_tex_
;
//cudaTextureObject_t depth_obj_;
//cudaTextureObject_t colour_obj_;
// This part is sent to device
DepthCameraCUDA
data
;
};
}
...
...
This diff is collapsed.
Click to expand it.
applications/reconstruct/src/depth_camera.cpp
0 → 100644
+
58
−
0
View file @
43f32841
#include
<ftl/depth_camera.hpp>
using
ftl
::
voxhash
::
DepthCamera
;
extern
"C"
void
computeNormals
(
float4
*
d_output
,
float3
*
d_input
,
unsigned
int
width
,
unsigned
int
height
);
extern
"C"
void
convertDepthFloatToCameraSpaceFloat3
(
float3
*
d_output
,
float
*
d_input
,
float4x4
intrinsicsInv
,
unsigned
int
width
,
unsigned
int
height
,
const
DepthCameraData
&
depthCameraData
);
DepthCamera
::
DepthCamera
()
{
depth_mat_
=
nullptr
;
colour_mat_
=
nullptr
;
point_mat_
=
nullptr
;
normal_mat_
=
nullptr
;
depth_tex_
=
nullptr
;
colour_tex_
=
nullptr
;
normal_tex_
=
nullptr
;
}
void
DepthCamera
::
alloc
(
const
DepthCameraParams
&
params
,
bool
withNormals
=
false
)
{
//! todo resizing???
depth_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_32FC1
);
colour_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_8UC4
);
depth_tex_
=
new
ftl
::
cuda
::
TextureObject
<
float
>
((
cv
::
cuda
::
PtrStepSz
<
float
>
)
*
depth_mat_
);
colour_tex_
=
new
ftl
::
cuda
::
TextureObject
<
uchar4
>
((
cv
::
cuda
::
PtrStepSz
<
uchar4
>
)
*
colour_mat_
);
data
.
depth
=
depth_tex_
->
cudaTexture
();
data
.
colour
=
colour_tex_
->
cudaTexture
();
data
.
params
=
params
;
if
(
withNormals
)
{
point_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_32FC3
);
normal_mat_
=
new
cv
::
cuda
::
GpuMat
(
params
.
m_imageHeight
,
params
.
m_imageWidth
,
CV_32FC4
);
normal_tex_
=
new
ftl
::
cuda
::
TextureObject
<
float4
>
((
cv
::
cuda
::
PtrStepSz
<
float4
>
)
*
normal_mat_
);
data
.
normal
=
normal_tex_
->
cudaTexture
();
}
else
{
data
.
normal
=
0
;
}
}
void
DepthCamera
::
free
()
{
if
(
depth_mat_
)
delete
depth_mat_
;
if
(
colour_mat_
)
delete
colour_mat_
;
if
(
point_mat_
)
delete
point_mat_
;
if
(
normal_mat_
)
delete
normal_mat_
;
delete
depth_tex_
;
delete
colour_tex_
;
if
(
normal_tex_
)
delete
normal_tex_
;
}
void
DepthCamera
::
updateData
(
const
cv
::
Mat
&
depth
,
const
cv
::
Mat
&
rgb
,
cv
::
cuda
::
Stream
&
stream
)
{
depth_mat_
->
upload
(
depth
,
stream
);
colour_mat_
->
upload
(
rgb
,
stream
);
if
(
normal_mat_
)
{
_computeNormals
(
cv
::
cuda
::
StreamAccessor
::
getStream
(
stream
));
}
}
void
DepthCamera
::
_computeNormals
(
cudaStream_t
stream
)
{
convertDepthFloatToCameraSpaceFloat3
(
m_data
.
d_depth3
,
m_data
.
d_depth
,
m_params
.
m_intrinsicsInverse
,
m_params
.
m_width
,
m_params
.
m_height
,
cameraData
);
computeNormals
(
m_data
.
d_normals
,
m_data
.
d_depth3
,
m_params
.
m_width
,
m_params
.
m_height
);
}
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