Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
995b6963
Commit
995b6963
authored
Sep 02, 2014
by
Bence Magyar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cosmetic changes
parent
d1193e31
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
71 additions
and
83 deletions
+71
-83
icp.hpp
...surface_matching/include/opencv2/surface_matching/icp.hpp
+14
-14
pose_3d.hpp
...ace_matching/include/opencv2/surface_matching/pose_3d.hpp
+12
-18
ppf_match_3d.hpp
...atching/include/opencv2/surface_matching/ppf_match_3d.hpp
+20
-19
t_hash_int.hpp
..._matching/include/opencv2/surface_matching/t_hash_int.hpp
+0
-0
ppf_load_match.cpp
modules/surface_matching/samples/ppf_load_match.cpp
+14
-14
c_utils.hpp
modules/surface_matching/src/c_utils.hpp
+2
-2
hash_murmur64.hpp
modules/surface_matching/src/hash_murmur64.hpp
+0
-0
icp.cpp
modules/surface_matching/src/icp.cpp
+2
-2
pose_3d.cpp
modules/surface_matching/src/pose_3d.cpp
+0
-0
ppf_helpers.cpp
modules/surface_matching/src/ppf_helpers.cpp
+0
-2
ppf_match_3d.cpp
modules/surface_matching/src/ppf_match_3d.cpp
+7
-12
No files found.
modules/surface_matching/include/opencv2/surface_matching/icp.hpp
View file @
995b6963
...
...
@@ -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
;
...
...
modules/surface_matching/include/opencv2/surface_matching/pose_3d.hpp
View file @
995b6963
...
...
@@ -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
...
...
modules/surface_matching/include/opencv2/surface_matching/ppf_match_3d.hpp
View file @
995b6963
...
...
@@ -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
]);
...
...
modules/surface_matching/include/opencv2/surface_matching/t_hash_int.hpp
View file @
995b6963
modules/surface_matching/samples/ppf_load_match.cpp
View file @
995b6963
...
...
@@ -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
<<
"
\n
Usage : ppf_matching [input model file] [input scene file]"
<<
std
::
endl
;
std
::
cout
<<
"
\n
Please start again with new parameters"
<<
std
::
endl
;
cout
<<
"Program init error : "
<<
errorMessage
<<
endl
;
cout
<<
"
\n
Usage : ppf_matching [input model file] [input scene file]"
<<
endl
;
cout
<<
"
\n
Please 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
];
...
...
modules/surface_matching/src/c_utils.hpp
View file @
995b6963
...
...
@@ -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
];
...
...
modules/surface_matching/src/hash_murmur64.hpp
View file @
995b6963
modules/surface_matching/src/icp.cpp
View file @
995b6963
...
...
@@ -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
...
...
modules/surface_matching/src/pose_3d.cpp
View file @
995b6963
modules/surface_matching/src/ppf_helpers.cpp
View file @
995b6963
...
...
@@ -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
modules/surface_matching/src/ppf_match_3d.cpp
View file @
995b6963
...
...
@@ -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
R
elativeSceneDistance
)
void
PPF3DDetector
::
match
(
const
Mat
&
pc
,
std
::
vector
<
Pose3D
*>&
results
,
const
double
relativeSceneSampleStep
,
const
double
r
elativeSceneDistance
)
{
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
&&
R
elativeSceneSampleStep
>
0
);
CV_Assert
(
relativeSceneSampleStep
<=
1
&&
r
elativeSceneSampleStep
>
0
);
SceneSampleStep
=
(
int
)(
1.0
/
R
elativeSceneSampleStep
);
SceneSampleStep
=
(
int
)(
1.0
/
r
elativeSceneSampleStep
);
//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
)
R
elativeSceneDistance
,
0
);
Mat
sampled
=
samplePCByQuantization
(
pc
,
xRange
,
yRange
,
zRange
,
(
float
)
r
elativeSceneDistance
,
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment