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
984a790c
Commit
984a790c
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Switch zlib to default compression
parent
86120280
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vision/src/main.cpp
+54
-1
54 additions, 1 deletion
vision/src/main.cpp
vision/src/streamer.cpp
+1
-1
1 addition, 1 deletion
vision/src/streamer.cpp
with
55 additions
and
2 deletions
vision/src/main.cpp
+
54
−
1
View file @
984a790c
...
...
@@ -7,6 +7,7 @@
#include
<glog/logging.h>
#include
<ftl/config.h>
#include
<ctpl_stl.h>
#include
<zlib.h>
#include
<string>
#include
<map>
...
...
@@ -166,6 +167,9 @@ static void run(const string &file) {
Mat
l
,
r
,
disp
;
Mat
pl
,
pdisp
;
vector
<
unsigned
char
>
rgb_buf
;
vector
<
unsigned
char
>
d_buf
;
string
uri
=
string
(
"ftl://utu.fi/"
)
+
(
string
)
config
[
"stream"
][
"name"
]
+
string
(
"/rgb-d"
);
Display
display
(
config
[
"display"
]);
display
.
setCalibration
(
Q_32F
);
...
...
@@ -177,6 +181,7 @@ static void run(const string &file) {
condition_variable
cv
;
int
jobs
=
0
;
// Pipeline for disparity
pool
.
push
([
&
](
int
id
)
{
auto
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
// Read calibrated images.
...
...
@@ -203,6 +208,51 @@ static void run(const string &file) {
LOG
(
INFO
)
<<
"Disparity in "
<<
elapsed
.
count
()
<<
"s"
;
});
// Pipeline for jpeg compression
/*pool.push([&](int id) {
auto start = std::chrono::high_resolution_clock::now();
if (pl.rows != 0) cv::imencode(".jpg", pl, rgb_buf);
unique_lock<mutex> lk(m);
jobs++;
lk.unlock();
cv.notify_one();
std::chrono::duration<double> elapsed =
std::chrono::high_resolution_clock::now() - start;
LOG(INFO) << "JPG in " << elapsed.count() << "s";
});*/
// Pipeline for zlib compression
/*pool.push([&](int id) {
auto start = std::chrono::high_resolution_clock::now();
if (pl.rows != 0) {
d_buf.resize(pdisp.step*pdisp.rows);
z_stream defstream;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
defstream.avail_in = pdisp.step*pdisp.rows;
defstream.next_in = (Bytef *)pdisp.data; // input char array
defstream.avail_out = (uInt)pdisp.step*pdisp.rows; // size of output
defstream.next_out = (Bytef *)d_buf.data(); // output char array
deflateInit(&defstream, Z_BEST_COMPRESSION);
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);
d_buf.resize(defstream.total_out);
}
unique_lock<mutex> lk(m);
jobs++;
lk.unlock();
cv.notify_one();
std::chrono::duration<double> elapsed =
std::chrono::high_resolution_clock::now() - start;
LOG(INFO) << "ZLIB in " << elapsed.count() << "s";
});*/
// Pipeline for stream compression
pool
.
push
([
&
](
int
id
)
{
auto
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
if
(
pl
.
rows
!=
0
)
stream
.
send
(
pl
,
pdisp
);
...
...
@@ -216,15 +266,18 @@ static void run(const string &file) {
LOG
(
INFO
)
<<
"Stream in "
<<
elapsed
.
count
()
<<
"s"
;
});
// Send RGB+Depth images for local rendering
display
.
render
(
l
,
disp
);
display
.
wait
(
1
);
// Wait for both pipelines to complete
unique_lock
<
mutex
>
lk
(
m
);
cv
.
wait
(
lk
,
[
&
jobs
]{
return
jobs
==
2
;});
// Store previous frame for next stage compression
l
.
copyTo
(
pl
);
disp
.
copyTo
(
pdisp
);
//net.publish(uri, rgb_buf, d_buf);
}
}
...
...
This diff is collapsed.
Click to expand it.
vision/src/streamer.cpp
+
1
−
1
View file @
984a790c
...
...
@@ -35,7 +35,7 @@ void Streamer::send(const Mat &rgb, const Mat &depth) {
defstream
.
avail_out
=
(
uInt
)
depth
.
step
*
depth
.
rows
;
// size of output
defstream
.
next_out
=
(
Bytef
*
)
d_buf
.
data
();
// output char array
deflateInit
(
&
defstream
,
Z_
BES
T_COMPRESSION
);
deflateInit
(
&
defstream
,
Z_
DEFAUL
T_COMPRESSION
);
deflate
(
&
defstream
,
Z_FINISH
);
deflateEnd
(
&
defstream
);
...
...
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