static Mat imageFromFile(string filePath, cv::Size imgSize)
{
Mat img(imgSize, CV_32F);
std::ifstream file(filePath);
string line;
if (file.is_open())
{
int i = 0;
while (getline(file, line))
{
cout << "\rRow: " << i;
std::vector<string> lineVector = split(line, ",");
int j = 0;
for (auto value = lineVector.begin(); value != lineVector.end(); value++)
img.at<float>(i, j++) = stof(*value);
i++;
}
cout << endl;
file.close();
}
return img;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.