您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

OpenCVcv::Mat中的数据写入txt文件中

2025/10/11 7:00:06发布24次查看
这篇文章主要介绍了opencvcv::mat中的数据按行列写入txt文件中,需要的朋友可以参考下
在使用opencv进行图像处理的过程中,经常会涉及到将文件中的数据读入到cv::mat中,或者将cv::mat中的数据写入到txt文件中。
下面就介绍一种我常用的将cv::mat中的数据写入到txt文件中的方法,具体见代码:
void writemattofile(cv::mat& m, const char* filename) { std::ofstream fout(filename); if (!fout) { std::cout << "file not opened" << std::endl; return; } for (int i = 0; i<m.rows; i++) { for (int j = 0; j<m.cols; j++) { fout << m.at<float>(i, j) << "\t"; } fout << std::endl; } fout.close(); }
相关推荐:
opencv cv.mat与.txt文件数据的读写操作
以上就是opencvcv::mat中的数据写入txt文件中的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product