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
bb930665
Commit
bb930665
authored
Dec 31, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16249 from alalek:check_size
parents
7b28d5b4
523f0819
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
4 deletions
+49
-4
calibration.cpp
modules/calib3d/src/calibration.cpp
+4
-2
check.hpp
modules/core/include/opencv2/core/check.hpp
+2
-0
check.cpp
modules/core/src/check.cpp
+8
-0
test_misc.cpp
modules/core/test/test_misc.cpp
+35
-2
No files found.
modules/calib3d/src/calibration.cpp
View file @
bb930665
...
@@ -3221,8 +3221,10 @@ void cv::Rodrigues(InputArray _src, OutputArray _dst, OutputArray _jacobian)
...
@@ -3221,8 +3221,10 @@ void cv::Rodrigues(InputArray _src, OutputArray _dst, OutputArray _jacobian)
CV_INSTRUMENT_REGION
();
CV_INSTRUMENT_REGION
();
Mat
src
=
_src
.
getMat
();
Mat
src
=
_src
.
getMat
();
CV_Check
(
src
.
rows
,
(
src
.
rows
==
1
&&
src
.
cols
==
3
)
||
(
src
.
rows
==
3
&&
src
.
cols
==
1
)
||
const
Size
srcSz
=
src
.
size
();
(
src
.
rows
==
1
&&
src
.
cols
==
1
&&
src
.
channels
()
==
3
)
||
(
src
.
rows
==
3
&&
src
.
cols
==
3
),
CV_Check
(
srcSz
,
srcSz
==
Size
(
3
,
1
)
||
srcSz
==
Size
(
1
,
3
)
||
(
srcSz
==
Size
(
1
,
1
)
&&
src
.
channels
()
==
3
)
||
srcSz
==
Size
(
3
,
3
),
"Input matrix must be 1x3 or 3x1 for a rotation vector, or 3x3 for a rotation matrix"
);
"Input matrix must be 1x3 or 3x1 for a rotation vector, or 3x3 for a rotation matrix"
);
bool
v2m
=
src
.
cols
==
1
||
src
.
rows
==
1
;
bool
v2m
=
src
.
cols
==
1
||
src
.
rows
==
1
;
...
...
modules/core/include/opencv2/core/check.hpp
View file @
bb930665
...
@@ -69,6 +69,7 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const
...
@@ -69,6 +69,7 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
size_t
v1
,
const
size_t
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
size_t
v1
,
const
size_t
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
float
v1
,
const
float
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
float
v1
,
const
float
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
double
v1
,
const
double
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
double
v1
,
const
double
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
Size_
<
int
>
v1
,
const
Size_
<
int
>
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatDepth
(
const
int
v1
,
const
int
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatDepth
(
const
int
v1
,
const
int
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatType
(
const
int
v1
,
const
int
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatType
(
const
int
v1
,
const
int
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatChannels
(
const
int
v1
,
const
int
v2
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatChannels
(
const
int
v1
,
const
int
v2
,
const
CheckContext
&
ctx
);
...
@@ -77,6 +78,7 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& c
...
@@ -77,6 +78,7 @@ CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& c
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
size_t
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
size_t
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
float
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
float
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
double
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
double
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_auto
(
const
Size_
<
int
>
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatDepth
(
const
int
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatDepth
(
const
int
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatType
(
const
int
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatType
(
const
int
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatChannels
(
const
int
v
,
const
CheckContext
&
ctx
);
CV_EXPORTS
void
CV_NORETURN
check_failed_MatChannels
(
const
int
v
,
const
CheckContext
&
ctx
);
...
...
modules/core/src/check.cpp
View file @
bb930665
...
@@ -113,6 +113,10 @@ void check_failed_auto(const double v1, const double v2, const CheckContext& ctx
...
@@ -113,6 +113,10 @@ void check_failed_auto(const double v1, const double v2, const CheckContext& ctx
{
{
check_failed_auto_
<
double
>
(
v1
,
v2
,
ctx
);
check_failed_auto_
<
double
>
(
v1
,
v2
,
ctx
);
}
}
void
check_failed_auto
(
const
Size_
<
int
>
v1
,
const
Size_
<
int
>
v2
,
const
CheckContext
&
ctx
)
{
check_failed_auto_
<
Size_
<
int
>
>
(
v1
,
v2
,
ctx
);
}
template
<
typename
T
>
static
CV_NORETURN
template
<
typename
T
>
static
CV_NORETURN
...
@@ -163,6 +167,10 @@ void check_failed_auto(const double v, const CheckContext& ctx)
...
@@ -163,6 +167,10 @@ void check_failed_auto(const double v, const CheckContext& ctx)
{
{
check_failed_auto_
<
double
>
(
v
,
ctx
);
check_failed_auto_
<
double
>
(
v
,
ctx
);
}
}
void
check_failed_auto
(
const
Size_
<
int
>
v
,
const
CheckContext
&
ctx
)
{
check_failed_auto_
<
Size_
<
int
>
>
(
v
,
ctx
);
}
}}
// namespace
}}
// namespace
modules/core/test/test_misc.cpp
View file @
bb930665
...
@@ -671,7 +671,8 @@ TEST(Core_Check, testMatType_fail_2)
...
@@ -671,7 +671,8 @@ TEST(Core_Check, testMatType_fail_2)
EXPECT_STREQ
(
e
.
err
.
c_str
(),
EXPECT_STREQ
(
e
.
err
.
c_str
(),
"> Unsupported src:
\n
"
"> Unsupported src:
\n
"
"> 'src_type == CV_32FC1 || src_type == CV_32FC3'
\n
"
"> 'src_type == CV_32FC1 || src_type == CV_32FC3'
\n
"
"> where
\n
> 'src_type' is 0 (CV_8UC1)
\n
"
"> where
\n
"
"> 'src_type' is 0 (CV_8UC1)
\n
"
);
);
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
...
@@ -737,7 +738,39 @@ TEST(Core_Check, testMatDepth_fail_2)
...
@@ -737,7 +738,39 @@ TEST(Core_Check, testMatDepth_fail_2)
EXPECT_STREQ
(
e
.
err
.
c_str
(),
EXPECT_STREQ
(
e
.
err
.
c_str
(),
"> Unsupported src:
\n
"
"> Unsupported src:
\n
"
"> 'src_depth == CV_32F || src_depth == CV_64F'
\n
"
"> 'src_depth == CV_32F || src_depth == CV_64F'
\n
"
"> where
\n
> 'src_depth' is 0 (CV_8U)
\n
"
"> where
\n
"
"> 'src_depth' is 0 (CV_8U)
\n
"
);
}
catch
(
const
std
::
exception
&
e
)
{
FAIL
()
<<
"Unexpected C++ exception: "
<<
e
.
what
();
}
catch
(...)
{
FAIL
()
<<
"Unexpected unknown exception"
;
}
}
void
test_check_Size_1
(
const
Size
&
srcSz
)
{
CV_Check
(
srcSz
,
srcSz
==
Size
(
4
,
3
),
"Unsupported src size"
);
}
TEST
(
Core_Check
,
testSize_1
)
{
try
{
test_check_Size_1
(
Size
(
2
,
1
));
FAIL
()
<<
"Unreachable code called"
;
}
catch
(
const
cv
::
Exception
&
e
)
{
EXPECT_STREQ
(
e
.
err
.
c_str
(),
"> Unsupported src size:
\n
"
"> 'srcSz == Size(4, 3)'
\n
"
"> where
\n
"
"> 'srcSz' is [2 x 1]
\n
"
);
);
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
...
...
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