diff --git a/reconstruct/src/main.cpp b/reconstruct/src/main.cpp index 4fa5cbcd124a0f9f334e38b0237f911bcab34ced..03571248549b089adf324a54f059ef0923ba7795 100644 --- a/reconstruct/src/main.cpp +++ b/reconstruct/src/main.cpp @@ -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()) { diff --git a/vision/src/streamer.cpp b/vision/src/streamer.cpp index 8a346d38b55cd5af2b81dfaa947bd678d6afd5ac..47c7f71222960ce9673b42f7c65b5388b3b7b8bd 100644 --- a/vision/src/streamer.cpp +++ b/vision/src/streamer.cpp @@ -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);