yaml-cpp, . ++ , , , - . node , ( ).
, OpenCV, - :
class Matrix {
public:
Matrix(unsigned r, unsigned c, const std::vector<float>& d): rows(r), cols(c), data(d) { }
Matrix(const Matrix&) { }
~Matrix() { }
Matrix& operator = (const Matrix&) { }
private:
unsigned rows, cols;
std::vector<float> data;
};
-
void operator >> (const YAML::Node& node, Matrix& matrix) {
unsigned rows, cols;
std::vector<float> data;
node["rows"] >> rows;
node["cols"] >> cols;
node["data"] >> data;
matrix = Matrix(rows, cols, data);
}
. , ; , YAML::Node. :
std::ifstream fin("monsters.yaml");
YAML::Parser parser(fin);
YAML::Node doc;
parser.GetNextDocument(doc);
Matrix m;
doc["tableCenter"] >> m;
. , dt: f " - float". , , Matrix . ( ), , , . ( , , , .)