Ejemplo n.º 1
0
CSVData::CSVData(const char *filename)
{
  fstream input(filename);
  string header, line, joint, tmp;
  Column column;
  
  // parse header
  getline(input, header);
  replace(header.begin(), header.end(), ',', ' ');
  stringstream ss(header);
  ss >> joint;
  while(ss >> joint){
    cout << joint << endl;
    column.push_back(make_pair(joint, new vector<XnSkeletonJointTransformation>));
  }
  
  clx::char_separator<char> sep(',');
  clx::table<double> table(input, clx::create_tokenizer<double>(sep));
  for (size_t i = 0; i < table.size(); i++){
    vector<double>::iterator eit = table[i].begin();
    eit++; // skip frame column;
      
    Column::iterator cit;
    for(cit = column.begin(); cit != column.end(); cit++){
      XnSkeletonJointTransformation t;
      
      XnSkeletonJointPosition *pos = &t.position;
      pos->fConfidence = *eit++;
      pos->position.X = *eit++;
      pos->position.Y = *eit++;
      pos->position.Z = *eit++;

      XnSkeletonJointOrientation *ori = &t.orientation;
      ori->fConfidence = *eit++;
      for(int j=0; j < 9; j++) 
	ori->orientation.elements[j] = *eit++;
      
      cit->second->push_back(t);
    }
  }

  Column::iterator it;
  for(it = column.begin(); it != column.end(); it++){
    data[it->first] = it->second;
  }
}
Ejemplo n.º 2
0
EditableDenseThreeDimensionalModel::Column
EditableDenseThreeDimensionalModel::expandAndRetrieve(size_t index) const
{
    // See comment above m_trunc declaration in header

    assert(index < m_data.size());
    Column c = m_data.at(index);
    if (index == 0) {
        return c;
    }
    int trunc = (int)m_trunc[index];
    if (trunc == 0) {
        return c;
    }
    bool top = true;
    int tdist = trunc;
    if (trunc < 0) { top = false; tdist = -trunc; }
    Column p = expandAndRetrieve(index - tdist);
    int psize = p.size(), csize = c.size();
    if (psize != m_yBinCount) {
        std::cerr << "WARNING: EditableDenseThreeDimensionalModel::expandAndRetrieve: Trying to expand from incorrectly sized column" << std::endl;
    }
    if (top) {
        for (int i = csize; i < psize; ++i) {
            c.push_back(p.at(i));
        }
    } else {
        // push_front is very slow on QVector -- but not enough to
        // make it desirable to choose a different container, since
        // QVector has all the other advantages for us.  easier to
        // write the whole array out to a new vector
        Column cc(psize);
        for (int i = 0; i < psize - csize; ++i) {
            cc[i] = p.at(i);
        }
        for (int i = 0; i < csize; ++i) {
            cc[i + (psize - csize)] = c.at(i);
        }
        return cc;
    }
    return c;
}