Ejemplo n.º 1
0
std::vector<CCL_MocapJoint> loadMotionCaptureFromJson(const ci::fs::path &file)
{
  vector<CCL_MocapJoint> mJoints;

  Jzon::Object rootNode;
  Jzon::FileReader::ReadFile(file.string(), rootNode);

  const Jzon::Array &joints = rootNode.Get("joints").AsArray();
  for( Jzon::Array::const_iterator it = joints.begin() ; it != joints.end();++it){
      Jzon::Object joint = (*it).AsObject();
      // name
      string name = joint.Get("name").ToString();

      // xPos
      Jzon::Array xPosList = joint.Get("xPos").AsArray();
      vector<float> xPosVec;
      for( Jzon::Array::iterator itt = xPosList.begin() ; itt != xPosList.end();++itt){
          float pos = stof((*itt).ToString());
          xPosVec.push_back(pos);
      }
      // yPos
      Jzon::Array yPosList = joint.Get("yPos").AsArray();
      vector<float>yPosVec;
      for( Jzon::Array::iterator itt = yPosList.begin() ; itt != yPosList.end();++itt){
          float pos = stof((*itt).ToString());
          yPosVec.push_back(pos);
      }
      // zPos
      Jzon::Array zPosList = joint.Get("zPos").AsArray();
      vector<float> zPosVec;
      for( Jzon::Array::iterator itt = zPosList.begin() ; itt != zPosList.end();++itt){
          float pos = stof((*itt).ToString());
          zPosVec.push_back(pos);
      }


    //  cout << "JOINT NAME:"<<name<<endl;
      CCL_MocapJoint cclJoint = CCL_MocapJoint(name,10);

      cclJoint.xPositions = xPosVec;
      cclJoint.yPositions = yPosVec;
      cclJoint.zPositions = zPosVec;
      cclJoint.loadPositions();


      mJoints.push_back(cclJoint);

  }
/*
  for( int i  = 0 ; i < 10 ; i++) {
      CCL_MocapJoint jointt = mJoints[i];
      for( int j = 0 ; j < 3 ; j++){
          cout << "[" << jointt.jointName << "] (" << jointt.jointPositions[j].x << "," <<jointt.jointPositions[j].y << ","<< jointt.jointPositions[j].z <<")"<< endl;
      }
  }*/

  return mJoints;
};
Ejemplo n.º 2
0
int main(int argc, char* const argv[])
try {
    
    if (argc != 2) {
        std::cout << "Usage: " << argv[0] << " file\n";
        return 1;
    }
    
    const char* path=argv[1];
        
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
    assert(image.get() != 0);
    image->readMetadata();
        
    Jzon::Object root;

    const char*    FS="FS";
    Jzon::Object      fs  ;
    root.Add      (FS,fs) ;
    fileSystemPush(path,root.Get(FS));
    
	Exiv2::ExifData &exifData = image->exifData();
    for ( ExifData::const_iterator i = exifData.begin(); i != exifData.end() ; ++i ) {
        std::string   key ;
        push(objectForKey(i->key(),key,root),key,i);
    }

	Exiv2::IptcData &iptcData = image->iptcData();
    for (Exiv2::IptcData::const_iterator i = iptcData.begin(); i != iptcData.end(); ++i) {
        std::string key ;
        push(objectForKey(i->key(),key,root),key,i);
    }

	Exiv2::XmpData  &xmpData  = image->xmpData();
    for (Exiv2::XmpData::const_iterator i = xmpData.begin(); i != xmpData.end(); ++i) {
        std::string key ;
        push(objectForKey(i->key(),key,root),key,i);
    }
/*
    This is only for testing long paths    
    {
    	ExifData::const_iterator i = exifData.begin();
    	std::string key;
    	push(objectForKey("This.Is.A.Rather.Long.Path.Key",key,root),key,i);
    }
*/        
    Jzon::Writer writer(root,Jzon::StandardFormat);
    writer.Write();
    std::cout << writer.GetResult() << std::endl;
    return 0;
}
        
//catch (std::exception& e) {
//catch (Exiv2::AnyError& e) {
catch (Exiv2::Error& e) {
    std::cout << "Caught Exiv2 exception '" << e.what() << "'\n";
    return -1;
}