From ecc53aa0361312d1deea6090ff3ca1db44c45b7c Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sat, 13 Apr 2019 10:49:09 +0300 Subject: [PATCH] Switch to zlib level 4 compression to balance speed on my laptop --- reconstruct/src/main.cpp | 4 ++++ vision/src/streamer.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/reconstruct/src/main.cpp b/reconstruct/src/main.cpp index 38707af3f..4fa5cbcd1 100644 --- a/reconstruct/src/main.cpp +++ b/reconstruct/src/main.cpp @@ -7,6 +7,7 @@ #include <glog/logging.h> #include <ftl/config.h> #include <zlib.h> +// #include <lz4.h> #include <string> #include <map> @@ -147,6 +148,9 @@ static void run(const string &file) { inflateInit(&infstream); inflate(&infstream, Z_NO_FLUSH); inflateEnd(&infstream); + + //LZ4_decompress_safe((char*)d.data(), (char*)depth.data, d.size(), depth.step*depth.rows); + //cv::imdecode(d, cv::IMREAD_GRAYSCALE, &depth); //depth.convertTo(depth, CV_32FC1); //, 1.0f/16.0f); //, 1.0f/256.0f); }); diff --git a/vision/src/streamer.cpp b/vision/src/streamer.cpp index 8c359ad59..8a346d38b 100644 --- a/vision/src/streamer.cpp +++ b/vision/src/streamer.cpp @@ -2,6 +2,7 @@ #include <ftl/streamer.hpp> #include <vector> #include <zlib.h> +// #include <lz4.h> using ftl::Streamer; using ftl::net::Universe; @@ -35,11 +36,17 @@ 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_DEFAULT_COMPRESSION); + deflateInit(&defstream, 4); // Z_DEFAULT_COMPRESSION deflate(&defstream, Z_FINISH); deflateEnd(&defstream); d_buf.resize(defstream.total_out); + + // LZ4 Version + // d_buf.resize(LZ4_compressBound(depth.step*depth.rows)); + // int s = LZ4_compress_default((char*)depth.data, (char*)d_buf.data(), depth.step*depth.rows, d_buf.size()); + // d_buf.resize(s); + //Mat d2; //depth.convertTo(d2, CV_16UC1, 256); //cv::imencode(".png", depth, d_buf); -- GitLab