Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
3c8bd19e
Commit
3c8bd19e
authored
Dec 10, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5309 from paroj:sampsonDist
parents
5d6292fc
16fcd78f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
calib3d.hpp
modules/calib3d/include/opencv2/calib3d.hpp
+11
-0
fundam.cpp
modules/calib3d/src/fundam.cpp
+20
-0
No files found.
modules/calib3d/include/opencv2/calib3d.hpp
View file @
3c8bd19e
...
...
@@ -1403,6 +1403,17 @@ CV_EXPORTS_W void reprojectImageTo3D( InputArray disparity,
bool
handleMissingValues
=
false
,
int
ddepth
=
-
1
);
/** @brief Calculates the Sampson Distance between two points.
The function sampsonDistance calculates and returns the first order approximation of the geometric error as:
\f[sd( \texttt{pt1} , \texttt{pt2} )= \frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2}{(\texttt{F} \cdot \texttt{pt1})(0) + (\texttt{F} \cdot \texttt{pt1})(1) + (\texttt{F}^t \cdot \texttt{pt2})(0) + (\texttt{F}^t \cdot \texttt{pt2})(1)}\f]
The fundamental matrix may be calculated using the cv::findFundamentalMat function. See HZ 11.4.3 for details.
@param pt1 first homogeneous 2d point
@param pt2 second homogeneous 2d point
@param F fundamental matrix
*/
CV_EXPORTS_W
double
sampsonDistance
(
InputArray
pt1
,
InputArray
pt2
,
InputArray
F
);
/** @brief Computes an optimal affine transformation between two 3D point sets.
@param src First input 3D point set.
...
...
modules/calib3d/src/fundam.cpp
View file @
3c8bd19e
...
...
@@ -1039,4 +1039,24 @@ void cv::convertPointsHomogeneous( InputArray _src, OutputArray _dst )
convertPointsToHomogeneous
(
_src
,
_dst
);
}
double
cv
::
sampsonDistance
(
InputArray
_pt1
,
InputArray
_pt2
,
InputArray
_F
)
{
CV_Assert
(
_pt1
.
type
()
==
CV_64F
&&
_pt1
.
type
()
==
CV_64F
&&
_F
.
type
()
==
CV_64F
);
CV_DbgAssert
(
_pt1
.
rows
()
==
3
&&
_F
.
size
()
==
Size
(
3
,
3
)
&&
_pt1
.
rows
()
==
_pt2
.
rows
());
Mat
pt1
(
_pt1
.
getMat
());
Mat
pt2
(
_pt2
.
getMat
());
Mat
F
(
_F
.
getMat
());
Vec3d
F_pt1
=
*
F
.
ptr
<
Matx33d
>
()
*
*
pt1
.
ptr
<
Vec3d
>
();
Vec3d
Ft_pt2
=
F
.
ptr
<
Matx33d
>
()
->
t
()
*
*
pt2
.
ptr
<
Vec3d
>
();
double
v
=
pt2
.
ptr
<
Vec3d
>
()
->
dot
(
F_pt1
);
// square
Ft_pt2
=
Ft_pt2
.
mul
(
Ft_pt2
);
F_pt1
=
F_pt1
.
mul
(
F_pt1
);
return
v
*
v
/
(
F_pt1
[
0
]
+
F_pt1
[
1
]
+
Ft_pt2
[
0
]
+
Ft_pt2
[
1
]);
}
/* End of file. */
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