Completed translation of comments

This commit is contained in:
Paolo Cignoni 2020-09-22 18:55:56 +02:00
parent 62f16491ea
commit 7563d41062
1 changed files with 79 additions and 104 deletions

View File

@ -49,12 +49,9 @@
namespace vcg { namespace vcg {
/************************************************************************* /**
AlignPair Class for aligning pair of meshes using ICP (iterated closest point)
*/
Classe per gestire un allineamento tra DUE sole mesh.
**************************************************************************/
class AlignPair { class AlignPair {
public: public:
@ -77,7 +74,7 @@ public:
UNKNOWN_MODE }; UNKNOWN_MODE };
/*********************** Classi Accessorie ****************************/ /*********************** Utility classes ****************************/
class A2Vertex; class A2Vertex;
@ -138,14 +135,14 @@ public:
int DistanceDiscarded; int DistanceDiscarded;
int AngleDiscarded; int AngleDiscarded;
int BorderDiscarded; int BorderDiscarded;
int SampleTested; // quanti punti ho testato con la mindist int SampleTested; // how many points have been tested
int SampleUsed; // quanti punti ho scelto per la computematrix int SampleUsed; // how many points have been actually used to compute the transformation
double pcl50; double pcl50;
double pclhi; double pclhi;
double AVG; double AVG;
double RMS; double RMS;
double StdDev; double StdDev;
int Time; // quando e' finita questa iterazione int Time; // Ending time of this iteration
}; };
@ -205,7 +202,7 @@ public:
I[qi].SampleTested, I[qi].SampleUsed, I[qi].DistanceDiscarded, I[qi].BorderDiscarded, I[qi].AngleDiscarded); I[qi].SampleTested, I[qi].SampleUsed, I[qi].DistanceDiscarded, I[qi].BorderDiscarded, I[qi].AngleDiscarded);
} }
// Scrive una tabella con tutti i valori //! Write a HTML table with the values
inline void htmlDump(FILE *fp) inline void htmlDump(FILE *fp)
{ {
fprintf(fp, "Final Err %8.5f In %i iterations Total Time %ims\n", lastPcl50(), (int)I.size(), totTime()); fprintf(fp, "Final Err %8.5f In %i iterations Total Time %ims\n", lastPcl50(), (int)I.size(), totTime());
@ -249,64 +246,46 @@ public:
Param() Param()
{ {
SampleNum = 2000; SampleNum = 2000;
MaxPointNum = 100000; MaxPointNum = 100000;
MinPointNum = 30; MinPointNum = 30;
MaxIterNum = 75;
MaxIterNum = 75; TrgDistAbs = 0.005f;
TrgDistAbs = 0.005f; MinDistAbs = 10;
MaxAngleRad = math::ToRad(45.0);
MinDistAbs = 10; MaxShear = 0.5;
MaxAngleRad = math::ToRad(45.0); MaxScale = 0.5; // means that the scale must be between 1-MaxScale and 1+MaxScale
MaxShear = 0.5; PassHiFilter = 0.75;
MaxScale = 0.5; // significa che lo scale deve essere compreso tra 1-MaxScale e 1+MaxScale ReduceFactorPerc = 0.80;
PassHiFilter = 0.75; MinMinDistPerc = 0.01;
ReduceFactorPerc = 0.80; EndStepNum = 5;
MinMinDistPerc = 0.01; MatchMode = MMRigid;
EndStepNum = 5; SampleMode = SMNormalEqualized;
MatchMode = MMRigid; UGExpansionFactor = 10;
SampleMode = SMNormalEqualized;
UGExpansionFactor=10;
MinFixVertNum=20000;
MinFixVertNumPerc=.25;
UseVertexOnly = false;
} }
int SampleNum; // numero di sample da prendere sulla mesh fix, utilizzando int SampleNum; //! The intial number of samples that are chosen on the fix mesh.
// il SampleMode scelto tra cui poi sceglierne al piu' <MaxPointNum> int MaxPointNum; //! Maximum number off point used to compute the transforamtion matrix (rarely used)
// e almeno <MinPointNum> da usare per l'allineamento. int MinPointNum; //! Minimal number of point that we have to find to consider the resulting alignment valid
int MaxPointNum; // numero di coppie di punti da usare quando si calcola la matrice double MinDistAbs; //! Minimal distance for ICP points. Only points that are closer than this threshold are chosen.
// di allienamento e che poi si mettono da parte per il globale; //! This threshold is iteratively lowered by the ReduceFactor parameter
// di solito non usato
int MinPointNum; // minimo numero di coppie di punti ammissibile perche' sia considerato
// valido l'allineamento
double MinDistAbs; // distanza minima iniziale perche due punti vengano presi in
// considerazione. NON e' piu espressa in percentuale sul bbox della mesh nella ug.
// Ad ogni passo puo essere ridotta per
// accellerare usando ReduceFactor
double MaxAngleRad; // massimo angolo in radianti tra due normali perche' i due
// punti vengano presi in considerazione.
int MaxIterNum; // massimo numero di iterazioni da fare in align double MaxAngleRad; //! Max angle (in radiant) for ICP points. Only points whose normal differ less than this threshold are considered
double TrgDistAbs; // distanza obiettivo entro la quale devono stare almeno la meta'
// dei campioni scelti; di solito non entra in gioco perche' ha un default molto basso
int EndStepNum; // numero di iterazioni da considerare per decidere se icp ha converso. int MaxIterNum; //! Maximum number of iteration to be done during aligning
double TrgDistAbs; //! Target distance (half of the samples should be below this distance to consider the icp reach convergence)
int EndStepNum; //! max number of ICP iterations
//double PassLoFilter; // Filtraggio utilizzato per decidere quali punti scegliere tra quello trovati abbastanza double PassHiFilter; //! Percentile filtering threshold. Usually we discard the farthest quartile of the matched points
double PassHiFilter; // vicini. Espresso in percentili. Di solito si scarta il quelli sopra il 75 e quelli sotto il 5 double ReduceFactorPerc; //! At each step we discard the points farther than a given threshold. The threshold is iterativeley reduced;
double ReduceFactorPerc; // At each step we discard the points farther than a given threshold. The threshold is iterativeley reduced; //! StartMinDist= min(StartMinDist, 5.0*H.Percentile(ap.ReduceFactorPerc))
// StartMinDist= min(StartMinDist, 5.0*H.Percentile(ap.ReduceFactorPerc))
double MinMinDistPerc; // Ratio between initial starting distance (MinDistAbs) and what can reach by the application of the ReduceFactor. double MinMinDistPerc; //! Ratio between initial starting distance (MinDistAbs) and what can reach by the application of the ReduceFactor.
int UGExpansionFactor; // Grandezza della UG per la mesh fix come rapporto del numero di facce della mesh fix int UGExpansionFactor; //! Size of the uniform grid as a ration of the fix mesh size
// Nel caso si usi qualche struttura multiresolution bool UseVertexOnly; //! if true all the Alignment pipeline ignores faces and works over point clouds.
int MinFixVertNum; // Gli allineamenti si fanno mettendo nella ug come mesh fix una semplificata;
float MinFixVertNumPerc; // si usa il max tra MinFixVertNum e OrigMeshSize*MinFixVertNumPerc
bool UseVertexOnly; // if true all the Alignment pipeline ignores faces and works over point clouds.
double MaxShear; double MaxShear;
double MaxScale; double MaxScale;
@ -316,14 +295,13 @@ public:
}; };
// Classe per memorizzare il risultato di un allineamento tra due mesh // Class to store the result of an alignment between two meshes
// i punti si intendono nel sistema di riferimento iniziale delle due mesh. // the points are intended in the initial reference system of the two meshes.
// //
// se le mesh hanno una trasformazione di base in ingresso, // if the meshes have a basic transformation in input,
// questa appare solo durante la A2Mesh::Import e poi e' per sempre dimenticata. // this appears only during the A2Mesh::Import and then is forever forgotten.
// Questi punti sono quindi nei sistemi di riferimento costruiti durante la Import // These points are therefore in the reference systems built during the Import
// la matrice Tr quella che // the matrix Tr that which
//
// Tr*Pmov[i]== Pfix // Tr*Pmov[i]== Pfix
@ -334,10 +312,10 @@ public:
int FixName; int FixName;
Matrix44d Tr; Matrix44d Tr;
std::vector<Point3d> Pfix; // vertici corrispondenti su fix (rossi) std::vector<Point3d> Pfix; // Corresponding Points on the Fix Mesh (red)
std::vector<Point3d> Nfix; // normali corrispondenti su fix (rossi) std::vector<Point3d> Nfix; // Corresponding Normals on the Fix Mesh (red)
std::vector<Point3d> Pmov; // vertici scelti su mov (verdi) prima della trasformazione in ingresso (Original Point Target) std::vector<Point3d> Pmov; // Chosen Points on the Mov Mesh (green) before the transformation
std::vector<Point3d> Nmov; // normali scelti su mov (verdi) std::vector<Point3d> Nmov; // Chosen Normals on the Mov Mesh (green)
Histogramf H; Histogramf H;
Stat as; Stat as;
Param ap; Param ap;
@ -369,7 +347,7 @@ public:
}; };
/******************* Fine Classi Accessorie ************************/ /******************* End utility classes ************************/
static inline const char* errorMsg(ErrorCode code) static inline const char* errorMsg(ErrorCode code)
{ {
@ -570,32 +548,32 @@ public:
} }
/* /*
Minimo esempio di codice per l'uso della funzione di allineamento. Minimal example of code for using the align.
AlignPair::A2Mesh Mov,Fix; // le due mesh da allineare AlignPair::A2Mesh Mov,Fix; // The two meshes to be alligned. Mov will moved.
vector<AlignPair::A2Vertex> MovVert; // i punti sulla mov da usare per l'allineamento vector<AlignPair::A2Vertex> MovVert; // Points chosen on Mov Mesh to compute the alignment
Matrix44d In; In.SetIdentity(); // la trasformazione iniziale che applicata a mov la porterebbe su fix. Matrix44d In; In.SetIdentity(); // Initial transformation to be applied to Mov mesh to bring it over the Fix mesh.
AlignPair aa; // l'oggetto principale. AlignPair aa; // The main align class
AlignPair::Param ap; AlignPair::Param ap;
UGrid< AlignPair::A2Mesh::face_container > UG; UGrid< AlignPair::A2Mesh::face_container > UG;
Fix.LoadPly("FixMesh.ply"); // Standard ply loading Fix.LoadPly("FixMesh.ply"); // Standard ply loading
Mov.LoadPly("MovMesh.ply"); Mov.LoadPly("MovMesh.ply");
Fix.Init( Ident, false); // Inizializzazione necessaria (normali per vert, Fix.Init( Ident, false); // Basic init (computation of normals)
Mov.Init( Ident, false); // info per distanza punto faccia ecc) Mov.Init( Ident, false);
AlignPair::InitFix(&Fix, ap, UG); // la mesh fix viene messa nella ug. AlignPair::InitFix(&Fix, ap, UG); // Init UG for quick search
aa.ConvertVertex(Mov.vert,MovVert); // si campiona la mesh Mov per trovare un po' di vertici. aa.ConvertVertex(Mov.vert,MovVert); // Sample the Mov vertex in order to find good samples to be used.
aa.SampleMovVert(MovVert, ap.SampleNum, ap.SampleMode); aa.SampleMovVert(MovVert, ap.SampleNum, ap.SampleMode);
aa.mov=&MovVert; // si assegnano i membri principali dell'oggetto align pair aa.mov=&MovVert; // basic init of the align class with the chosen vert and the fix mesh
aa.fix=&Fix; aa.fix=&Fix;
aa.ap = ap; aa.ap = ap;
aa.Align(In,UG,res); // si spera :) aa.Align(In,UG,res); // Main ICP algorithm
// il risultato sta nella matrice res.Tr; // the matrix containing the computed alignment is in res.Tr;
res.as.Dump(stdout); res.as.Dump(stdout);
*/ */
@ -629,7 +607,7 @@ in
************************************************************************************/ ************************************************************************************/
/* /**
The Main ICP alignment Function: The Main ICP alignment Function:
It assumes that: It assumes that:
we have two meshes: we have two meshes:
@ -637,9 +615,6 @@ in
- Mov the mesh we 'move' e.g. the one for which we search the transforamtion. - Mov the mesh we 'move' e.g. the one for which we search the transforamtion.
requires normalize normals for vertices AND faces requires normalize normals for vertices AND faces
Allinea due mesh;
Assume che:
la uniform grid sia gia' inizializzata con la mesh fix
*/ */
inline bool align( inline bool align(
A2Grid &u, A2Grid &u,
@ -653,13 +628,13 @@ in
Histogramf &h, Histogramf &h,
Stat &as) Stat &as)
{ {
std::vector<char> beyondCntVec; // flag vector to set the movverts that we should not use std::vector<char> beyondCntVec; // flag vector to set the movverts that we should not use
// every time that a vertex is at a distance beyound max dist, its counter is incremented; // every time that a vertex is at a distance beyound max dist, its counter is incremented;
// movverts that has been discarded more than MaxCntDist times will not be considered anymore // movverts that has been discarded more than MaxCntDist times will not be considered anymore
const int maxBeyondCnt = 3; const int maxBeyondCnt = 3;
std::vector< Point3d > movvert; std::vector< Point3d > movvert;
std::vector< Point3d > movnorm; std::vector< Point3d > movnorm;
std::vector<Point3d> pmov; // vertices chosen after the transformation std::vector<Point3d> pmov; // vertices chosen after the transformation
status = SUCCESS; status = SUCCESS;
int tt0 = clock(); int tt0 = clock();
@ -704,7 +679,7 @@ in
Point3d closestPoint, closestNormal; Point3d closestPoint, closestNormal;
double maxd = startMinDist; double maxd = startMinDist;
ii.SampleTested++; ii.SampleTested++;
if (u.Empty()) {// using the point cloud grid{ if (u.Empty()) { // using the point cloud grid
A2Mesh::VertexPointer vp = tri::GetClosestVertex(*fix, uv, movvert[i], maxd, error); A2Mesh::VertexPointer vp = tri::GetClosestVertex(*fix, uv, movvert[i], maxd, error);
if (error >= startMinDist) { if (error >= startMinDist) {
ii.DistanceDiscarded++; ++beyondCntVec[i]; continue; ii.DistanceDiscarded++; ++beyondCntVec[i]; continue;
@ -715,7 +690,7 @@ in
closestPoint = vp->P(); closestPoint = vp->P();
closestNormal = vp->N(); closestNormal = vp->N();
} }
else {// using the standard faces and grid else { // using the standard faces and grid
A2Mesh::FacePointer f = vcg::tri::GetClosestFaceBase<vcg::AlignPair::A2Mesh, vcg::AlignPair::A2Grid >(*fix, u, movvert[i], maxd, error, closestPoint); A2Mesh::FacePointer f = vcg::tri::GetClosestFaceBase<vcg::AlignPair::A2Mesh, vcg::AlignPair::A2Grid >(*fix, u, movvert[i], maxd, error, closestPoint);
if (error >= startMinDist) { if (error >= startMinDist) {
ii.DistanceDiscarded++; ++beyondCntVec[i]; continue; ii.DistanceDiscarded++; ++beyondCntVec[i]; continue;