Esempio n. 1
0
 void saveToXML() {
     xml.clear();
     xml.addChild("SKY");
     xml.setTo("SKY");
     
     for (auto it = stars.begin(); it != stars.end(); it++) {
         ofVec2f p = it->getPosition();
         int m = it->getMagnitude();
         int id = it->getId();
         
         ofXml star;
         star.addChild("STAR");
         star.setTo("STAR");
         star.addChild("POSITION");
         star.setTo("POSITION");
         star.addValue("X", p.x);
         star.addValue("Y", p.y);
         star.setTo("../");
         star.addValue("MAGNITUDE", m);
         star.addValue("ID", id);
         
         xml.addXml(star);
     }
     xml.save("mySettings.xml");
 }
void KinectV2Classifier::setLearnXml(ofXml &xml)
{
    // first save the classifier
    if (trained) {
        svm.saveModel(ofToDataPath("svmModel.dat"));
    }
    
    // event-parameter mappings
    xml.addChild("LearnInfo");
    xml.setTo("LearnInfo");
    
    // classes
    xml.addChild("Classes");
    xml.setTo("Classes");
    for (int i=0; i<classes.size(); i++) {
        ofXml xml_;
        xml_.addChild("Class");
        xml_.setTo("Class");
        xml_.addValue("Name", classes[i]);
        xml.addXml(xml_);
    }
    xml.setToParent();
    
    // ranges
    xml.addChild("Ranges");
    xml.setTo("Ranges");
    for (int i=0; i<min.size(); i++) {
        ofXml xml_;
        xml_.addChild("Joint");
        xml_.setTo("Joint");
        xml_.addValue("Min", min[i]);
        xml_.addValue("Max", max[i]);
        xml.addXml(xml_);
    }
    xml.setToParent();
    
    vector<vector<float> > & entries = data.getEntries();
    if (entries.size() > 0) {
        xml.addChild("Training");
        xml.setTo("Training");
        for (int i = 0; i < entries.size(); i++) {
            vector<string> featureStringV;
            for (int f=1; f<entries[i].size(); f++) {
                featureStringV.push_back(ofToString(entries[i][f]));
            }
            string featureString = ofJoinString(featureStringV, ",");
            double label = entries[i][0];
            ofXml xml_;
            xml_.addChild("Entry");
            xml_.setTo("Entry");
            xml_.addValue("Label", label);
            xml_.addValue("Features", featureString);
            xml.addXml(xml_);
        }
        xml.setToParent();
    }
    
    if (trained) {
        xml.addChild("Model");
        xml.setTo("Model");
        xml.addValue("Path", ofToDataPath("svmModel.dat"));
        xml.setToParent();
    }
    
    xml.setToParent();
}