#include "mediapipe/framework/formats/matrix.h"
#include <algorithm>
#include "absl/log/absl_check.h"
#include "mediapipe/framework/port/core_proto_inc.h"
#include "mediapipe/framework/port/logging.h"
#include "mediapipe/framework/port/proto_ns.h"
#include "mediapipe/framework/port/ret_check.h"
namespace mediapipe {
void MatrixDataProtoFromMatrix(const Matrix& matrix, MatrixData* matrix_data) { … }
void MatrixFromMatrixDataProto(const MatrixData& matrix_data, Matrix* matrix) { … }
#if !defined(MEDIAPIPE_MOBILE) && !defined(MEDIAPIPE_LITE) && \
!defined(MEDIAPIPE_PROTO_LITE)
std::string MatrixAsTextProto(const Matrix& matrix) {
MatrixData matrix_data;
MatrixDataProtoFromMatrix(matrix, &matrix_data);
std::string text_proto;
proto_ns::TextFormat::PrintToString(matrix_data, &text_proto);
return text_proto;
}
void MatrixFromTextProto(const std::string& text_proto, Matrix* matrix) {
ABSL_CHECK(matrix);
MatrixData matrix_data;
ABSL_CHECK(proto_ns::TextFormat::ParseFromString(text_proto, &matrix_data));
MatrixFromMatrixDataProto(matrix_data, matrix);
}
#endif
}