Example #1
0
QDomElement Ersky9xInterface::getGeneralDataXML(QDomDocument * qdoc, Ersky9xGeneral * tgen)
{
  QDomElement gd = qdoc->createElement("GENERAL_DATA");
  appendNumberElement(qdoc, &gd, "Version", tgen->myVers, true); // have to write value here
  appendTextElement(qdoc, &gd, "Owner", QString::fromAscii(tgen->ownerName,sizeof(tgen->ownerName)).trimmed());
  appendCDATAElement(qdoc, &gd, "Data", (const char *)tgen,sizeof(Ersky9xGeneral));
  return gd;
}
Example #2
0
QDomElement Ersky9xInterface::getModelDataXML(QDomDocument * qdoc, Ersky9xModelData_v11 * tmod, int modelNum, int mdver)
{
  QDomElement md = qdoc->createElement("MODEL_DATA");
  md.setAttribute("number", modelNum);
  appendNumberElement(qdoc, &md, "Version", mdver, true); // have to write value here
  appendTextElement(qdoc, &md, "Name", QString::fromAscii(tmod->name,sizeof(tmod->name)).trimmed());
  appendCDATAElement(qdoc, &md, "Data", (const char *)tmod,sizeof(Ersky9xModelData_v11));
  return md;
}
Example #3
0
inline void CameraSet<T>::save( const std::string& filename, bool undistort )
{
    // init stuff
    tinyxml2::XMLDocument doc;
    progress<size_t> pb( "CameraSet::save: saving poses ", poseCount() );
    pb.update();

    // add root
    tinyxml2::XMLNode* root = doc.InsertEndChild( doc.NewElement( "CameraCalibration" ) );

    // run over the camers
    tinyxml2::XMLNode* cameras = root->InsertEndChild( doc.NewElement( "Cameras" ) );
    for( auto camIt=m_cameras.begin(); camIt != m_cameras.end(); camIt++ )
    {
        // init camera
        tinyxml2::XMLNode* camera = cameras->InsertEndChild( doc.NewElement( "Camera" ) );

        // add camera properties
        appendTextElement( doc, *camera, std::string("Id"), toString(camIt->second.id) );
        appendTextElement( doc, *camera, std::string("ImageSize"), toString( camIt->second.imageSize ) );
        appendTextElement( doc, *camera, std::string("Intrinsic"), toString( camIt->second.intrinsic ) );
        appendTextElement( doc, *camera, std::string("Distortion"), toString( camIt->second.distortion ) );
        appendTextElement( doc, *camera, std::string("Error"), toString( camIt->second.error ) );

        // run over all its poses and add them
        tinyxml2::XMLNode* poses = camera->InsertEndChild( doc.NewElement( "Poses" ) );
        for( size_t p=0; p<camIt->second.poses.size(); p++ )
        {
            // add the pose
            tinyxml2::XMLNode* pose = poses->InsertEndChild( doc.NewElement( "Pose" ) );

            // pose identification
            appendTextElement( doc, *pose, std::string("Id"), toString(camIt->second.poses[p].id) );
            appendTextElement( doc, *pose, std::string("Name"), camIt->second.poses[p].name );

            // if not rejected, also add the rest
            if( !camIt->second.poses[p].rejected )
            {
                appendTextElement( doc, *pose, std::string("Points2D"), toString( camIt->second.poses[p].points2D ) );
                appendTextElement( doc, *pose, std::string("Points3D"), toString( camIt->second.poses[p].points3D ) );
                appendTextElement( doc, *pose, std::string("PointIndices"), toString( camIt->second.poses[p].pointIndices ) );
                appendTextElement( doc, *pose, std::string("Transformation"), toString( camIt->second.poses[p].transformation ) );
                appendTextElement( doc, *pose, std::string("ProjectedPoints"), toString( camIt->second.poses[p].projected2D ) );

                // check if should undistort
                if( undistort )
                {
                    // get the pose
                    cimg_library::CImg<uint8_t> undistorted;
                    iris::undistort( camIt->second, camIt->second.poses[p], undistorted );

                    // assemble filename
                    std::string imageFileName = filename.substr( 0, filename.find_last_of('.') ) + "-";
                    imageFileName += camIt->second.poses[p].name.substr( 0, camIt->second.poses[p].name.find_last_of('.') ) + "-undistorted.png";
                    undistorted.save_png( imageFileName.c_str() );
                }
            }

            // update progress bar
            pb.next_step();
        }
    }

    // wrap up
    doc.SaveFile( filename.c_str() );
    pb.finish();
}