使用CSV文件去读图像和标签
2013-11-05 13:53
309 查看
//使用CSV文件去读图像和标签,主要使用stringstream和getline方法 staticvoid read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator =';') { std::ifstream file(filename.c_str(), ifstream::in); if (!file) { string error_message ="No valid input file was given, please check the given filename."; CV_Error(CV_StsBadArg, error_message); } string line, path, classlabel; while (getline(file, line)) { stringstream liness(line); getline(liness, path, separator); getline(liness, classlabel); if(!path.empty()&&!classlabel.empty()) { images.push_back(imread(path, 0)); labels.push_back(atoi(classlabel.c_str())); } } }
相关文章推荐
- Web 端 js 导出csv文件(使用a标签)
- Web 端 js 导出csv文件(使用a标签)
- Web 端 js 导出csv文件(使用a标签)
- Web 端 js 导出csv文件(使用a标签)
- Web 端 js 导出csv文件(使用a标签)
- Web 端 js 导出csv文件(使用a标签)
- Web 端 js 导出csv文件(使用a标签)
- validation.xml验证文件的配置 struts标签使用举例--logic篇
- 使用<context:property-placeholder>标签导入多个properties文件
- 使用<img>标签加载php文件,记录页面访问讯息
- 使用Phoenix 导出csv文件,使用table方式
- 在 Laravel 5 中使用 Laravel Excel 实现 Excel/CSV 文件导入导出功能
- 在 Laravel 5 中使用 Laravel Excel 实现 Excel/CSV 文件导入导出功能
- C++builder 使用cximage对图像文件进行操作
- shiro使用经验总结:【同时实现url和按钮的拦截,只能用配置文件。不需要用注解!!!已多次测试=@RequiresPermissions不能拦截url直接访问。只能拦截标签(鸡肋,不要用!!)
- spring配置文件<import>标签中使用${}占位符获得配置文件的属性值
- JMeter 压力测试使用函数和 CSV 文件参数化 json 数据
- 闲谈(一) Java 使用 Excle 和 CSV 文件
- 使用SQL*Loader将CSV文件数据导入ORACLE数据表
- 将标签文件打包为jar包提供给jsp使用