opencv将Mat数据输出到xls中

来源:互联网 发布:淘宝售后客服消差评 编辑:程序博客网 时间:2024/05/30 04:58

在opencv中将Mat数据放到xls中可以用于调试自己的代码。

首先是文件后缀名不能使xlsx,而是xls

代码如下:(我不会插代码。。)


#include <opencv2\opencv.hpp>
#include <fstream>
using namespace cv;
void main()
{
Mat mat = imread("F:\\biecuo.png");

ofstream Fs("F:\\test.xls");
if (!Fs.is_open())
{
cout << "error!" << endl;
return;
}


int height = M.rows;
int width = M.cols;
for (int i = 0; i<height; i++)
{
for (int j = 0; j<width; j++)
{
Fs << (int)M.ptr<uchar>(i)[j] << '\t';
}
Fs << endl;
}
Fs.close();
}

0 0
原创粉丝点击