七月cv_作业1:读入文本数字图像

给一张数字图
00000000000000011000000000000000
00000000000111111110000000000000
00000000001111111111100000000000
00000000001111111111110000000000
00000000011111111111111000000000
00000000011111100011111000000000
00000000111110000001111000000000
00000000111110000001111100000000
00000000111110000000111110000000
00000001111110000000111110000000
00000001111110000000011111000000
00000001111110000000001111000000
00000001111110000000001111100000
00000001111100000000001111000000
00000001111000000000001111000000
00000001111000000000001111000000
00000001111000000000000111000000
00000000111100000000000111000000
00000000111100000000000111000000
00000000111100000000000111000000
00000001111000000000011110000000
00000001111000000000011110000000
00000000111000000000011110000000
00000000111110000011111110000000
00000000111110001111111100000000
00000000111111111111111000000000
00000000011111111111111000000000
00000000111111111111100000000000
00000000011111111111000000000000
00000000001111111000000000000000
00000000001111100000000000000000
00000000000100000000000000000000

用cpp读入:
代码

#include<iostream>
#include<fstream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;

int main() {
	string path_to_read = "0.txt";
	fstream indata(path_to_read);
	string s;
	//while (indata >> s) {
	while(getline(indata,s)){
		cout << "this is s:" << s << endl;
	}
	//system(pause);
	//cvWaitKey();
	system("pause");
	return 0;
}

结果如下:
在这里插入图片描述

发布了46 篇原创文章 · 获赞 0 · 访问量 836

猜你喜欢

转载自blog.csdn.net/github_38148039/article/details/103889258