输入数据"data.txt"
数据格式如下:
123 234
123 34
131 546
123 767
程序代码
#include <iostream>
#include <fstream>
#include <opencv2/opencv.hpp>using namespace std;
using namespace cv;int main()
{ifstream fin;vector<Point2d> pointset;Point2d pts;double temp_x = 0, temp_y = 0;fin.open("data.txt");//!fin.eof() 用来控制什么时候读取终止for (int i = 0; !fin.eof(); i++){//读取txt文件的坐标值fin >> temp_x >> temp_y;pts.x = temp_x;pts.y = temp_y;pointset.push_back(pts);}for (int i = 0; i < pointset.size(); i++){cout << "(" << pointset.at(i).x << " , " << pointset.at(i).y << ")" << endl;}fin.close();system("pause");
}
输出结果
转载自:
博主:rishown
博文地址:https://blog.csdn.net/rishown/article/details/79738560
来源:CSDN
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态