Commit 995b6963 authored by Bence Magyar's avatar Bence Magyar

Cosmetic changes

parent d1193e31
......@@ -66,20 +66,20 @@ namespace ppf_match_3d
* You will find that my emphasis is on the performance, while retaining the accuracy.
* This implementation is based on Tolga Birdal's MATLAB implementation in here:
* http://www.mathworks.com/matlabcentral/fileexchange/47152-icp-registration-using-efficient-variants-and-multi-resolution-scheme
The main contributions come from:
1. Picky ICP:
http://www5.informatik.uni-erlangen.de/Forschung/Publikationen/2003/Zinsser03-ARI.pdf
2. Efficient variants of the ICP Algorithm:
http://docs.happycoders.org/orgadoc/graphics/imaging/fasticp_paper.pdf
3. Geometrically Stable Sampling for the ICP Algorithm: https://graphics.stanford.edu/papers/stabicp/stabicp.pdf
4. Multi-resolution registration:
http://www.cvl.iis.u-tokyo.ac.jp/~oishi/Papers/Alignment/Jost_MultiResolutionICP_3DIM03.pdf
5. Linearization of Point-to-Plane metric by Kok Lim Low:
https://www.comp.nus.edu.sg/~lowkl/publications/lowk_point-to-plane_icp_techrep.pdf
*/
* The main contributions come from:
* 1. Picky ICP:
* http://www5.informatik.uni-erlangen.de/Forschung/Publikationen/2003/Zinsser03-ARI.pdf
* 2. Efficient variants of the ICP Algorithm:
* http://docs.happycoders.org/orgadoc/graphics/imaging/fasticp_paper.pdf
* 3. Geometrically Stable Sampling for the ICP Algorithm: https://graphics.stanford.edu/papers/stabicp/stabicp.pdf
* 4. Multi-resolution registration:
* http://www.cvl.iis.u-tokyo.ac.jp/~oishi/Papers/Alignment/Jost_MultiResolutionICP_3DIM03.pdf
* 5. Linearization of Point-to-Plane metric by Kok Lim Low:
* https://www.comp.nus.edu.sg/~lowkl/publications/lowk_point-to-plane_icp_techrep.pdf
*/
class CV_EXPORTS ICP
{
public:
public:
enum ICP_SAMPLING_TYPE
{
......@@ -118,7 +118,7 @@ class CV_EXPORTS ICP
m_maxItereations = iterations;
m_numLevels = numLevels;
m_sampleType = sampleType;
};
}
/**
* \brief Perform registration
......@@ -146,7 +146,7 @@ class CV_EXPORTS ICP
*/
int registerModelToScene(const Mat& srcPC, const Mat& dstPC, std::vector<Pose3D*>& poses);
private:
private:
float m_tolerence;
int m_maxItereations;
float m_rejectionScale;
......
......@@ -57,7 +57,7 @@ namespace ppf_match_3d
*/
class CV_EXPORTS Pose3D
{
public:
public:
Pose3D()
{
alpha=0;
......@@ -67,7 +67,7 @@ class CV_EXPORTS Pose3D
for (int i=0; i<16; i++)
Pose[i]=0;
};
}
Pose3D(double Alpha, unsigned int ModelIndex=0, unsigned int NumVotes=0)
{
......@@ -78,8 +78,7 @@ class CV_EXPORTS Pose3D
for (int i=0; i<16; i++)
Pose[i]=0;
};
}
/**
* \brief Updates the pose with the new one
......@@ -113,7 +112,7 @@ class CV_EXPORTS Pose3D
int writePose(const std::string& FileName);
int readPose(const std::string& FileName);
virtual ~Pose3D() {};
virtual ~Pose3D() {}
double alpha, residual;
unsigned int modelIndex;
......@@ -129,43 +128,37 @@ class CV_EXPORTS Pose3D
*/
class CV_EXPORTS PoseCluster3D
{
public:
public:
PoseCluster3D()
{
//poseList.clear();
numVotes=0;
id=0;
};
}
PoseCluster3D(Pose3D* newPose)
{
//poseList.clear();
poseList.clear();
poseList.push_back(newPose);
numVotes=newPose->numVotes;
id=0;
};
}
PoseCluster3D(Pose3D* newPose, int newId)
{
//poseList.clear();
poseList.push_back(newPose);
this->numVotes = newPose->numVotes;
this->id = newId;
};
}
virtual ~PoseCluster3D()
{
numVotes=0;
id=0;
//poseList.clear();
};
{}
/**
* \brief Adds a new pose to the cluster. The pose should be "close" to the mean poses
* in order to preserve the consistency
* \param [in] newPose Pose to add to the cluster
*/
void addPose(Pose3D* newPose) ;
void addPose(Pose3D* newPose);
int writePoseCluster(FILE* f);
int readPoseCluster(FILE* f);
......@@ -176,6 +169,7 @@ class CV_EXPORTS PoseCluster3D
int numVotes;
int id;
};
} // namespace ppf_match_3d
} // namespace cv
......
......@@ -36,6 +36,7 @@
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
/**
** ppf_match_3d : Interfaces for matching 3d surfaces in 3d scenes. This module implements the algorithm from Bertram Drost and Slobodan Ilic.
** Use: Read a 3D model, load a 3D scene and match the model to the scene
......@@ -69,9 +70,9 @@ namespace ppf_match_3d
#define T_PPF_LENGTH 5
/**
* @struct THash
* @brief Struct, holding a node in the hashtable
*/
* @struct THash
* @brief Struct, holding a node in the hashtable
*/
typedef struct THash
{
int id;
......@@ -79,21 +80,21 @@ typedef struct THash
} THash;
/**
* @class PPF3DDetector
* @brief Class, allowing the load and matching 3D models.
* Typical Use:
*
* // Train a model
* ppf_match_3d::PPF3DDetector detector(0.05, 0.05);
* detector.trainModel(pc);
* // Search the model in a given scene
* vector < Pose3D* > results;
* detector.match(pcTest, results, 1.0/5.0,0.05);
*
*/
* @class PPF3DDetector
* @brief Class, allowing the load and matching 3D models.
* Typical Use:
*
* // Train a model
* ppf_match_3d::PPF3DDetector detector(0.05, 0.05);
* detector.trainModel(pc);
* // Search the model in a given scene
* vector < Pose3D* > results;
* detector.match(pcTest, results, 1.0/5.0,0.05);
*
*/
class CV_EXPORTS PPF3DDetector
{
public:
public:
/**
* \brief Empty constructor. Sets default arguments
......@@ -142,7 +143,7 @@ class CV_EXPORTS PPF3DDetector
void read(const FileNode& fn);
void write(FileStorage& fs) const;
protected:
protected:
double maxDist, angle_step, angleStepRadians, distance_step;
double samplingStepRelative, angleStepRelative, distanceStepRelative;
......@@ -160,8 +161,8 @@ class CV_EXPORTS PPF3DDetector
void clearTrainingModels();
private:
void computePPFFeatures( const double p1[4], const double n1[4],
private:
void computePPFFeatures(const double p1[4], const double n1[4],
const double p2[4], const double n2[4],
double f[4]);
......
......@@ -47,24 +47,24 @@ using namespace std;
using namespace cv;
using namespace ppf_match_3d;
static void help(std::string errorMessage)
static void help(const string& errorMessage)
{
std::cout<<"Program init error : "<<errorMessage<<std::endl;
std::cout<<"\nUsage : ppf_matching [input model file] [input scene file]"<<std::endl;
std::cout<<"\nPlease start again with new parameters"<<std::endl;
cout << "Program init error : "<< errorMessage << endl;
cout << "\nUsage : ppf_matching [input model file] [input scene file]"<< endl;
cout << "\nPlease start again with new parameters"<< endl;
}
int main(int argc, char** argv)
{
// welcome message
std::cout<< "****************************************************"<<std::endl;
std::cout<< "* Surface Matching demonstration : demonstrates the use of surface matching"
" using point pair features."<<std::endl;
std::cout<< "* The sample loads a model and a scene, where the model lies in a different"
cout << "****************************************************" << endl;
cout << "* Surface Matching demonstration : demonstrates the use of surface matching"
" using point pair features." << endl;
cout << "* The sample loads a model and a scene, where the model lies in a different"
" pose than the training.\n* It then trains the model and searches for it in the"
" input scene. The detected poses are further refined by ICP\n* and printed to the "
" standard output."<<std::endl;
std::cout<< "****************************************************"<<std::endl;
" standard output." << endl;
cout << "****************************************************" << endl;
if (argc < 3)
{
......@@ -73,15 +73,15 @@ int main(int argc, char** argv)
}
#if (defined __x86_64__ || defined _M_X64)
std::cout << "Running on 64 bits" << std::endl;
cout << "Running on 64 bits" << endl;
#else
std::cout << "Running on 32 bits" << std::endl;
cout << "Running on 32 bits" << endl;
#endif
#ifdef _OPENMP
std::cout << "Running with OpenMP" << std::endl;
cout << "Running with OpenMP" << endl;
#else
std::cout << "Running without OpenMP and without TBB" << std::endl;
cout << "Running without OpenMP and without TBB" << endl;
#endif
string modelFileName = (string)argv[1];
......
......@@ -533,7 +533,7 @@ static inline void dcmToAA(double *R, double *axis, double *angle)
* \param [in] angle Angle (In radians)
* \param [in] R 3x3 Rotation matrix
*/
static inline void aaToDCM(double *axis, double angle, double *R)
static inline void aaToDCM(double *axis, double angle, double *R)
{
double ident[9]={1,0,0,0,1,0,0,0,1};
double n[9] = { 0.0, -axis[2], axis[1],
......@@ -627,7 +627,7 @@ static inline void dcmToQuat(double *R, double *q)
* \param [in] R Rotation Matrix
*
*/
static inline void quatToDCM(double *q, double *R)
static inline void quatToDCM(double *q, double *R)
{
double sqw = q[0] * q[0];
double sqx = q[1] * q[1];
......
......@@ -195,8 +195,8 @@ static float getRejectionThreshold(float* r, int m, float outlierScale)
static void minimizePointToPlaneMetric(Mat Src, Mat Dst, Mat& X)
{
//Mat sub = Dst - Src;
Mat A=Mat(Src.rows, 6, CV_64F);
Mat b=Mat(Src.rows, 1, CV_64F);
Mat A = Mat(Src.rows, 6, CV_64F);
Mat b = Mat(Src.rows, 1, CV_64F);
#if defined _OPENMP
#pragma omp parallel for
......
......@@ -570,7 +570,6 @@ Mat addNoisePC(Mat pc, double scale)
return randT + pc;
}
//////////// COMPUTE NORMALS OF POINT CLOUD //////////////////////////////////
/*
The routines below use the eigenvectors of the local covariance matrix
to compute the normals of a point cloud.
......@@ -731,7 +730,6 @@ CV_EXPORTS int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNe
return 1;
}
//////////////////////////////////////// END OF NORMAL COMPUTATIONS ///////////////////////////////////
} // namespace ppf_match_3d
} // namespace cv
......@@ -46,14 +46,14 @@ namespace cv
namespace ppf_match_3d
{
// routines for assisting sort
static int qsortPoseCmp (const void * a, const void * b)
static int qsortPoseCmp(const void * a, const void * b)
{
Pose3D* pose1 = *(Pose3D**)a;
Pose3D* pose2 = *(Pose3D**)b;
return ( pose2->numVotes - pose1->numVotes );
}
static int sortPoseClusters (const PoseCluster3D* a, const PoseCluster3D* b)
static int sortPoseClusters(const PoseCluster3D* a, const PoseCluster3D* b)
{
return ( a->numVotes > b->numVotes );
}
......@@ -80,7 +80,6 @@ static KeyType hashPPF(const double f[4], const double AngleStep, const double D
int key[4]={d1,d2,d3,d4};
KeyType hashKey=0;
//hashMurmurx86(key, 4*sizeof(int), 42, &hashKey);
murmurHash(key, 4*sizeof(int), 42, &hashKey);
return hashKey;
......@@ -162,7 +161,7 @@ void PPF3DDetector::setSearchParams(const int numPoses, const double positionThr
}
// compute per point PPF as in paper
void PPF3DDetector::computePPFFeatures( const double p1[4], const double n1[4],
void PPF3DDetector::computePPFFeatures(const double p1[4], const double n1[4],
const double p2[4], const double n2[4],
double f[4])
{
......@@ -313,7 +312,6 @@ void PPF3DDetector::trainModel(const Mat &PC)
sampled_step = sampledStep;
ppf_step = ppfStep;
num_ref_points = numRefPoints;
//samplingStepRelative = sampling_step_relative;
sampledPC = sampled;
trained = true;
}
......@@ -478,7 +476,7 @@ int PPF3DDetector::clusterPoses(Pose3D** poseList, int numPoses, std::vector<Pos
return 0;
}
void PPF3DDetector::match(const Mat& pc, std::vector<Pose3D*>& results, const double RelativeSceneSampleStep, const double RelativeSceneDistance)
void PPF3DDetector::match(const Mat& pc, std::vector<Pose3D*>& results, const double relativeSceneSampleStep, const double relativeSceneDistance)
{
if (!trained)
{
......@@ -486,9 +484,9 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3D*>& results, const do
}
CV_Assert(pc.type() == CV_32F || pc.type() == CV_32FC1);
CV_Assert(RelativeSceneSampleStep<=1 && RelativeSceneSampleStep>0);
CV_Assert(relativeSceneSampleStep<=1 && relativeSceneSampleStep>0);
SceneSampleStep = (int)(1.0/RelativeSceneSampleStep);
SceneSampleStep = (int)(1.0/relativeSceneSampleStep);
//int numNeighbors = 10;
int numAngles = (int) (floor (2 * M_PI / angle_step));
......@@ -507,7 +505,7 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3D*>& results, const do
float dz = zRange[1] - zRange[0];
float diameter = sqrt ( dx * dx + dy * dy + dz * dz );
float distanceSampleStep = diameter * RelativeSceneDistance;*/
Mat sampled = samplePCByQuantization(pc, xRange, yRange, zRange, (float)RelativeSceneDistance, 0);
Mat sampled = samplePCByQuantization(pc, xRange, yRange, zRange, (float)relativeSceneDistance, 0);
// allocate the accumulator : Moved this to the inside of the loop
/*#if !defined (_OPENMP)
......@@ -687,9 +685,6 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3D*>& results, const do
}
free(poseList);
/*#if !defined (_OPENMP)
free(accumulator);
#endif*/
}
} // namespace ppf_match_3d
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment