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坐标的更多相关文章

  1. 动态创建二维vector数组 C和C++ 及指针与引用的区别

    二维vectorvector<vector <int> > ivec(m ,vector<int>(n));    //m*n的二维vector 动态创建m*n的二 ...

  2. C++-二维vector初始化大小方法-备忘

    来源: C++——二维vector初始化大小方法 1.直接用初始化方法 名字为vec,大小为n*m,初始值为0的二维vector. vector<vector<)); 2.用resize( ...

  3. 二维vector基本使用

    变量声明 vector<vector<int> > 变量名: 添加行 vector<vector<int> > v2d; for(int i=0;i&l ...

  4. 二维vector的使用

    和数组一样,数组有二维的数组,vector也有二维的vector.下面就介绍一下二维vector的使用方法. 一般声明初始化二维vector有三种方法 (1) vector< vector< ...

  5. C#读txt文件并写入二维数组中(txt数据行,列未知)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  6. STL学习二:Vector容器

    1.Vector容器简介 vector是将元素置于一个动态数组中加以管理的容器. vector可以随机存取元素(支持索引值直接存取, 用[]操作符或at()方法,这个等下会详讲). vector尾部添 ...

  7. STL学习系列二:Vector容器

    1.Vector容器简介 vector是将元素置于一个动态数组中加以管理的容器. vector可以随机存取元素(支持索引值直接存取, 用[]操作符或at()方法,这个等下会详讲). vector尾部添 ...

  8. java生成二维码以及读取案例

    今天有时间把二维码这块看了一下,方法有几种,我只是简单的看了一下  google  的  zxing! 很简单的一个,比较适合刚刚学习java的小伙伴哦!也比较适合以前没有接触过和感兴趣的的小伙伴,o ...

  9. C++STL二维vector指定位置排序

    自己一直用vector 二维的存储变量 有时候需要进行排序 在此 为记录一下方法 废话少说直接上代码 #include <QCoreApplication> #include <io ...

随机推荐

  1. Mybatis_映射文件配置

    获取自增主键的值 若数据库支持自动生成主键的字段(比如 MySQL 和 SQL Server),则可以设置 useGeneratedKeys=”true”,然后再把 keyProperty 设置到目标 ...

  2. js打开所在文件夹并选中文件

    该方法只支持IE. var wsh = new ActiveXObject("WSCript.shell");  var src = "/select," + ...

  3. 解决linux下80端口占用问题

    在即安装有tomcat,又安装有nginx的服务器上(典型阿里云驻云java镜像),系统默认配置nginx占用80端口,tomcat占用8080端口. 如果想要便于用户可以直接通过IP或者域名访问到t ...

  4. python -Tkinter 实现一个小计算器功能

    文章来源:http://www.cnblogs.com/Skyyj/p/6618739.html 本代码是基于python 2.7的 如果是对于python3.X  则需要将 tkinter 改为Tk ...

  5. 认识学习MVC这家伙

    通过最近的学习认识,只能感慨这玩意太强大了! 以前看了一些MVC的入门教程,看入门教程我感觉不能去体会它的强大,可以看看它的扩展点,通过扩展点去真正的试着了解它,体会它的强大. 它的验证.模型绑定提供 ...

  6. [Algorithm]排序

    一.排序算法 1.插入排序 1) 直接插入排序:(插入类) 1 void InsertSort( ElemType R[], int n ) 2 { 3 for ( int i = 2; i < ...

  7. "window.location.href"、"location.href"是本页面跳转

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  8. MVC进阶篇(二)—路由机制

    前言 这个东西好像,一般也不经常动,都用默认的即可.由于MVC模式在framework里面的解析机制,区别与webform模式,是采用解析路由机制的url.从来实例化视图列对象,然后对该action进 ...

  9. 1.2、Logistics Regression算法实践

     1.1.Logistics Regression算法实践 有了上篇博客的理论准备后,接下来,我们用以及完成的函数,构建Logistics Regression分类器.我们利用线性可分的数据作为训练样 ...

  10. ssh 远程登录TX2

    TX2 端SSH操作 安装: sudo apt-get install openssh-server 确认sshserver是否启动: ps -e |grep ssh 如果看到sshd那说明ssh-s ...