17 bool ReadMatrixXdFromBINFile(FILE *file, Eigen::MatrixXd &mat) {
19 if (fread(&rows,
sizeof(uint32_t), 1, file) < 1) {
23 if (fread(&cols,
sizeof(uint32_t), 1, file) < 1) {
27 mat.resize(rows, cols);
28 if (fread(mat.data(),
sizeof(
double), rows * cols, file) < rows * cols) {
35 bool WriteMatrixXdToBINFile(FILE *file,
const Eigen::MatrixXd &mat) {
36 uint32_t rows = (uint32_t)mat.rows();
37 uint32_t cols = (uint32_t)mat.cols();
38 if (fwrite(&rows,
sizeof(uint32_t), 1, file) < 1) {
42 if (fwrite(&cols,
sizeof(uint32_t), 1, file) < 1) {
46 if (fwrite(mat.data(),
sizeof(
double), rows * cols, file) < rows * cols) {
71 "Read BIN failed: unable to open file: {}",
filename);
74 bool success = ReadMatrixXdFromBINFile(fid, feature.
data_);
84 "Write BIN failed: unable to open file: {}",
filename);
87 bool success = WriteMatrixXdToBINFile(fid, feature.
data_);
Class to store featrues for registration.
Eigen::MatrixXd data_
Data buffer storing features.
bool ReadFeature(const std::string &filename, utility::Feature &feature)
bool WriteFeatureToBIN(const std::string &filename, const utility::Feature &feature)
bool WriteFeature(const std::string &filename, const utility::Feature &feature)
bool ReadFeatureFromBIN(const std::string &filename, utility::Feature &feature)
FILE * FOpen(const std::string &filename, const std::string &mode)
Generic file read and write utility for python interface.