void SaveDepthPNG(const cv::Mat_<float> depth, std::string& depth_png_path)
{
std::vector<int> compression_params;
compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
compression_params.push_back(0);
compression_params.push_back(cv::IMWRITE_PNG_STRATEGY);
compression_params.push_back(cv::IMWRITE_PNG_STRATEGY_DEFAULT);
cv::Mat_<float> color_depth;
double min;
double max;
cv::minMaxIdx(depth, &min, &max);
cv::Mat adjMap;
float scale = 255 / (max - min);
depth.convertTo(adjMap, CV_8UC1, scale, -min * scale);
cv::Mat falseColorsMap;
cv::applyColorMap(adjMap, falseColorsMap, cv::COLORMAP_JET);
cv::imwrite(depth_png_path, falseColorsMap, compression_params);
}
|