zoukankan      html  css  js  c++  java
  • 二维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!
    "; };
    	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(); // 关闭文件
    }
    

      

  • 相关阅读:
    typeof返回的结果必定是字符串
    coe文件格式
    求余算法的FPGA实现
    dBm
    信噪比
    增益
    总谐波失真THD
    基波与谐波
    Tco时候在干嘛?
    AXI4-Slave自定义IP设计
  • 原文地址:https://www.cnblogs.com/byteHuang/p/8378657.html
Copyright © 2011-2022 走看看