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
0bc44376
Commit
0bc44376
authored
Nov 02, 2015
by
Viet Dinh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug #5599
solves equations more correctly, eliminates “nan” error.
parent
fdf549b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
2 deletions
+36
-2
mathfuncs.cpp
modules/core/src/mathfuncs.cpp
+36
-2
No files found.
modules/core/src/mathfuncs.cpp
View file @
0bc44376
...
@@ -2495,7 +2495,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
...
@@ -2495,7 +2495,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
coeffs
[
i
]
=
C
(
rcoeffs
[
i
],
0
);
coeffs
[
i
]
=
C
(
rcoeffs
[
i
],
0
);
}
}
C
p
(
1
,
0
),
r
(
0.4
,
0.9
);
C
p
(
1
,
0
),
r
(
1
,
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
{
...
@@ -2511,12 +2511,46 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
...
@@ -2511,12 +2511,46 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
{
{
p
=
roots
[
i
];
p
=
roots
[
i
];
C
num
=
coeffs
[
n
],
denom
=
coeffs
[
n
];
C
num
=
coeffs
[
n
],
denom
=
coeffs
[
n
];
int
num_same_root
=
1
;
for
(
j
=
0
;
j
<
n
;
j
++
)
for
(
j
=
0
;
j
<
n
;
j
++
)
{
{
num
=
num
*
p
+
coeffs
[
n
-
j
-
1
];
num
=
num
*
p
+
coeffs
[
n
-
j
-
1
];
if
(
j
!=
i
)
denom
=
denom
*
(
p
-
roots
[
j
]);
if
(
j
!=
i
)
{
if
(
(
p
-
roots
[
j
]).
re
!=
0
||
(
p
-
roots
[
j
]).
im
!=
0
)
denom
=
denom
*
(
p
-
roots
[
j
]);
else
num_same_root
++
;
}
}
}
num
/=
denom
;
num
/=
denom
;
if
(
num_same_root
>
1
)
{
for
(
j
=
0
;
j
<
num_same_root
/
2
;
j
++
)
{
double
old_num_re
=
num
.
re
;
double
old_num_im
=
num
.
im
;
num
.
re
=
old_num_re
*
old_num_re
+
old_num_im
*
old_num_im
;
Mat
num_re_arr
=
(
Mat_
<
double
>
(
1
,
1
)
<<
num
.
re
);
cv
::
sqrt
(
num_re_arr
,
num_re_arr
);
num
.
re
=
num_re_arr
.
at
<
double
>
(
0
,
0
);
num
.
re
+=
old_num_re
;
num
.
im
=
num
.
re
-
old_num_re
;
num
.
re
/=
2
;
num_re_arr
.
at
<
double
>
(
0
,
0
)
=
num
.
re
;
cv
::
sqrt
(
num_re_arr
,
num_re_arr
);
num
.
re
=
num_re_arr
.
at
<
double
>
(
0
,
0
);
Mat
num_im_arr
=
(
Mat_
<
double
>
(
1
,
1
)
<<
num
.
im
);
num
.
im
/=
2
;
num_im_arr
.
at
<
double
>
(
0
,
0
)
=
num
.
re
;
cv
::
sqrt
(
num_im_arr
,
num_im_arr
);
num
.
im
=
num_im_arr
.
at
<
double
>
(
0
,
0
);
if
(
old_num_re
<
0
)
num
.
im
=
-
num
.
im
;
}
}
roots
[
i
]
=
p
-
num
;
roots
[
i
]
=
p
-
num
;
maxDiff
=
max
(
maxDiff
,
abs
(
num
));
maxDiff
=
max
(
maxDiff
,
abs
(
num
));
}
}
...
...
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