void PhotoTexturingWidget::bakeTextures(){ FilterParameterSet combineParamSet = loadDefaultBakeSettings(); //creating template name for baked texture file QFileInfo fi = QFileInfo(mesh->fileName.c_str()); QString bTextureFile = fi.baseName()+"_baked.png"; if (QFile(bTextureFile).exists()){ int count = 1; while(QFile(bTextureFile).exists()){ bTextureFile = fi.baseName()+"_baked_"; int max = 1000; while(count<max){ bTextureFile+="0"; max/=10; } bTextureFile+=QString::number(count)+".png"; count++; } } combineParamSet.addString(PhotoTexturer::BAKE_MERGED_TEXTURE,bTextureFile,"Merged Texture Filename:",""); GenericParamDialog ad(this,&combineParamSet,"Texture Baking Parameters"); int result=ad.exec(); int textureId =0; if (result == 1){ saveDefaultBakeSettings(combineParamSet); textureId = photoTexturer->bakeTextures(mesh,&combineParamSet); } update(); updateGLAreaTextures(); }
// Core Function doing the actual mesh processing. bool RangeMapPlugin::applyFilter(QAction *filter, MeshDocument &m, FilterParameterSet & par, vcg::CallBackPos *cb) { CMeshO::FaceIterator fi; switch(ID(filter)) { case FP_SELECTBYANGLE : { bool usecam = par.getBool("usecamera"); Point3f viewpoint = par.getPoint3f("viewpoint"); // if usecamera but mesh does not have one if( usecam && !m.mm()->hasDataMask(MeshModel::MM_CAMERA) ) { errorMessage = "Mesh has not a camera that can be used to compute view direction. Please set a view direction."; // text return false; } if(usecam) { viewpoint = m.mm()->cm.shot.GetViewPoint(); } // angle threshold in radians float limit = cos( math::ToRad(par.getDynamicFloat("anglelimit")) ); Point3f viewray; for(fi=m.mm()->cm.face.begin();fi!=m.mm()->cm.face.end();++fi) if(!(*fi).IsD()) { viewray = viewpoint - Barycenter(*fi); viewray.Normalize(); if((viewray.dot((*fi).N().Normalize())) < limit) fi->SetS(); } } break; } return true; }
// The Real Core Function doing the actual mesh processing. // Move Vertex of a random quantity bool SlidingCurvaturePlugin::applyFilter(QAction *filter, MeshModel &m, FilterParameterSet & par, vcg::CallBackPos *cb) { if( ID(filter)== FP_COMPUTE_PRINC_CURV_DIR_FROM_SLIDING){ vcg::Histogramf hi; vcg::CurvatureFromSliding<CMeshO> cfs; vcg::tri::UpdateBounding<CMeshO>::Box(m.cm); // update bounding box vcg::tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFaceNormalized(m.cm); // update Normals vcg::tri::Stat<CMeshO>::ComputeEdgeHistogram(m.cm,hi); float radius = hi.Avg()*par.getFloat("radius"); cfs.Compute(m.cm,radius, cb );} return true; }
// This function define the needed parameters for each filter. Return true if the filter has some parameters // it is called every time, so you can set the default value of parameters according to the mesh // For each parmeter you need to define, // - the name of the parameter, // - the string shown in the dialog // - the default value // - a possibly long string describing the meaning of that parameter (shown as a popup help in the dialog) void SlidingCurvaturePlugin::initParameterSet(QAction *action,MeshModel &m, FilterParameterSet & parlst) { switch(ID(action)) { case FP_COMPUTE_PRINC_CURV_DIR_FROM_SLIDING : parlst.addFloat ("radius", 2.0, "Specify radius as multiplier of average edge lenght", "Specify radius as multiplier of average edge lenght" ); break; default : assert(0); } }
// This function define the needed parameters for each filter. void RangeMapPlugin::initParameterSet(QAction *action, MeshDocument &m, FilterParameterSet & parlst) { switch(ID(action)) { case FP_SELECTBYANGLE : { parlst.addDynamicFloat("anglelimit", 75.0f, 0.0f, 180.0f, MeshModel::MM_FACEFLAGSELECT, "angle threshold (deg)", "faces with normal at higher angle w.r.t. the view direction are selected"); parlst.addBool ("usecamera", false, "Use ViewPoint from Mesh Camera", "Uses the ViewPoint from the camera associated to the current mesh\n if there is no camera, an error occurs"); parlst.addPoint3f("viewpoint", Point3f(0.0f, 0.0f, 0.0f), "ViewPoint", "if UseCamera is true, this value is ignored"); } break; default : assert(0); } }
// This function define the needed parameters for each filter. Return true if the filter has some parameters // it is called every time, so you can set the default value of parameters according to the mesh // For each parameter you need to define, // - the name of the parameter, // - the string shown in the dialog // - the default value // - a possibly long string describing the meaning of that parameter (shown as a popup help in the dialog) void FilterPerceptualMetric::initParameterSet(QAction *action, MeshDocument & md, FilterParameterSet & parlst) { switch(ID(action)) { case FP_ROUGHNESS_MULTISCALE : { MeshModel *refmesh = md.mm(); foreach (refmesh, md.meshList) if (refmesh != md.mm()) break; parlst.addMesh("ReferenceMesh", refmesh, "Reference Mesh", "The original mesh."); parlst.addMesh("InputMesh", md.mm(), "Mesh", "The mesh where the perceptual impairment of the processing is evaluated."); } break; case FP_ROUGHNESS_SMOOTHING : { MeshModel *refmesh = md.mm(); foreach (refmesh, md.meshList) if (refmesh != md.mm()) break; parlst.addMesh("ReferenceMesh", refmesh, "Reference Mesh", "The original mesh."); parlst.addMesh("InputMesh", md.mm(), "Mesh", "The mesh where the perceptual impairment of the processing is evaluated."); } break; case FP_STRAIN_ENERGY : { MeshModel *refmesh = md.mm(); foreach (refmesh, md.meshList) if (refmesh != md.mm()) break; parlst.addMesh("ReferenceMesh", refmesh, "Reference Mesh", "The original mesh."); parlst.addMesh("InputMesh", md.mm(), "Mesh", "The mesh where the perceptual impairment of the processing is evaluated."); } break; default : assert(0); } }
bool FilterPerceptualMetric::applyFilter(QAction *action, MeshDocument &md, FilterParameterSet & par, vcg::CallBackPos *cb) { switch(ID(action)) { case FP_ROUGHNESS_MULTISCALE : { MeshModel* mesh0 = par.getMesh("ReferenceMesh"); // reference mesh MeshModel* mesh1 = par.getMesh("InputMesh"); // the processed mesh double globalimpact = PerceptualMetrics<CMeshO>::roughnessMultiscale(mesh0->cm, mesh1->cm); Log(0,"This metric is not implemented yet!!"); } break; case FP_ROUGHNESS_SMOOTHING : { MeshModel* mesh0 = par.getMesh("ReferenceMesh"); // reference mesh MeshModel* mesh1 = par.getMesh("InputMesh"); // the processed mesh double globalimpact = PerceptualMetrics<CMeshO>::roughnessSmoothing(mesh0->cm, mesh1->cm); Log(0,"This metric is not implemented yet!!"); } break; case FP_STRAIN_ENERGY : { MeshModel* mesh0 = par.getMesh("ReferenceMesh"); // reference mesh MeshModel* mesh1 = par.getMesh("InputMesh"); // the processed mesh double globalimpact = PerceptualMetrics<CMeshO>::strainEnergy(mesh0->cm, mesh1->cm); Log(0,"Perceptual Distance: %f",globalimpact); } break; default : assert(0); } return true; }
bool FilterFeatureAlignment::applyFilter(QAction *filter, MeshDocument &md, FilterParameterSet & par, vcg::CallBackPos * cb) { glLog=log; //assign log to a global variable. needed to write the log from everywhere in the code //define needed typedef MeshType typedef CMeshO MeshType; //declare variables for parameters int featureType, from, to, step, trials; MeshModel *mFix, *mMov, *currMesh; //read parameters currMesh = md.mm(); //get current mesh from document if(par.hasParameter("mFix")) mFix = par.getMesh("mFix"); else mFix = currMesh; if(par.hasParameter("mMov")) mMov = par.getMesh("mMov"); else mMov = currMesh; if(par.hasParameter("featureType")) featureType = par.getEnum("featureType"); else featureType = -1; if(par.hasParameter("trials")) trials = par.getInt("trials"); else trials = 100; if(par.hasParameter("from")) from = par.getInt("from"); else from = 1000; if(par.hasParameter("to")) to = par.getInt("to"); else to = 5000; if(par.hasParameter("step")) step = par.getInt("step"); else step = 1000; switch(ID(filter)) { case AF_COMPUTE_FEATURE: { switch(featureType){ case 0:{ typedef SmoothCurvatureFeature<MeshType, 6> FeatureType; //define needed typedef FeatureType FeatureType::Parameters param; FeatureType::SetupParameters(param); return ComputeFeatureOperation<MeshType,FeatureType>(*currMesh, param, cb); } case 1:{ typedef APSSCurvatureFeature<MeshType, 3> FeatureType; //define needed typedef FeatureType FeatureType::Parameters param; FeatureType::SetupParameters(param); return ComputeFeatureOperation<MeshType,FeatureType>(*currMesh, param, cb); } case 2:{ typedef FeatureRGB<MeshType, 3> FeatureType; //define needed typedef FeatureType FeatureType::Parameters param; FeatureType::SetupParameters(param); return ComputeFeatureOperation<MeshType,FeatureType>(*currMesh, param, cb); } default: assert(0); } //end switch(ftype) assert(0); } //end case AF_COMPUTE_FEATURE case AF_EXTRACTION: { switch(featureType){ case 0:{ typedef SmoothCurvatureFeature<MeshType, 6> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); bool ok = ExtractionOperation<AlignerType>(*currMesh, alignerParam, cb); return ok; } case 1:{ typedef FeatureRGB<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); bool ok = ExtractionOperation<AlignerType>(*currMesh, alignerParam, cb); return ok; } default: assert(0); } //end switch(ftype) assert(0); } //end case AF_EXTRACTION case AF_MATCHING : { switch(featureType) { case 0:{ typedef SmoothCurvatureFeature<MeshType, 6> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = MatchingOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } case 1:{ typedef FeatureRGB<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = MatchingOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } default: assert(0); } //end switch(ftype) assert(0); } //end case AF_MATCHING case AF_RIGID_TRANSFORMATION : { switch(featureType) { case 0:{ typedef SmoothCurvatureFeature<MeshType, 6> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RigidTransformationOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } case 1:{ typedef FeatureRGB<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RigidTransformationOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } default: assert(0); } //end switch(ftype) assert(0); } //end case AF_RIGID_TRANSFORMATION case AF_CONSENSUS : { typedef OverlapEstimation<CMeshO> ConsensusType; ConsensusType::Parameters consParam; //set up params for consensus consParam.samples = math::Clamp(par.getInt("fullConsensusSamples"),1,mMov->cm.VertexNumber()); consParam.consensusDist=math::Clamp<float>(par.getFloat("consensusDist"),0.0f,100.0f); consParam.paint = par.getBool("paint"); consParam.normalEqualization = par.getBool("normEq"); consParam.threshold = 0.0f; consParam.bestScore = 0; float result = ConsensusOperation<ConsensusType>(*mFix, *mMov, consParam, cb); if(result<0){ errorMessage = "Consensus Initialization fails."; return false; } Log("Consensus of %.2f%%", 100*result); return true; } case AF_RANSAC: { switch(featureType){ case 0:{ typedef SmoothCurvatureFeature<MeshType, 6> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RansacOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } case 1:{ typedef APSSCurvatureFeature<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RansacOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } case 2:{ typedef FeatureRGB<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RansacOperation<AlignerType>(*mFix, *mMov, alignerParam, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } default: assert(0); } // end switch(ftype) assert(0); } //end case AF_RANSAC case AF_RANSAC_DIAGRAM: { switch(featureType){ case 0:{ typedef SmoothCurvatureFeature<MeshType, 6> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RansacDiagramOperation<AlignerType>(*mFix, *mMov, alignerParam, trials, from, to, step, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } case 1:{ typedef APSSCurvatureFeature<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RansacDiagramOperation<AlignerType>(*mFix, *mMov, alignerParam, trials, from, to, step, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } case 2:{ typedef FeatureRGB<MeshType, 3> FeatureType; //define needed typedef FeatureType typedef FeatureAlignment<MeshType, FeatureType> AlignerType; //define the Aligner class typedef AlignerType::Result ResultType; AlignerType::Parameters alignerParam(mFix->cm, mMov->cm); setAlignmentParameters<AlignerType>(mFix->cm, mMov->cm, par, alignerParam); ResultType res = RansacDiagramOperation<AlignerType>(*mFix, *mMov, alignerParam, trials, from, to, step, cb); return logResult<AlignerType>(ID(filter), res, errorMessage); } default: assert(0); } // end switch(ftype) assert(0); } //end case AF_RANSAC_DIAGRAM default: assert(0); } // end switch(ID(filter)) return false; }
void FilterFeatureAlignment::setAlignmentParameters(typename ALIGNER_TYPE::MeshType& mFix, typename ALIGNER_TYPE::MeshType& mMov, FilterParameterSet& par, typename ALIGNER_TYPE::Parameters& param) { typedef ALIGNER_TYPE AlignerType; typedef typename AlignerType::MeshType MeshType; if(par.hasParameter("samplingStrategy")) param.samplingStrategy = par.getEnum("samplingStrategy"); if(par.hasParameter("numMovFeatureSelected")) param.numMovFeatureSelected = math::Clamp(par.getInt("numMovFeatureSelected"),0,mMov.VertexNumber()); if(par.hasParameter("nBase")){ param.nBase = par.getInt("nBase"); if(param.nBase<4) param.nBase=4; } if(par.hasParameter("k")){ param.k = par.getInt("k"); if(param.k<1) param.k=1; } if(par.hasParameter("ransacIter")){ param.ransacIter = par.getInt("ransacIter"); if(param.ransacIter<0) param.ransacIter = 0;} if(par.hasParameter("fullConsensusSamples")) param.fullConsensusSamples = math::Clamp(par.getInt("fullConsensusSamples"),1,mMov.VertexNumber()); if(par.hasParameter("overlap")) param.overlap = math::Clamp<float>(par.getFloat("overlap"),0.0f,100.0f); if(par.hasParameter("consensusDist")) param.consensusDist = math::Clamp<float>(par.getFloat("consensusDist"),0.0f,100.0f); if(par.hasParameter("pickPoints")) param.pickPoints = par.getBool("pickPoints"); if(par.hasParameter("normEq")) param.normalEqualization = par.getBool("normEq"); if(par.hasParameter("paint")) param.paint = par.getBool("paint"); }
void FilterFeatureAlignment::initParameterSet(QAction *a, MeshDocument& md, FilterParameterSet & par) { switch(ID(a)) { case AF_COMPUTE_FEATURE: { QStringList l; l << "GMSmooth curvature" << "APSS curvature" << "RGB"; par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh."); break; } case AF_EXTRACTION: { QStringList l, st; l << "GMSmooth curvature" << "RGB"; st << "Uniform" << "Poisson disk"; par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh."); par.addInt("numMovFeatureSelected", 250, "Number of features:", "The number of feature points you want to extract from the current mesh."); par.addEnum("samplingStrategy", 0, st,"Sampling strategy:", "The sampling strategy used to select feature points:<br>Uniform -> random selection<br>Poisson disk -> Poisson disk sampling."); par.addBool("pickPoints", false, "Store feature points", "Turns on and off storing of feature points into PickedPoints attribute. Check this if you plan of showing feature points. NOTICE: rendering more of two hundred feature points can be very slow."); break; } case AF_MATCHING: { QStringList l; l << "GMSmooth curvature" << "RGB feature"; par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh."); par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment."); par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh."); par.addInt("numMovFeatureSelected", 250, "Number of features:", "The number of feature points you want to extract from Move Mesh. The base of feature points that has to be matched is randomly picked in this subset."); par.addInt("nBase", 4, "Number of base features:", "Number of feature points that make a base. At least 3 are required, 4 get a better result."); par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower."); break; } case AF_RIGID_TRANSFORMATION : { QStringList l; l << "GMSmooth curvature" << "RGB"; par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh."); par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment."); par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh."); par.addInt("numMovFeatureSelected", 250, "Number of features:", "The number of feature points you want to extract from Move Mesh. The base of feature points that has to be matched is randomly picked in this subset."); par.addInt("nBase", 4, "Number of base features:", "Number of feature points that make a base. At least 3 are required, 4 get a better result."); par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower."); break; } case AF_CONSENSUS : { par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment."); par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh."); par.addFloat("consensusDist", 2, "Consensus distance:","Consensus distance expressed in percentage of Move Mesh bounding box diagonal. It states how close two verteces must be to be in consensus."); par.addInt("fullConsensusSamples", 2500, "Number of samples:", "Number of samples used to perform consensus procedure. Greater values get a more actual esteem but takes more time to be computed."); par.addBool("normEq", true, "Normal equalization","If checked samples are selected according a normal equilezed strategy, elsewhere a random selection is performed. Normal equalization is computationally more expensive but provides a better esteem, specially with few samples."); par.addBool("paint", true, "Paint Move Mesh","If checked Move Mesh is painted according to consensus as follows:<br>white -> not tested<br>blue -> too far<br>yellow -> close but badly oriented<br>red -> in consensus."); break; } case AF_RANSAC: { QStringList l; l << "GMSmooth curvature" << "APSS curvature" << "RGB"; par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh."); par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment."); par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh."); par.addInt("ransacIter", 500, "Iterations:", "Number of iterations of the RANSAC algorithm. Greater values provides a greater success probability but requires more time."); par.addFloat("overlap", 75.0, "Overlap:", "A measure, expressed in percentage, of how much Move Mesh overlaps with Fix Mesh. It is very important to provide an actual esteem: lower values can produce false positive results or too rough alignments; higher values produce a small success probability and no alignements at all."); par.addFloat("consensusDist", 2, "Consensus distance:","Consensus distance expressed in percentage of Move Mesh bounding box diagonal. It states how close two verteces must be to be in consensus."); par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower."); par.addBool("pickPoints", false, "Store best match", "If checked, feature points of the base picked on Move Mesh and feature points of the best matching base on Fix Mesh are stored into PickedPoints attribute. Bases are stored only if alignment process ends successfully, i.e at least one base have to exceed full consensus."); break; } case AF_RANSAC_DIAGRAM: { QStringList l; l << "GMSmooth curvature" << "APSS curvature" << "RGB"; par.addEnum("featureType", 0, l,"Feature type:", "The feature that you want to compute for the current mesh."); par.addMesh("mFix", 0, "Fix mesh:", "The mesh that stays still and grow large after alignment."); par.addMesh("mMov", 1, "Move mesh:", "The mesh that moves to fit Fix Mesh."); par.addFloat("overlap", 75.0, "Overlap:", "A measure, expressed in percentage, of how much Move Mesh overlaps with Fix Mesh. It is very important to provide an actual esteem: lower values can produce false positive results or too rough alignments; higher values produce a small success probability and no alignements at all."); par.addFloat("consensusDist", 2, "Consensus distance:","Consensus distance expressed in percentage of Move Mesh bounding box diagonal. It states how close two verteces must be to be in consensus."); par.addInt("k", 75, "Number of neighboors:", "Number of neighboor feature points picked by kNN search during matching. Greater values produce a greater success probability but make the alignment process slower."); par.addInt("trials", 100, "Trials:", "How many times the alignment process is repeated with the same amount of RANSAC iterations."); par.addInt("from", 100, "From iteration:", "Number of RANSAC iteration used to perform the first battery of alignments."); par.addInt("to", 1000, "To iteration:", "Number of RANSAC iteration over which no more alignments are performed."); par.addInt("step", 100, "Step:", "Step used to increment RANSAC iterations after that the specified number of attempts has been done."); break; } default: assert(0); } }
void PhotoTexturingWidget::saveDefaultBakeSettings(FilterParameterSet pset){ QSettings ptSettings; ptSettings.setValue(PhotoTexturer::TEXTURE_SIZE_WIDTH,pset.getInt(PhotoTexturer::TEXTURE_SIZE_WIDTH)); ptSettings.setValue(PhotoTexturer::TEXTURE_SIZE_HEIGHT,pset.getInt(PhotoTexturer::TEXTURE_SIZE_HEIGHT)); ptSettings.setValue(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,pset.getBool(PhotoTexturer::UNPROJECT_ENABLE_ANGLE)); ptSettings.setValue(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,pset.getInt(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT)); ptSettings.setValue(PhotoTexturer::UNPROJECT_ANGLE,pset.getFloat(PhotoTexturer::UNPROJECT_ANGLE)); ptSettings.setValue(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,pset.getInt(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS)); ptSettings.setValue(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,pset.getBool(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE)); ptSettings.setValue(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,pset.getInt(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT)); ptSettings.setValue(PhotoTexturer::BAKE_SAVE_UNPROJECT,pset.getBool(PhotoTexturer::BAKE_SAVE_UNPROJECT)); ptSettings.setValue(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,pset.getBool(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING)); ptSettings.setValue(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,pset.getInt(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS)); ptSettings.setValue(PhotoTexturer::BAKE_MERGE_TEXTURES,pset.getBool(PhotoTexturer::BAKE_MERGE_TEXTURES)); ptSettings.setValue(PhotoTexturer::BAKE_MERGE_TYPE,pset.getEnum(PhotoTexturer::BAKE_MERGE_TYPE)); ptSettings.setValue(PhotoTexturer::BAKE_SMARTBLEND,pset.getString(PhotoTexturer::BAKE_SMARTBLEND)); }
FilterParameterSet PhotoTexturingWidget::loadDefaultBakeSettings(){ QSettings ptSettings; QVariant tmpValue; FilterParameterSet combineParamSet; tmpValue= ptSettings.value(PhotoTexturer::TEXTURE_SIZE_WIDTH,1024); combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_WIDTH,tmpValue.toInt(),"Image width:",""); tmpValue = ptSettings.value(PhotoTexturer::TEXTURE_SIZE_HEIGHT,1024); combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_HEIGHT,tmpValue.toInt(),"Image height:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,true); combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,tmpValue.toBool(),"Enable angle map:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,1); combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,tmpValue.toInt(),"Angle map weight:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ANGLE,85.0); combineParamSet.addFloat(PhotoTexturer::UNPROJECT_ANGLE,tmpValue.toDouble(),"Max angle (degrees):",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,1); combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,tmpValue.toInt(),"Angle map sharpness:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,false); combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,tmpValue.toBool(),"Enable distance map:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,1); combineParamSet.addInt(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,tmpValue.toInt(),"Distance map weight:",""); tmpValue = ptSettings.value(PhotoTexturer::BAKE_SAVE_UNPROJECT,true); combineParamSet.addBool(PhotoTexturer::BAKE_SAVE_UNPROJECT,tmpValue.toBool(),"Save unprojected textures:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,false); combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,tmpValue.toBool(),"Enable Texture edge Stretching:",""); tmpValue = ptSettings.value(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,2); combineParamSet.addInt(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,tmpValue.toInt(),"Edge Stretching Passes:",""); tmpValue = ptSettings.value(PhotoTexturer::BAKE_MERGE_TEXTURES,true); combineParamSet.addBool(PhotoTexturer::BAKE_MERGE_TEXTURES,tmpValue.toBool(),"Merge unprojected textures:",""); tmpValue = ptSettings.value(PhotoTexturer::BAKE_MERGE_TYPE,0); combineParamSet.addEnum(PhotoTexturer::BAKE_MERGE_TYPE,tmpValue.toInt(),QStringList() <<"Merge Faces by Angle"<<"Smartblend","Merge Mode:",""); tmpValue = ptSettings.value(PhotoTexturer::BAKE_SMARTBLEND,"smartblend.exe"); //combineParamSet.addOpenFileName(PhotoTexturer::BAKE_SMARTBLEND,tmpValue.toString(),".exe","Smartblend:",""); combineParamSet.addString(PhotoTexturer::BAKE_SMARTBLEND,tmpValue.toString(),"Smartblend:",""); return combineParamSet; }
void PhotoTexturingWidget::unprojectTextures(){ QSettings ptSettings; QVariant setSmartBlend = ptSettings.value(PhotoTexturer::BAKE_SMARTBLEND,"smartblend.exe"); FilterParameterSet combineParamSet; combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_WIDTH,1024,"Image width:",""); combineParamSet.addInt(PhotoTexturer::TEXTURE_SIZE_HEIGHT,1024,"Image height:",""); combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_ANGLE,true,"Enable angle map:",""); combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_WEIGHT,1,"Angle map weight:",""); combineParamSet.addFloat(PhotoTexturer::UNPROJECT_ANGLE,85,"Min angle:",""); combineParamSet.addInt(PhotoTexturer::UNPROJECT_ANGLE_SHARPNESS,1,"Angle map sharpness:",""); combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_DISTANCE,false,"Enable distance map:",""); combineParamSet.addInt(PhotoTexturer::UNPROJECT_DISTANCE_WEIGHT,1,"Distance map weight:",""); combineParamSet.addBool(PhotoTexturer::BAKE_SAVE_UNPROJECT,true,"Save unprojected textures:",""); combineParamSet.addBool(PhotoTexturer::UNPROJECT_ENABLE_EDGE_STRETCHING,false,"Enable Texture edge Stretching:",""); combineParamSet.addInt(PhotoTexturer::UNPROJECT_EDGE_STRETCHING_PASS,2,"Edge Stretching Passes:",""); combineParamSet.addBool(PhotoTexturer::BAKE_MERGE_TEXTURES,true,"Merge unprojected textures:",""); combineParamSet.addEnum(PhotoTexturer::BAKE_MERGE_TYPE,0,QStringList() <<"Merge Faces by Angle"<<"Smartblend","Merge Mode:",""); combineParamSet.addString(PhotoTexturer::BAKE_MERGED_TEXTURE,"","Merged Texture Filename:",""); combineParamSet.addString(PhotoTexturer::BAKE_SMARTBLEND,setSmartBlend.toString(),"smartblend:",""); QListWidgetItem* lwis = ui.textureListWidget->currentItem(); int textureID = lwis[0].type(); GenericParamDialog ad(this,&combineParamSet,"Texture Baking Parameters"); int result=ad.exec(); ptSettings.setValue(PhotoTexturer::BAKE_SMARTBLEND,combineParamSet.getString(PhotoTexturer::BAKE_SMARTBLEND)); if (result == 1){ photoTexturer->unprojectTextures(mesh,textureID,&combineParamSet); } update(); updateGLAreaTextures(); }
//添加元素 void FilterParameter::addQDomElement(FilterParameterSet &par, QDomElement &np) { QString name=np.attribute("name"); QString type=np.attribute("type"); qDebug(" Reading Param with name %s : %s",qPrintable(name),qPrintable(type)); if(type=="Bool") { par.addBool(name,np.attribute("value")!=QString("false")); return; } if(type=="Int") { par.addInt(name,np.attribute("value").toInt()); return; } if(type=="Float") { par.addFloat(name,np.attribute("value").toDouble()); return; } if(type=="String") { par.addString(name,np.attribute("value")); return; } if(type=="AbsPerc") { par.addAbsPerc(name,np.attribute("value").toFloat(),np.attribute("min").toFloat(),np.attribute("max").toFloat()); return; } if(type=="Color") { par.addColor(name,QColor::QColor(np.attribute("rgb").toUInt())); return; } if(type=="Matrix44") { Matrix44f mm; for(int i=0;i<16;++i) mm.V()[i]=np.attribute(QString("val")+QString::number(i)).toDouble(); par.addMatrix44(name,mm); return; } if(type=="Enum") { QStringList list = QStringList::QStringList(); for(QDomElement ns = np.firstChildElement("EnumString"); !ns.isNull(); ns = ns.nextSiblingElement("EnumString")){ list<<ns.attribute("value"); } par.addEnum(name,np.attribute("value").toInt(),list); return; } if(type == MeshPointerName()) { par.addMesh(name, np.attribute(ValueName()).toInt()); return; } if(type == FloatListName()) { QList<float> values; for(QDomElement listItem = np.firstChildElement(ItemName()); !listItem.isNull(); listItem = listItem.nextSiblingElement(ItemName())) { values.append(listItem.attribute(ValueName()).toFloat()); } par.addFloatList(name,values); return; } if(type == DynamicFloatName()) { par.addDynamicFloat(name, np.attribute(ValueName()).toFloat(), np.attribute(MinName()).toFloat(), np.attribute(MaxName()).toFloat(), np.attribute(MaskName()).toInt()); return; } if(type == OpenFileNameName()) { par.addOpenFileName(name, np.attribute(ValueName())); return; } if(type == SaveFileNameName()) { par.addSaveFileName(name, np.attribute(ValueName())); return; } if(type=="Point3f") { Point3f val; val[0]=np.attribute("x").toFloat(); val[1]=np.attribute("y").toFloat(); val[2]=np.attribute("z").toFloat(); par.addPoint3f(name, val); return; } assert(0); // we are trying to parse an unknown xml element }