最近参加一个比赛,提供了一个CSV文件,内容如下
参考博客 https://blog.csdn.net/u013232740/article/details/50828062
由于这里的数据都比较规整,没有无效字符等,于是照着博客改写了一下,达到了我读数据的目的
这里把读到的数据拿出来用于图片标记,其实就是把图片里面所需要的ROI框出来
#include<iostream>
#include"opencv2/opencv.hpp"
#include<fstream> // for ifstream
#include<vector> // for vector
using namespace std;
using namespace cv;
struct Coordinate
{
int x;
int y;
int w;
int h;
};
int main()
{
// ont statements
ifstream _csvInput("C:\\Users\\Administrator\\Desktop\\卡口\\卡口图片打标\\train_b.csv");
// or two statements by using .open("path")
string _Oneline;
vector<string> _lineOfstr; // 声明一个字符串向量用于存放图片ID和打标数据
while (getline(_csvInput, _Oneline)) // 整行读取,换行符“\n”区分,遇到文件尾标志eof终止读取
{
istringstream _Readstr(_Oneline); // 将整行字符串_Oneli