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
f0d277e4
Commit
f0d277e4
authored
Sep 26, 2018
by
Menghui Xie
Committed by
Vadim Pisarevsky
Sep 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M_PI changed to CV_PI (#12645)
* M_PI changed to CV_PI * M_PI changed to CV_PI * M_PI changed to CV_PI
parent
d8d025c3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
33 deletions
+33
-33
chessboard.cpp
modules/calib3d/src/chessboard.cpp
+31
-31
chessboard.hpp
modules/calib3d/src/chessboard.hpp
+1
-1
test_chesscorners.cpp
modules/calib3d/test/test_chesscorners.cpp
+1
-1
No files found.
modules/calib3d/src/chessboard.cpp
View file @
f0d277e4
...
@@ -22,11 +22,11 @@ namespace details {
...
@@ -22,11 +22,11 @@ namespace details {
// magic numbers used for chessboard corner detection
// magic numbers used for chessboard corner detection
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
const
float
CORNERS_SEARCH
=
0.5
F
;
// percentage of the edge length to the next corner used to find new corners
const
float
CORNERS_SEARCH
=
0.5
F
;
// percentage of the edge length to the next corner used to find new corners
const
float
MAX_ANGLE
=
float
(
48.0
/
180.0
*
M
_PI
);
// max angle between line segments supposed to be straight
const
float
MAX_ANGLE
=
float
(
48.0
/
180.0
*
CV
_PI
);
// max angle between line segments supposed to be straight
const
float
MIN_COS_ANGLE
=
float
(
cos
(
35.0
/
180
*
M
_PI
));
// min cos angle between board edges
const
float
MIN_COS_ANGLE
=
float
(
cos
(
35.0
/
180
*
CV
_PI
));
// min cos angle between board edges
const
float
MIN_RESPONSE_RATIO
=
0.1
F
;
const
float
MIN_RESPONSE_RATIO
=
0.1
F
;
const
float
ELLIPSE_WIDTH
=
0.35
F
;
// width of the search ellipse in percentage of its length
const
float
ELLIPSE_WIDTH
=
0.35
F
;
// width of the search ellipse in percentage of its length
const
float
RAD2DEG
=
float
(
180.0
/
M
_PI
);
const
float
RAD2DEG
=
float
(
180.0
/
CV
_PI
);
const
int
MAX_SYMMETRY_ERRORS
=
5
;
// maximal number of failures during point symmetry test (filtering out lines)
const
int
MAX_SYMMETRY_ERRORS
=
5
;
// maximal number of failures during point symmetry test (filtering out lines)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
...
@@ -214,7 +214,7 @@ int testPointSymmetry(cv::Mat mat,cv::Point2f pt,float dist,float max_error)
...
@@ -214,7 +214,7 @@ int testPointSymmetry(cv::Mat mat,cv::Point2f pt,float dist,float max_error)
int
count
=
0
;
int
count
=
0
;
cv
::
Mat
patch1
,
patch2
;
cv
::
Mat
patch1
,
patch2
;
cv
::
Point2f
center1
,
center2
;
cv
::
Point2f
center1
,
center2
;
for
(
double
angle
=
0
;
angle
<=
M_PI
;
angle
+=
M
_PI
*
0.1
)
for
(
double
angle
=
0
;
angle
<=
CV_PI
;
angle
+=
CV
_PI
*
0.1
)
{
{
cv
::
Point2f
n
(
float
(
cos
(
angle
)),
float
(
-
sin
(
angle
)));
cv
::
Point2f
n
(
float
(
cos
(
angle
)),
float
(
-
sin
(
angle
)));
center1
=
pt
+
dist
*
n
;
center1
=
pt
+
dist
*
n
;
...
@@ -284,7 +284,7 @@ void FastX::rotate(float angle,const cv::Mat &img,cv::Size size,cv::Mat &out)con
...
@@ -284,7 +284,7 @@ void FastX::rotate(float angle,const cv::Mat &img,cv::Size size,cv::Mat &out)con
}
}
else
else
{
{
cv
::
Mat
m
=
cv
::
getRotationMatrix2D
(
cv
::
Point2f
(
float
(
img
.
cols
*
0.5
),
float
(
img
.
rows
*
0.5
)),
float
(
angle
/
M
_PI
*
180
),
1
);
cv
::
Mat
m
=
cv
::
getRotationMatrix2D
(
cv
::
Point2f
(
float
(
img
.
cols
*
0.5
),
float
(
img
.
rows
*
0.5
)),
float
(
angle
/
CV
_PI
*
180
),
1
);
CV_Assert
(
m
.
type
()
==
CV_64FC1
);
CV_Assert
(
m
.
type
()
==
CV_64FC1
);
m
.
at
<
double
>
(
0
,
2
)
+=
0.5
*
(
size
.
width
-
img
.
cols
);
m
.
at
<
double
>
(
0
,
2
)
+=
0.5
*
(
size
.
width
-
img
.
cols
);
m
.
at
<
double
>
(
1
,
2
)
+=
0.5
*
(
size
.
height
-
img
.
rows
);
m
.
at
<
double
>
(
1
,
2
)
+=
0.5
*
(
size
.
height
-
img
.
rows
);
...
@@ -390,7 +390,7 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
...
@@ -390,7 +390,7 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
// assuming all elements of the same channel
// assuming all elements of the same channel
const
int
channels
=
rotated_images
.
front
().
channels
();
const
int
channels
=
rotated_images
.
front
().
channels
();
int
channels_1
=
channels
-
1
;
int
channels_1
=
channels
-
1
;
float
resolution
=
float
(
M
_PI
/
channels
);
float
resolution
=
float
(
CV
_PI
/
channels
);
float
angle
;
float
angle
;
float
val1
,
val2
,
val3
,
wrap_around
;
float
val1
,
val2
,
val3
,
wrap_around
;
...
@@ -436,9 +436,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
...
@@ -436,9 +436,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
{
{
angle
=
float
((
calcSubPos
(
val1
,
val2
,
val3
)
+
i
)
*
resolution
);
angle
=
float
((
calcSubPos
(
val1
,
val2
,
val3
)
+
i
)
*
resolution
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
+=
float
(
M
_PI
);
angle
+=
float
(
CV
_PI
);
else
if
(
angle
>
M
_PI
)
else
if
(
angle
>
CV
_PI
)
angle
-=
float
(
M
_PI
);
angle
-=
float
(
CV
_PI
);
angles_i
.
push_back
(
angle
);
angles_i
.
push_back
(
angle
);
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
}
}
...
@@ -447,9 +447,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
...
@@ -447,9 +447,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
{
{
angle
=
float
((
calcSubPos
(
val1
,
val2
,
val3
)
+
i
)
*
resolution
);
angle
=
float
((
calcSubPos
(
val1
,
val2
,
val3
)
+
i
)
*
resolution
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
+=
float
(
M
_PI
);
angle
+=
float
(
CV
_PI
);
else
if
(
angle
>
M
_PI
)
else
if
(
angle
>
CV
_PI
)
angle
-=
float
(
M
_PI
);
angle
-=
float
(
CV
_PI
);
angles_i
.
push_back
(
-
angle
);
angles_i
.
push_back
(
-
angle
);
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
}
}
...
@@ -463,9 +463,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
...
@@ -463,9 +463,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
{
{
angle
=
float
((
calcSubPos
(
val1
,
val2
,
wrap_around
)
+
channels
-
1
)
*
resolution
);
angle
=
float
((
calcSubPos
(
val1
,
val2
,
wrap_around
)
+
channels
-
1
)
*
resolution
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
+=
float
(
M
_PI
);
angle
+=
float
(
CV
_PI
);
else
if
(
angle
>
M
_PI
)
else
if
(
angle
>
CV
_PI
)
angle
-=
float
(
M
_PI
);
angle
-=
float
(
CV
_PI
);
angles_i
.
push_back
(
angle
);
angles_i
.
push_back
(
angle
);
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
}
}
...
@@ -474,9 +474,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
...
@@ -474,9 +474,9 @@ std::vector<std::vector<float> > FastX::calcAngles(const std::vector<cv::Mat> &r
{
{
angle
=
float
((
calcSubPos
(
val1
,
val2
,
wrap_around
)
+
channels
-
1
)
*
resolution
);
angle
=
float
((
calcSubPos
(
val1
,
val2
,
wrap_around
)
+
channels
-
1
)
*
resolution
);
if
(
angle
<
0
)
if
(
angle
<
0
)
angle
+=
float
(
M
_PI
);
angle
+=
float
(
CV
_PI
);
else
if
(
angle
>
M
_PI
)
else
if
(
angle
>
CV
_PI
)
angle
-=
float
(
M
_PI
);
angle
-=
float
(
CV
_PI
);
angles_i
.
push_back
(
-
angle
);
angles_i
.
push_back
(
-
angle
);
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
pt_iter
->
angle
=
360.0
F
-
angle
*
RAD2DEG
;
}
}
...
@@ -632,7 +632,7 @@ void FastX::detectImpl(const cv::Mat& _gray_image,
...
@@ -632,7 +632,7 @@ void FastX::detectImpl(const cv::Mat& _gray_image,
cv
::
Mat
rotated
,
filtered_h
,
filtered_v
;
cv
::
Mat
rotated
,
filtered_h
,
filtered_v
;
int
diag
=
int
(
sqrt
(
gray_image
.
rows
*
gray_image
.
rows
+
gray_image
.
cols
*
gray_image
.
cols
));
int
diag
=
int
(
sqrt
(
gray_image
.
rows
*
gray_image
.
rows
+
gray_image
.
cols
*
gray_image
.
cols
));
cv
::
Size
size
(
diag
,
diag
);
cv
::
Size
size
(
diag
,
diag
);
int
num
=
int
(
0.5001
*
M
_PI
/
parameters
.
resolution
);
int
num
=
int
(
0.5001
*
CV
_PI
/
parameters
.
resolution
);
std
::
vector
<
cv
::
Mat
>
images
;
std
::
vector
<
cv
::
Mat
>
images
;
images
.
resize
(
2
*
num
);
images
.
resize
(
2
*
num
);
int
scale_size
=
int
(
1
+
pow
(
2.0
,
scale
+
1
+
super_res
));
int
scale_size
=
int
(
1
+
pow
(
2.0
,
scale
+
1
+
super_res
));
...
@@ -722,7 +722,7 @@ cv::Point2f Ellipse::getCenter()const
...
@@ -722,7 +722,7 @@ cv::Point2f Ellipse::getCenter()const
void
Ellipse
::
draw
(
cv
::
InputOutputArray
img
,
const
cv
::
Scalar
&
color
)
const
void
Ellipse
::
draw
(
cv
::
InputOutputArray
img
,
const
cv
::
Scalar
&
color
)
const
{
{
cv
::
ellipse
(
img
,
center
,
axes
,
360
-
angle
/
M
_PI
*
180
,
0
,
360
,
color
);
cv
::
ellipse
(
img
,
center
,
axes
,
360
-
angle
/
CV
_PI
*
180
,
0
,
360
,
color
);
}
}
bool
Ellipse
::
contains
(
const
cv
::
Point2f
&
pt
)
const
bool
Ellipse
::
contains
(
const
cv
::
Point2f
&
pt
)
const
...
@@ -1542,10 +1542,10 @@ float Chessboard::Board::findMaxPoint(cv::flann::Index &index,const cv::Mat &dat
...
@@ -1542,10 +1542,10 @@ float Chessboard::Board::findMaxPoint(cv::flann::Index &index,const cv::Mat &dat
const
float
&
a0
=
*
(
val
+
2
);
const
float
&
a0
=
*
(
val
+
2
);
float
a1
=
fabs
(
a0
-
white_angle
);
float
a1
=
fabs
(
a0
-
white_angle
);
float
a2
=
fabs
(
a0
-
black_angle
);
float
a2
=
fabs
(
a0
-
black_angle
);
if
(
a1
>
M
_PI
*
0.5
)
if
(
a1
>
CV
_PI
*
0.5
)
a1
=
float
(
fabs
(
a1
-
M
_PI
));
a1
=
float
(
fabs
(
a1
-
CV
_PI
));
if
(
a2
>
M
_PI
*
0.5
)
if
(
a2
>
CV
_PI
*
0.5
)
a2
=
float
(
fabs
(
a2
-
M
_PI
));
a2
=
float
(
fabs
(
a2
-
CV
_PI
));
if
(
a1
<
MAX_ANGLE
||
a2
<
MAX_ANGLE
)
if
(
a1
<
MAX_ANGLE
||
a2
<
MAX_ANGLE
)
{
{
cv
::
Point2f
pt
(
*
val
,
*
(
val
+
1
));
cv
::
Point2f
pt
(
*
val
,
*
(
val
+
1
));
...
@@ -1788,7 +1788,7 @@ bool Chessboard::Board::estimateSearchArea(const cv::Point2f &p1,const cv::Point
...
@@ -1788,7 +1788,7 @@ bool Chessboard::Board::estimateSearchArea(const cv::Point2f &p1,const cv::Point
n
=
n
/
norm
;
n
=
n
/
norm
;
float
angle
=
acos
(
n
.
x
);
float
angle
=
acos
(
n
.
x
);
if
(
n
.
y
>
0
)
if
(
n
.
y
>
0
)
angle
=
float
(
2.0
F
*
M
_PI
-
angle
);
angle
=
float
(
2.0
F
*
CV
_PI
-
angle
);
n
=
p4
-
p3
;
n
=
p4
-
p3
;
norm
=
float
(
cv
::
norm
(
n
));
norm
=
float
(
cv
::
norm
(
n
));
double
delta
=
std
::
max
(
3.0
F
,
p
*
norm
);
double
delta
=
std
::
max
(
3.0
F
,
p
*
norm
);
...
@@ -2795,7 +2795,7 @@ void Chessboard::findKeyPoints(const cv::Mat& image, std::vector<KeyPoint>& keyp
...
@@ -2795,7 +2795,7 @@ void Chessboard::findKeyPoints(const cv::Mat& image, std::vector<KeyPoint>& keyp
para
.
branches
=
2
;
// this is always the case for checssboard corners
para
.
branches
=
2
;
// this is always the case for checssboard corners
para
.
strength
=
10
;
// minimal threshold
para
.
strength
=
10
;
// minimal threshold
para
.
resolution
=
float
(
M
_PI
*
0.25
);
// this gives the best results taking interpolation into account
para
.
resolution
=
float
(
CV
_PI
*
0.25
);
// this gives the best results taking interpolation into account
para
.
filter
=
1
;
para
.
filter
=
1
;
para
.
super_resolution
=
parameters
.
super_resolution
;
para
.
super_resolution
=
parameters
.
super_resolution
;
para
.
min_scale
=
parameters
.
min_scale
;
para
.
min_scale
=
parameters
.
min_scale
;
...
@@ -2846,7 +2846,7 @@ cv::Mat Chessboard::buildData(const std::vector<KeyPoint>& keypoints)const
...
@@ -2846,7 +2846,7 @@ cv::Mat Chessboard::buildData(const std::vector<KeyPoint>& keypoints)const
{
{
(
*
val
++
)
=
iter
->
pt
.
x
;
(
*
val
++
)
=
iter
->
pt
.
x
;
(
*
val
++
)
=
iter
->
pt
.
y
;
(
*
val
++
)
=
iter
->
pt
.
y
;
(
*
val
++
)
=
float
(
2.0
*
M_PI
-
iter
->
angle
/
180.0
*
M
_PI
);
(
*
val
++
)
=
float
(
2.0
*
CV_PI
-
iter
->
angle
/
180.0
*
CV
_PI
);
(
*
val
++
)
=
iter
->
response
;
(
*
val
++
)
=
iter
->
response
;
}
}
return
data
;
return
data
;
...
@@ -2876,13 +2876,13 @@ std::vector<cv::KeyPoint> Chessboard::getInitialPoints(cv::flann::Index &flann_i
...
@@ -2876,13 +2876,13 @@ std::vector<cv::KeyPoint> Chessboard::getInitialPoints(cv::flann::Index &flann_i
continue
;
continue
;
const
float
&
angle
=
data
.
at
<
float
>
(
*
ids_iter
,
2
);
const
float
&
angle
=
data
.
at
<
float
>
(
*
ids_iter
,
2
);
float
angle_temp
=
fabs
(
angle
-
white_angle
);
float
angle_temp
=
fabs
(
angle
-
white_angle
);
if
(
angle_temp
>
M
_PI
*
0.5
)
if
(
angle_temp
>
CV
_PI
*
0.5
)
angle_temp
=
float
(
fabs
(
angle_temp
-
M
_PI
));
angle_temp
=
float
(
fabs
(
angle_temp
-
CV
_PI
));
if
(
angle_temp
>
MAX_ANGLE
)
if
(
angle_temp
>
MAX_ANGLE
)
{
{
angle_temp
=
fabs
(
angle
-
black_angle
);
angle_temp
=
fabs
(
angle
-
black_angle
);
if
(
angle_temp
>
M
_PI
*
0.5
)
if
(
angle_temp
>
CV
_PI
*
0.5
)
angle_temp
=
float
(
fabs
(
angle_temp
-
M
_PI
));
angle_temp
=
float
(
fabs
(
angle_temp
-
CV
_PI
));
if
(
angle_temp
>
MAX_ANGLE
)
if
(
angle_temp
>
MAX_ANGLE
)
continue
;
continue
;
}
}
...
...
modules/calib3d/src/chessboard.hpp
View file @
f0d277e4
...
@@ -32,7 +32,7 @@ class FastX : public cv::Feature2D
...
@@ -32,7 +32,7 @@ class FastX : public cv::Feature2D
Parameters
()
Parameters
()
{
{
strength
=
40
;
strength
=
40
;
resolution
=
float
(
M
_PI
*
0.25
);
resolution
=
float
(
CV
_PI
*
0.25
);
branches
=
2
;
branches
=
2
;
min_scale
=
2
;
min_scale
=
2
;
max_scale
=
5
;
max_scale
=
5
;
...
...
modules/calib3d/test/test_chesscorners.cpp
View file @
f0d277e4
...
@@ -566,7 +566,7 @@ bool CV_ChessboardDetectorTest::checkByGeneratorHighAccuracy()
...
@@ -566,7 +566,7 @@ bool CV_ChessboardDetectorTest::checkByGeneratorHighAccuracy()
for
(
int
i
=
15
;
i
<
90
;
i
=
i
+
15
)
for
(
int
i
=
15
;
i
<
90
;
i
=
i
+
15
)
{
{
// project 3d points to new camera
// project 3d points to new camera
Vec3f
rvec
(
0.0
F
,
0.05
F
,
float
(
float
(
i
)
/
180.0
*
M
_PI
));
Vec3f
rvec
(
0.0
F
,
0.05
F
,
float
(
float
(
i
)
/
180.0
*
CV
_PI
));
Vec3f
tvec
(
0
,
0
,
0
);
Vec3f
tvec
(
0
,
0
,
0
);
cv
::
Mat
k
=
(
cv
::
Mat_
<
double
>
(
3
,
3
)
<<
fx
/
2
,
0
,
center
.
x
*
2
,
0
,
fy
/
2
,
center
.
y
,
0
,
0
,
1
);
cv
::
Mat
k
=
(
cv
::
Mat_
<
double
>
(
3
,
3
)
<<
fx
/
2
,
0
,
center
.
x
*
2
,
0
,
fy
/
2
,
center
.
y
,
0
,
0
,
1
);
cv
::
projectPoints
(
pts3d
,
rvec
,
tvec
,
k
,
cv
::
Mat
(),
pts2_all
);
cv
::
projectPoints
(
pts3d
,
rvec
,
tvec
,
k
,
cv
::
Mat
(),
pts2_all
);
...
...
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