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
fa065c4d
Commit
fa065c4d
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Reduce buffer copies by swapping
parent
78c5ed3c
No related branches found
No related tags found
1 merge request
!80
Make capture and compute parallel
Pipeline
#12600
passed
5 years ago
Stage: all
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/rgbd-sources/include/ftl/rgbd/source.hpp
+16
-11
16 additions, 11 deletions
components/rgbd-sources/include/ftl/rgbd/source.hpp
components/rgbd-sources/src/source.cpp
+13
-4
13 additions, 4 deletions
components/rgbd-sources/src/source.cpp
with
29 additions
and
15 deletions
components/rgbd-sources/include/ftl/rgbd/source.hpp
+
16
−
11
View file @
fa065c4d
...
...
@@ -68,15 +68,27 @@ class Source : public ftl::Configurable {
channel_t
getChannel
()
const
{
return
channel_
;
}
/**
* Perform the hardware or virtual frame grab operation.
*/
bool
capture
();
/**
* Between frames, do any required buffer swaps.
*/
void
swap
()
{
if
(
impl_
)
impl_
->
swap
();
}
/**
* Perform the hardware or virtual frame grab operation.
* Do any post-grab processing. This function
* may take considerable time to return, especially for sources requiring
* software stereo correspondance.
*/
bool
compute
(
int
N
=-
1
,
int
B
=-
1
);
/**
* Wrapper grab that performs capture, swap and computation steps in one.
* It is more optimal to perform capture and compute in parallel.
*/
bool
grab
(
int
N
=-
1
,
int
B
=-
1
)
{
bool
c
=
capture
();
swap
();
...
...
@@ -84,16 +96,9 @@ class Source : public ftl::Configurable {
}
/**
* Do any post-grab processing. This function
* may take considerable time to return, especially for sources requiring
* software stereo correspondance. If `process` is not called manually
* after a `grab` and before a `get`, then it will be called automatically
* on first `get`.
*/
//void process();
/**
* Get a copy of both colour and depth frames.
* Get a copy of both colour and depth frames. Note that this does a buffer
* swap rather than a copy, so the parameters should be persistent buffers for
* best performance.
*/
void
getFrames
(
cv
::
Mat
&
c
,
cv
::
Mat
&
d
);
...
...
This diff is collapsed.
Click to expand it.
components/rgbd-sources/src/source.cpp
+
13
−
4
View file @
fa065c4d
...
...
@@ -167,8 +167,16 @@ void Source::getFrames(cv::Mat &rgb, cv::Mat &depth) {
SHARED_LOCK
(
mutex_
,
lk
);
//rgb_.copyTo(rgb);
//depth_.copyTo(depth);
//rgb = rgb_;
//depth = depth_;
cv
::
Mat
tmp
;
tmp
=
rgb
;
rgb
=
rgb_
;
rgb_
=
tmp
;
tmp
=
depth
;
depth
=
depth_
;
depth_
=
tmp
;
}
Eigen
::
Vector4d
Source
::
point
(
uint
ux
,
uint
uy
)
{
...
...
@@ -236,7 +244,7 @@ bool Source::compute(int N, int B) {
return
true
;
}
else
if
(
impl_
&&
impl_
->
compute
(
N
,
B
))
{
timestamp_
=
impl_
->
timestamp_
;
/*
cv::Mat tmp;
cv
::
Mat
tmp
;
rgb_
.
create
(
impl_
->
rgb_
.
size
(),
impl_
->
rgb_
.
type
());
depth_
.
create
(
impl_
->
depth_
.
size
(),
impl_
->
depth_
.
type
());
tmp
=
rgb_
;
...
...
@@ -244,9 +252,10 @@ bool Source::compute(int N, int B) {
impl_
->
rgb_
=
tmp
;
tmp
=
depth_
;
depth_
=
impl_
->
depth_
;
impl_->depth_ = tmp;*/
impl_
->
rgb_
.
copyTo
(
rgb_
);
impl_
->
depth_
.
copyTo
(
depth_
);
impl_
->
depth_
=
tmp
;
//impl_->rgb_.copyTo(rgb_);
//impl_->depth_.copyTo(depth_);
return
true
;
}
return
false
;
...
...
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