Created
December 5, 2020 23:24
-
-
Save vladiant/99441b1ce3069b61c0e6f0d2b0c2bda4 to your computer and use it in GitHub Desktop.
C++ Opencv load CSV file as cv::Mat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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