Load CSV file as cv::Mat

asked 2014-02-25 10:37:45 -0500

r gravatar image

updated 2014-02-25 10:46:47 -0500

berak gravatar image

I save a cv::Mat as a CSV file which works fine, but when I go to load it and convert it back into a cv::Mat something is being corrupted. When I print out the contents of the cv::Mat they are different from that of the csv file. And when I show the Mat object I get a wide white window.

cv::imwrite("cameraFrame1.jpg", frame);
outFile.open("cameraFrame1.csv");
outFile << cv::format(frame, "CSV") << std::endl;
outFile.close();

...

CvMLData mlData;
mlData.read_csv("cameraFrame1.csv");
const CvMat* tmp = mlData.get_values();
cv::Mat img(tmp, true);
tmp->CvMat::~CvMat();

std::cout << "img: " << img << std::endl;

cv::namedWindow("img");
cv::imshow("img", img);
cv::waitKey(0);
edit retag flag offensive close merge delete