Skip to content

Instantly share code, notes, and snippets.

@vladiant
Created December 5, 2020 23:24
Show Gist options
  • Save vladiant/99441b1ce3069b61c0e6f0d2b0c2bda4 to your computer and use it in GitHub Desktop.
Save vladiant/99441b1ce3069b61c0e6f0d2b0c2bda4 to your computer and use it in GitHub Desktop.
C++ Opencv load CSV file as cv::Mat
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);
CvMLData mlData;
mlData.read_csv("cameraFrame1.csv");
const CvMat* tmp = mlData.get_values();
cv::Mat img(tmp, true);
// set the image type
img.convertTo(img, CV_8UC3);
// set the image size
cv::resize(img, img, cv::Size(320, 256));
tmp->CvMat::~CvMat();
std::cout << "img: " << img << std::endl;
cv::namedWindow("img");
cv::imshow("img", img);
cv::waitKey(0);
# https://stackoverflow.com/questions/22020548/c-opencv-load-csv-file-as-cvmat
cv::imwrite("cameraFrame1.jpg", frame);
outFile.open("cameraFrame1.csv");
outFile << cv::format(frame, "CSV") << std::endl;
outFile.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment