bool from_file( const std::string& fname, cv::Mat_<T>& out_mat, std::function< void(const std::string&, const int line) > error_invalid_mat_callback = on_invalid_mat) { bool ret; out_mat.release(); ret = getlines_from_file( fname, [&]( string& line, uint line_nr) { std::vector<T> v = from_string<T,vector>( line); if( v.size()==0 || out_mat.rows != 0 && v.size() != out_mat.cols) { error_invalid_mat_callback(fname, line_nr); ret = false; } else { out_mat.push_back( cv::Mat_<T>(cv::Mat_<T>(v).t())); // not gonna love the MatExpr } }); return ret; }