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(); // 关闭文件
}