二维vector容器读取txt坐标
template <class vector>
struct HeadLocation{
vector x;
vector y;
}; vector<HeadLocation<int> > gt_loc_; //二维vector容器 void ReadLocationFromTextFile(const string filename) {
cout << "Opening file " << filename << endl;
ifstream infile(filename.c_str());
if (!infile){ printf("不存在此文本文件!"); };
int num_crowd;
infile >> num_crowd;
if (num_crowd <= 0){ cout << "Number of crowd must be positive!\n"; };
gt_loc_.clear(); //size = 0, capicity =?
gt_loc_.resize(num_crowd); //size = num_crowd(行) for (int i = 0; i < num_crowd; i++) {
/*HeadLocation<float> location_t;
HeadLocation<int> location(location_t.begin(), location_t.end());*/
HeadLocation<int> location;
infile >> location.x >> location.y; for (int j = 0; j < 3; ++j) {
location.x = (location.x - 1) / 2;
location.y = (location.y - 1) / 2;
}
gt_loc_[i] = location;
}
infile.close(); // 关闭文件
}
二维vector容器读取txt坐标的更多相关文章
- 动态创建二维vector数组 C和C++ 及指针与引用的区别
二维vectorvector<vector <int> > ivec(m ,vector<int>(n)); //m*n的二维vector 动态创建m*n的二 ...
- C++-二维vector初始化大小方法-备忘
来源: C++——二维vector初始化大小方法 1.直接用初始化方法 名字为vec,大小为n*m,初始值为0的二维vector. vector<vector<)); 2.用resize( ...
- 二维vector基本使用
变量声明 vector<vector<int> > 变量名: 添加行 vector<vector<int> > v2d; for(int i=0;i&l ...
- 二维vector的使用
和数组一样,数组有二维的数组,vector也有二维的vector.下面就介绍一下二维vector的使用方法. 一般声明初始化二维vector有三种方法 (1) vector< vector< ...
- C#读txt文件并写入二维数组中(txt数据行,列未知)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- STL学习二:Vector容器
1.Vector容器简介 vector是将元素置于一个动态数组中加以管理的容器. vector可以随机存取元素(支持索引值直接存取, 用[]操作符或at()方法,这个等下会详讲). vector尾部添 ...
- STL学习系列二:Vector容器
1.Vector容器简介 vector是将元素置于一个动态数组中加以管理的容器. vector可以随机存取元素(支持索引值直接存取, 用[]操作符或at()方法,这个等下会详讲). vector尾部添 ...
- java生成二维码以及读取案例
今天有时间把二维码这块看了一下,方法有几种,我只是简单的看了一下 google 的 zxing! 很简单的一个,比较适合刚刚学习java的小伙伴哦!也比较适合以前没有接触过和感兴趣的的小伙伴,o ...
- C++STL二维vector指定位置排序
自己一直用vector 二维的存储变量 有时候需要进行排序 在此 为记录一下方法 废话少说直接上代码 #include <QCoreApplication> #include <io ...
随机推荐
- httpd和apache的区别
今天要配置集成服务器环境 apache + tomcat + php + jsp + mysql + sqlserver 去下载apache 发现有: apache_2.2.14-win32-x86 ...
- Git代码冲突常见解决方法
在发布这个配置文件的时候,会发生代码冲突: error: Your local changes to the following files would be overwritten by merge ...
- Python Lambda 的简单用法
下面代码简单举例介绍以下 lambda的用法. from functools import reduce #1 python lambda会创建一个函数对象,但不会把这个函数对象赋给一个标识符,而de ...
- poj2299 Ultra-QuickSort(线段树求逆序对)
Description In this problem, you have to analyze a particular sorting algorithm. The algorithm proce ...
- MongoDB整理笔记の体系架构
MongoDB 是一个可移植的数据库,它在流行的每一个平台上都可以使用,即所谓的跨平台特性. 一个运行着的MongoDB 数据库就可以看成是一个MongoDB Server,该Server 由实例和数 ...
- 尝鲜.net core2.1 ——编写一个global tool
本文内容参考微软工程师Nate McMaster的博文.NET Core 2.1 Global Tools 用过npm开发都知道,npm包都可以以全局的方式安装,例如安装一个http-server服务 ...
- arcgis for android常见问题回答
Q:arcgis for android最新版本是多少?(2014-7-18) Arcgis for android 10.2.3 sdk 百度盘下载地址:http://pan.baidu.com/s ...
- ubuntu14.10,安装ksnapshot(截图软件)
Linux:ubuntu14.10 ubuntu软件中心对它的描述:KSnapshot captures images of the screen. It can capture the whole ...
- 用C语言构建一个可执行程序的流程
1.流程图 从用C语言写源代码,然后经过编译器.连接器到最终可执行程序的流程图大致如下图所示. 2.编译流程 首先,我们先用C语言把源代码写好,然后交给C语言编译器.C语言编译器内部分为前端和后端. ...
- PHP7 - MongoDB Driver 使用心得
php7 只能使用Mongodb driver来驱动mongodb. 使用Mongodb Driver连接数据库 刚开始使用Mongodb Driver的时候我是拒绝的.查看官方文档只看到一排的类和不 ...