51 ADEBUG <<
"procing compressed";
52 auto compressed_image = image_pool_->GetObject();
53 compressed_image->mutable_header()->CopyFrom(image->header());
54 compressed_image->set_frame_id(image->frame_id());
55 compressed_image->set_measurement_time(image->measurement_time());
56 compressed_image->set_format(image->encoding() +
"; jpeg compressed bgr8");
58 std::vector<int> params;
60 params[0] = cv::IMWRITE_JPEG_QUALITY;
64 cv::Mat mat_image(image->height(), image->width(), CV_8UC3,
65 const_cast<char*
>(image->data().data()), image->step());
67 cv::cvtColor(mat_image, tmp_mat, cv::COLOR_RGB2BGR);
68 std::vector<uint8_t> compress_buffer;
69 if (!cv::imencode(
".jpg", tmp_mat, compress_buffer, params)) {
70 AERROR <<
"cv::imencode (jpeg) failed on input image";
73 compressed_image->set_data(compress_buffer.data(), compress_buffer.size());
74 writer_->Write(compressed_image);
75 }
catch (std::exception& e) {
76 AERROR <<
"cv::imencode (jpeg) exception :" << e.what();