/** * @author JIA Pei * @version 2010-02-07 * @brief Read a file and obtain all annotation data in VO_Shape * @param filename input parameter - which .asf annotation file to read * @param oShape output parameter - save annotation data to AAM shape data structure */ void CAnnotationDBIO::ReadASF( const std::string &filename, VO_Shape& oShape ) { oShape.SetAnnotationFileName(filename); std::fstream fp; fp.open(filename.c_str (), std::ios::in); std::stringstream ss; std::string temp; float tempFloat = 0.0f; // Just for the specific .asf for(unsigned int i = 0; i < 10; i++) //fp >> temp; std::getline(fp, temp); unsigned int NbOfPoints = atoi(temp.c_str ()); oShape.Resize(2, NbOfPoints); // Just for the specific .asf for(unsigned int i = 0; i < 6; i++) //fp >> temp; std::getline(fp, temp); for (unsigned int i = 0; i < NbOfPoints; i++) { fp >> temp >> temp >> temp; // In DTU IMM , x means rows from left to right ss << temp; ss >> tempFloat; ss.clear(); oShape(0, i) = tempFloat; fp >> temp; // In DTU IMM , y means cols from top to bottom ss << temp; ss >> tempFloat; ss.clear(); //fp >> temp; std::getline(fp, temp); // In sum, topleft is (0,0), right bottom is (640,480) oShape(1, i) = tempFloat; } // Just for the specific .asf for(unsigned int i = 0; i < 5; i++) fp >> temp; fp.close ();fp.clear(); }
/** * @author JIA Pei * @version 2010-02-07 * @brief Read a file and obtain all annotation data in VO_Shape * @param filename input parameter, which .pts annotation file to read * @param oShape output parameter, save annotation data to AAM shape data structure */ void CAnnotationDBIO::ReadPTS( const std::string &filename, VO_Shape& oShape) { oShape.SetAnnotationFileName(filename); std::fstream fp; fp.open(filename.c_str (), std::ios::in); std::string temp, oneLine; std::stringstream ss; float tempFloat = 0.0f; do { fp >> temp; }while (temp!="n_points:"); fp >> temp; ss << temp; unsigned int NbOfPoints; ss >> NbOfPoints; ss.clear(); oShape.Resize(2, NbOfPoints); fp >> temp; for (unsigned int i = 0; i < NbOfPoints; i++) { fp >> temp; // x refers to a row from left to right ss << temp; ss >> tempFloat; ss.clear(); oShape(0, i) = tempFloat; fp >> temp; // y refers to a col from top to bottom ss << temp; ss >> tempFloat; ss.clear(); // In sum, topleft is (0,0), right bottom is (720,576) oShape(1, i) = tempFloat; } fp.close ();fp.clear(); }