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
2ac81901
Commit
2ac81901
authored
Jun 29, 2017
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9014 from sovrasov:compare_scalars_fix
parents
5f1b6ee8
35a1ecef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
arithm.cpp
modules/core/src/arithm.cpp
+5
-2
test_arithm.cpp
modules/core/test/test_arithm.cpp
+10
-0
No files found.
modules/core/src/arithm.cpp
View file @
2ac81901
...
...
@@ -1239,7 +1239,10 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
||
!
_src1
.
sameSize
(
_src2
)
||
_src1
.
type
()
!=
_src2
.
type
())
{
if
(
checkScalar
(
_src1
,
_src2
.
type
(),
_src1
.
kind
(),
_src2
.
kind
()))
bool
is_src1_scalar
=
checkScalar
(
_src1
,
_src2
.
type
(),
_src1
.
kind
(),
_src2
.
kind
());
bool
is_src2_scalar
=
checkScalar
(
_src2
,
_src1
.
type
(),
_src2
.
kind
(),
_src1
.
kind
());
if
(
is_src1_scalar
&&
!
is_src2_scalar
)
{
op
=
op
==
CMP_LT
?
CMP_GT
:
op
==
CMP_LE
?
CMP_GE
:
op
==
CMP_GE
?
CMP_LE
:
op
==
CMP_GT
?
CMP_LT
:
op
;
...
...
@@ -1247,7 +1250,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
compare
(
_src2
,
_src1
,
_dst
,
op
);
return
;
}
else
if
(
!
checkScalar
(
_src2
,
_src1
.
type
(),
_src2
.
kind
(),
_src1
.
kind
()
)
)
else
if
(
(
is_src1_scalar
&&
is_src2_scalar
)
||
(
!
is_src1_scalar
&&
!
is_src2_scalar
)
)
CV_Error
(
CV_StsUnmatchedSizes
,
"The operation is neither 'array op array' (where arrays have the same size and the same type), "
"nor 'array op scalar', nor 'scalar op array'"
);
...
...
modules/core/test/test_arithm.cpp
View file @
2ac81901
...
...
@@ -1922,3 +1922,13 @@ TEST(Compare, empty)
EXPECT_TRUE
(
dst1
.
empty
());
EXPECT_TRUE
(
dst2
.
empty
());
}
TEST
(
Compare
,
regression_8999
)
{
Mat_
<
double
>
A
(
4
,
1
);
A
<<
1
,
3
,
2
,
4
;
Mat_
<
double
>
B
(
1
,
1
);
B
<<
2
;
Mat
C
;
ASSERT_ANY_THROW
({
compare
(
A
,
B
,
C
,
CMP_LT
);
});
}
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