Skip to content

Commit

Permalink
Syntax cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardeau committed Nov 11, 2024
1 parent c33abea commit f33abba
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 44 deletions.
21 changes: 12 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ option(NANOFLANN_BUILD_BENCHMARKS "" OFF)
option(NANOFLANN_BUILD_EXAMPLES "" OFF)
option(NANOFLANN_BUILD_TESTS "" OFF)
add_subdirectory( extern/nanoflann EXCLUDE_FROM_ALL )
target_link_libraries( CCCoreLib PUBLIC nanoflann::nanoflann )
target_link_libraries( CCCoreLib
PUBLIC
nanoflann::nanoflann
)

# Windows-specific flags
if ( WIN32 )
Expand Down Expand Up @@ -161,12 +164,12 @@ if ( CCCORELIB_USE_TBB )
if ( ${TBB_VERSION} VERSION_GREATER 2021.0.0 )
target_link_libraries( CCCoreLib
PUBLIC
TBB::tbb
TBB::tbb
)
else()
target_link_libraries( CCCoreLib
PUBLIC
${TBB_IMPORTED_TARGETS}
${TBB_IMPORTED_TARGETS}
)
endif()
target_compile_definitions( CCCoreLib
Expand Down Expand Up @@ -221,15 +224,15 @@ if ( CCCORELIB_USE_QT_CONCURRENT )
REQUIRED
)

set_target_properties( CCCoreLib PROPERTIES
AUTOMOC OFF
AUTORCC OFF
AUTOUIC OFF
)
set_target_properties( CCCoreLib PROPERTIES
AUTOMOC OFF
AUTORCC OFF
AUTOUIC OFF
)

target_link_libraries( CCCoreLib
PUBLIC
Qt5::Concurrent
Qt5::Concurrent
)

target_compile_definitions( CCCoreLib
Expand Down
42 changes: 20 additions & 22 deletions include/RegistrationTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ namespace CCCoreLib
const CCVector3& referenceGravityCenter,
ScaledTransformation& outTrans );

//! Computes RMS between two clouds given a transformation and a scale
/** Warning: both clouds must have the same size (and at least 3 points)
RMS = Sqrt ( Sum( square_norm( Pr - s*R*Pl+T ) ) / count )
\param lCloud left cloud {Pl}
\param rCloud right cloud {Pr}
\param trans transformation: Pr = s.R.Pl + T
\return RMS (or -1.0 if an error occurred)
**/
static double ComputeRMS( GenericCloud* lCloud,
GenericCloud* rCloud,
const ScaledTransformation& trans);

protected:

//! ICP Registration procedure with optional scale estimation
Expand Down Expand Up @@ -92,32 +104,18 @@ namespace CCCoreLib
{
public:

//! Returns "absolute orientation" (scale + transformation) between two set of (unordered) points
/** Warning: both clouds must have the same size (and at least 3 points)
Output transformation is from the left (L) to the right (R) coordinate system
\param lCloud left cloud {Pl}
\param rCloud right cloud {Pr}
\param trans resulting transformation: Pr = s.R.Pl + T
\param fixedScale force scale parameter to 1.0
//! Returns the transformation (scale + transformation) between two sets of (unordered) points
/** \warning Both clouds must have the same size (and at least 3 points)
\param[in] toBeAlignedPoints the points to be aligned
\param[in] referencePoints the fixed/static points
\param[out] trans resulting transformation: Pr = s.R.Pl + T
\param[in] fixedScale force scale parameter to 1.0
\return success
**/
static bool FindAbsoluteOrientation(GenericCloud* lCloud,
GenericCloud* rCloud,
static bool FindAbsoluteOrientation(GenericCloud* toBeAlignedPoints,
GenericCloud* referencePoints,
ScaledTransformation& trans,
bool fixedScale = false);

//! Computes RMS between two clouds given a transformation and a scale
/** Warning: both clouds must have the same size (and at least 3 points)
RMS = Sqrt ( Sum( square_norm( Pr - s*R*Pl+T ) ) / count )
\param lCloud left cloud {Pl}
\param rCloud right cloud {Pr}
\param trans transformation: Pr = s.R.Pl + T
\return RMS (or -1.0 if an error occurred)
**/
static double ComputeRMS( GenericCloud* lCloud,
GenericCloud* rCloud,
const ScaledTransformation& trans);

};

//! ICP point cloud registration algorithm (Besl et al.).
Expand Down
31 changes: 18 additions & 13 deletions src/RegistrationTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,32 +974,37 @@ ICPRegistrationTools::RESULT_TYPE ICPRegistrationTools::Register( GenericIndexed
return result;
}

bool HornRegistrationTools::FindAbsoluteOrientation(GenericCloud* lCloud,
GenericCloud* rCloud,
bool HornRegistrationTools::FindAbsoluteOrientation(GenericCloud* toBeAlignedPoints,
GenericCloud* referencePoints,
ScaledTransformation& trans,
bool fixedScale/*=false*/)
{
return RegistrationProcedure(lCloud, rCloud, trans, !fixedScale);
return RegistrationProcedure(toBeAlignedPoints, referencePoints, trans, !fixedScale);
}

double HornRegistrationTools::ComputeRMS(GenericCloud* lCloud,
GenericCloud* rCloud,
const ScaledTransformation& trans)
double RegistrationTools::ComputeRMS(GenericCloud* toBeAlignedPoints,
GenericCloud* referencePoints,
const ScaledTransformation& trans)
{
assert(rCloud && lCloud);
if (!rCloud || !lCloud || rCloud->size() != lCloud->size() || rCloud->size() < 3)
assert(referencePoints && toBeAlignedPoints);
if ( !referencePoints
|| !toBeAlignedPoints
|| referencePoints->size() != toBeAlignedPoints->size()
|| referencePoints->size() < 3 )
{
return false;
}

double rms = 0.0;

rCloud->placeIteratorAtBeginning();
lCloud->placeIteratorAtBeginning();
unsigned count = rCloud->size();
referencePoints->placeIteratorAtBeginning();
toBeAlignedPoints->placeIteratorAtBeginning();
unsigned count = referencePoints->size();

for (unsigned i = 0; i < count; i++)
{
const CCVector3* Ri = rCloud->getNextPoint();
const CCVector3* Li = lCloud->getNextPoint();
const CCVector3* Ri = referencePoints->getNextPoint();
const CCVector3* Li = toBeAlignedPoints->getNextPoint();
CCVector3 Lit = trans.apply(*Li);

rms += (*Ri - Lit).norm2();
Expand Down

0 comments on commit f33abba

Please sign in to comment.