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
7cc0b0f9
Commit
7cc0b0f9
authored
Jan 11, 2017
by
Tetragramm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add case including both moments empty.
parent
d33d37ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
matchcontours.cpp
modules/imgproc/src/matchcontours.cpp
+20
-5
No files found.
modules/imgproc/src/matchcontours.cpp
View file @
7cc0b0f9
...
...
@@ -50,7 +50,7 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double
eps
=
1.e-5
;
double
mmm
;
double
result
=
0
;
bool
any
Results
=
false
;
bool
any
A
=
false
,
anyB
=
false
;
HuMoments
(
moments
(
contour1
),
ma
);
HuMoments
(
moments
(
contour2
),
mb
);
...
...
@@ -63,6 +63,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double
ama
=
fabs
(
ma
[
i
]
);
double
amb
=
fabs
(
mb
[
i
]
);
if
(
ama
>
0
)
anyA
=
true
;
if
(
amb
>
0
)
anyB
=
true
;
if
(
ma
[
i
]
>
0
)
sma
=
1
;
else
if
(
ma
[
i
]
<
0
)
...
...
@@ -81,7 +86,6 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
ama
=
1.
/
(
sma
*
log10
(
ama
));
amb
=
1.
/
(
smb
*
log10
(
amb
));
result
+=
fabs
(
-
ama
+
amb
);
anyResults
=
true
;
}
}
break
;
...
...
@@ -92,6 +96,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double
ama
=
fabs
(
ma
[
i
]
);
double
amb
=
fabs
(
mb
[
i
]
);
if
(
ama
>
0
)
anyA
=
true
;
if
(
amb
>
0
)
anyB
=
true
;
if
(
ma
[
i
]
>
0
)
sma
=
1
;
else
if
(
ma
[
i
]
<
0
)
...
...
@@ -110,7 +119,6 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
ama
=
sma
*
log10
(
ama
);
amb
=
smb
*
log10
(
amb
);
result
+=
fabs
(
-
ama
+
amb
);
anyResults
=
true
;
}
}
break
;
...
...
@@ -121,6 +129,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double
ama
=
fabs
(
ma
[
i
]
);
double
amb
=
fabs
(
mb
[
i
]
);
if
(
ama
>
0
)
anyA
=
true
;
if
(
amb
>
0
)
anyB
=
true
;
if
(
ma
[
i
]
>
0
)
sma
=
1
;
else
if
(
ma
[
i
]
<
0
)
...
...
@@ -141,7 +154,6 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
mmm
=
fabs
(
(
ama
-
amb
)
/
ama
);
if
(
result
<
mmm
)
result
=
mmm
;
anyResults
=
true
;
}
}
break
;
...
...
@@ -149,7 +161,10 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
CV_Error
(
CV_StsBadArg
,
"Unknown comparison method"
);
}
if
(
!
anyResults
)
//If anyA and anyB are both true, the result is correct.
//If anyA and anyB are both false, the distance is 0, perfect match.
//If only one is true, then it's a false 0 and return large error.
if
(
anyA
!=
anyB
)
result
=
DBL_MAX
;
return
result
;
...
...
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