Skip to content
Snippets Groups Projects
Commit 0e5bf6d1 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Back to PNG with some fixes to make quality apparently equal to zlib (should be the same)

parent ecc53aa0
No related branches found
No related tags found
No related merge requests found
......@@ -132,9 +132,9 @@ static void run(const string &file) {
cv::imdecode(jpg, cv::IMREAD_COLOR, &rgb);
//LOG(INFO) << "Received JPG : " << rgb.cols;
depth = Mat(rgb.size(), CV_32FC1);
depth = Mat(rgb.size(), CV_16UC1);
z_stream infstream;
/*z_stream infstream;
infstream.zalloc = Z_NULL;
infstream.zfree = Z_NULL;
infstream.opaque = Z_NULL;
......@@ -147,12 +147,12 @@ static void run(const string &file) {
// the actual DE-compression work.
inflateInit(&infstream);
inflate(&infstream, Z_NO_FLUSH);
inflateEnd(&infstream);
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);
cv::imdecode(d, cv::IMREAD_UNCHANGED, &depth);
depth.convertTo(depth, CV_32FC1, 1.0f/256.0f); //, 1.0f/16.0f); //, 1.0f/256.0f);
});
while (disp.active()) {
......
......@@ -20,27 +20,39 @@ Streamer::~Streamer() {
}
//static Mat last;
void Streamer::send(const Mat &rgb, const Mat &depth) {
// Compress the rgb as jpeg.
vector<unsigned char> rgb_buf;
cv::imencode(".jpg", rgb, rgb_buf);
Mat d2;
depth.convertTo(d2, CV_16UC1, 256);
//if (last.rows == 0) d2.copyTo(last);
//Mat ddepth;
//ddepth = d2 - last;
vector<unsigned char> d_buf;
d_buf.resize(depth.step*depth.rows);
/*d_buf.resize(d2.step*d2.rows);
z_stream defstream;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
defstream.avail_in = depth.step*depth.rows;
defstream.next_in = (Bytef *)depth.data; // input char array
defstream.avail_out = (uInt)depth.step*depth.rows; // size of output
defstream.avail_in = d2.step*d2.rows;
defstream.next_in = (Bytef *)d2.data; // input char array
defstream.avail_out = (uInt)d2.step*d2.rows; // size of output
defstream.next_out = (Bytef *)d_buf.data(); // output char array
deflateInit(&defstream, 4); // Z_DEFAULT_COMPRESSION
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);
d_buf.resize(defstream.total_out);
d2.copyTo(last);
d_buf.resize(defstream.total_out);*/
// LZ4 Version
// d_buf.resize(LZ4_compressBound(depth.step*depth.rows));
......@@ -49,7 +61,7 @@ void Streamer::send(const Mat &rgb, const Mat &depth) {
//Mat d2;
//depth.convertTo(d2, CV_16UC1, 256);
//cv::imencode(".png", depth, d_buf);
cv::imencode(".png", d2, d_buf);
LOG(INFO) << "Depth Size = " << ((float)d_buf.size() / (1024.0f*1024.0f));
net_.publish(uri_, rgb_buf, d_buf);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment