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
185b9d7e
Commit
185b9d7e
authored
5 years ago
by
Sebastian Hahta
Browse files
Options
Downloads
Patches
Plain Diff
updated interface with automatic cpu/gpu transfer
parent
f90f6872
No related branches found
No related tags found
2 merge requests
!105
CUDA optical flow smoothing
,
!103
feature/frame class
Pipeline
#13267
passed
5 years ago
Stage: all
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/rgbd-sources/include/ftl/rgbd/frame.hpp
+28
-25
28 additions, 25 deletions
components/rgbd-sources/include/ftl/rgbd/frame.hpp
components/rgbd-sources/src/stereovideo.cpp
+6
-10
6 additions, 10 deletions
components/rgbd-sources/src/stereovideo.cpp
with
34 additions
and
35 deletions
components/rgbd-sources/include/ftl/rgbd/frame.hpp
+
28
−
25
View file @
185b9d7e
...
...
@@ -27,55 +27,57 @@ public:
return
available_
[
_channelIdx
(
channel
)];
}
/* @brief Get reference to the channel data.
* @param Channel type
* @param Output parameter
* @param User of the method sets data. NOTE: Only works on unused
* channels or if reset() was called previously (TODO).
* @returns True, if output parameter contains valid data
/* @brief get reference to the channel contents
* @param channel type
* @returns const reference to channel data
*
* Methods automatically copy between host/gpu if the data is only available
* in the other. Results are cached.
* in the other. Results are cached. Result is valid only if hasChannel() is
* true.
*/
bool
getChannel
(
const
ftl
::
rgbd
::
channel_t
&
channel
,
cv
::
Mat
&
out
,
bool
set
=
false
)
const
cv
::
Mat
&
getChannel
(
const
ftl
::
rgbd
::
channel_t
&
channel
)
{
auto
idx
=
_channelIdx
(
channel
);
bool
retval
=
available_
[
idx
]
&
mask_host
;
if
(
!
retval
)
if
(
!
(
available_
[
idx
]
&
mask_host
))
{
if
(
available_
[
idx
]
&
mask_gpu
)
{
channels_gpu_
[
idx
].
download
(
channels_host_
[
idx
]);
retval
=
true
;
set
=
true
;
available_
[
idx
]
|=
mask_host
;
}
}
if
(
set
)
{
available_
[
idx
]
|=
mask_host
;
}
return
channels_host_
[
idx
];
}
out
=
channels_host_
[
idx
];
return
retval
;
cv
::
Mat
&
setChannel
(
const
ftl
::
rgbd
::
channel_t
&
channel
)
{
auto
idx
=
_channelIdx
(
channel
);
available_
[
idx
]
=
mask_host
;
return
channels_host_
[
idx
];
}
bool
getChannel
(
const
ftl
::
rgbd
::
channel_t
&
channel
,
cv
::
cuda
::
GpuMat
&
out
,
bool
set
=
false
)
const
cv
::
cuda
::
GpuMat
&
getChannel
Gpu
(
const
ftl
::
rgbd
::
channel_t
&
channel
)
{
auto
idx
=
_channelIdx
(
channel
);
bool
retval
=
available_
[
idx
]
&
mask_gpu
;
if
(
!
retval
)
if
(
!
(
available_
[
idx
]
&
mask_gpu
))
{
if
(
available_
[
idx
]
&
mask_host
)
{
channels_gpu_
[
idx
].
upload
(
channels_host_
[
idx
]);
retval
=
true
;
set
=
true
;
available_
[
idx
]
|=
mask_gpu
;
}
}
if
(
set
)
{
available_
[
idx
]
|=
mask_host
;
}
out
=
channels_gpu_
[
idx
];
return
retval
;
return
channels_gpu_
[
idx
];
}
cv
::
cuda
::
GpuMat
&
setChannelGpu
(
const
ftl
::
rgbd
::
channel_t
&
channel
)
{
auto
idx
=
_channelIdx
(
channel
);
available_
[
idx
]
=
mask_gpu
;
return
channels_gpu_
[
idx
];
}
private
:
...
...
@@ -94,7 +96,8 @@ private:
case
kChanConfidence
:
return
7
;
case
kChanFlow
:
return
8
;
case
kChanEnergy
:
return
9
;
default:
return
0
;
// should not happen (error)
// should not happen (error); returned index is kChanNone
default:
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
components/rgbd-sources/src/stereovideo.cpp
+
6
−
10
View file @
185b9d7e
...
...
@@ -173,9 +173,8 @@ bool StereoVideoSource::capture(int64_t ts) {
bool
StereoVideoSource
::
retrieve
()
{
auto
&
frame
=
frames_
[
0
];
frame
.
reset
();
cv
::
cuda
::
GpuMat
left
,
right
;
frame
.
getChannel
(
ftl
::
rgbd
::
kChanLeft
,
left
,
true
);
frame
.
getChannel
(
ftl
::
rgbd
::
kChanRight
,
right
,
true
);
auto
&
left
=
frame
.
setChannelGpu
(
ftl
::
rgbd
::
kChanLeft
);
auto
&
right
=
frame
.
setChannelGpu
(
ftl
::
rgbd
::
kChanRight
);
lsrc_
->
get
(
left
,
right
,
calib_
,
stream2_
);
#ifdef HAVE_OPTFLOW
...
...
@@ -209,18 +208,15 @@ void StereoVideoSource::swap() {
bool
StereoVideoSource
::
compute
(
int
n
,
int
b
)
{
auto
&
frame
=
frames_
[
1
];
cv
::
cuda
::
GpuMat
left
,
right
,
disp
,
depth
;
frame
.
getChannel
(
ftl
::
rgbd
::
kChanLeft
,
left
);
frame
.
getChannel
(
ftl
::
rgbd
::
kChanRight
,
right
);
auto
&
left
=
frame
.
getChannelGpu
(
ftl
::
rgbd
::
kChanLeft
);
auto
&
right
=
frame
.
getChannelGpu
(
ftl
::
rgbd
::
kChanRight
);
const
ftl
::
rgbd
::
channel_t
chan
=
host_
->
getChannel
();
if
(
left
.
empty
()
||
right
.
empty
())
return
false
;
if
(
chan
==
ftl
::
rgbd
::
kChanDepth
)
{
frame
.
g
etChannel
(
ftl
::
rgbd
::
kChanDepth
,
depth
,
true
);
frame
.
g
etChannel
(
ftl
::
rgbd
::
kChanDisparity
,
disp
,
true
);
auto
&
depth
=
frame
.
s
etChannel
Gpu
(
ftl
::
rgbd
::
kChanDepth
);
auto
&
disp
=
frame
.
s
etChannel
Gpu
(
ftl
::
rgbd
::
kChanDisparity
);
if
(
depth
.
empty
())
depth
=
cv
::
cuda
::
GpuMat
(
left
.
size
(),
CV_32FC1
);
if
(
disp
.
empty
())
disp
=
cv
::
cuda
::
GpuMat
(
left
.
size
(),
CV_32FC1
);
...
...
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