8#include <RobotsIO/Utils/DepthToFile.h>
10#include <opencv2/core/eigen.hpp>
17bool RobotsIO::Utils::depth_to_file(
const std::string& output_path,
const cv::Mat& depth)
19 const std::string log_name =
"RobotsIO::Utils::depth_to_file";
23 if ((out = std::fopen(output_path.c_str(),
"wb")) ==
nullptr)
25 std::cout << log_name <<
"Error: cannot open output file " + output_path << std::endl;
33 if (std::fwrite(dims,
sizeof(dims), 1, out) != 1)
35 std::cout << log_name <<
"Error: cannot write image size to " + output_path << std::endl;
42 if (std::fwrite(depth.data,
sizeof(
float), dims[0] * dims[1], out) != dims[0] * dims[1])
44 std::cout << log_name <<
"Error: cannot write image data to " + output_path << std::endl;
57bool RobotsIO::Utils::depth_to_file(
const std::string& output_path,
const MatrixXf& depth)
60 cv::eigen2cv(depth, depth_cv);
61 return RobotsIO::Utils::depth_to_file(output_path, depth_cv);