void readMatrix(FileStorage& input_file, const std::string& name, cv::Mat& matrix) { FileNode node = input_file[name]; CvMat* m; m = (CvMat*)node.readObj(); ntk_throw_exception_if(!m, std::string("Could not read field ") + name + " from yml file."); matrix = m; }
void read_from_yaml(FileNode node, cv::Rect& r) { CvMat* c_m; c_m = (CvMat*)node.readObj(); ntk_throw_exception_if(!c_m, std::string("Could not read field ") + node.name() + " from yml file."); cv::Mat1f m (c_m); ntk_assert(m.cols == 4, "Bad Rect."); r = cv::Rect(m(0,0), m(0,1), m(0,2), m(0,3)); }
void read_from_yaml(FileNode node, cv::Vec2f& v) { CvMat* c_m; c_m = (CvMat*)node.readObj(); ntk_throw_exception_if(!c_m, std::string("Could not read field ") + node.name() + " from yml file."); cv::Mat1f m (c_m); ntk_assert(m.cols == 2, "Bad vector."); std::copy(m.ptr<float>(), m.ptr<float>()+2, &v[0]); }
//reads matrix from yml file void readMatrix(FileStorage& input_file, const std::string& name, cv::Mat& matrix) { FileNode node = input_file[name]; CvMat* m; m = (CvMat*)node.readObj(); if(!m) cerr << "Could not read field " << name << " from yml file." << endl; matrix = m; }