1 | initial version |
you can use plain c++ std lib for this:
#include <fstream>
std::ifstream in("my.txt");
// you did not tell us, what type of data to read, i'll assume float here !
Mat m; // initially empty
// slurp in data, one at a time
for (int i=0; i<238*51; i++)
{
float f;
in >> f;
m.push_back(f);
}
m = m.reshape(1, 238); // finally, reshape to 51x238
2 | No.2 Revision |
you can use plain c++ std lib for this:
#include <fstream>
std::ifstream in("my.txt");
// you did not tell us, what type of data to read, i'll assume float here !
Mat cv::Mat m; // initially empty
// slurp in data, one at a time
for (int i=0; i<238*51; i++)
{
float f;
in >> f;
m.push_back(f);
}
m = m.reshape(1, 238); // finally, reshape to 51x238