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
85ade61e
Commit
85ade61e
authored
Dec 27, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
3d44e9ad
5f2fed0e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
372 additions
and
65 deletions
+372
-65
mat.hpp
modules/core/include/opencv2/core/mat.hpp
+60
-0
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+19
-0
test_operations.cpp
modules/core/test/test_operations.cpp
+72
-0
draw.cpp
modules/features2d/src/draw.cpp
+27
-13
test_drawing.cpp
modules/features2d/test/test_drawing.cpp
+78
-0
window_w32.cpp
modules/highgui/src/window_w32.cpp
+40
-12
filter.cpp
modules/imgproc/src/filter.cpp
+0
-0
test_filter.cpp
modules/imgproc/test/test_filter.cpp
+29
-5
matchers.cpp
modules/stitching/src/matchers.cpp
+1
-0
openpose.cpp
samples/dnn/openpose.cpp
+17
-28
openpose.py
samples/dnn/openpose.py
+29
-7
No files found.
modules/core/include/opencv2/core/mat.hpp
View file @
85ade61e
...
@@ -3559,6 +3559,10 @@ CV_EXPORTS MatExpr operator + (const Mat& m, const MatExpr& e);
...
@@ -3559,6 +3559,10 @@ CV_EXPORTS MatExpr operator + (const Mat& m, const MatExpr& e);
CV_EXPORTS
MatExpr
operator
+
(
const
MatExpr
&
e
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
+
(
const
MatExpr
&
e
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
+
(
const
Scalar
&
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
+
(
const
Scalar
&
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
+
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
CV_EXPORTS
MatExpr
operator
+
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
+
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
+
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
+
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
+
b
;
}
CV_EXPORTS
MatExpr
operator
-
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
-
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
-
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
-
(
const
Mat
&
a
,
const
Scalar
&
s
);
...
@@ -3568,6 +3572,10 @@ CV_EXPORTS MatExpr operator - (const Mat& m, const MatExpr& e);
...
@@ -3568,6 +3572,10 @@ CV_EXPORTS MatExpr operator - (const Mat& m, const MatExpr& e);
CV_EXPORTS
MatExpr
operator
-
(
const
MatExpr
&
e
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
-
(
const
MatExpr
&
e
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
-
(
const
Scalar
&
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
-
(
const
Scalar
&
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
-
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
CV_EXPORTS
MatExpr
operator
-
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
-
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
-
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
-
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
-
b
;
}
CV_EXPORTS
MatExpr
operator
-
(
const
Mat
&
m
);
CV_EXPORTS
MatExpr
operator
-
(
const
Mat
&
m
);
CV_EXPORTS
MatExpr
operator
-
(
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
-
(
const
MatExpr
&
e
);
...
@@ -3580,6 +3588,10 @@ CV_EXPORTS MatExpr operator * (const Mat& m, const MatExpr& e);
...
@@ -3580,6 +3588,10 @@ CV_EXPORTS MatExpr operator * (const Mat& m, const MatExpr& e);
CV_EXPORTS
MatExpr
operator
*
(
const
MatExpr
&
e
,
double
s
);
CV_EXPORTS
MatExpr
operator
*
(
const
MatExpr
&
e
,
double
s
);
CV_EXPORTS
MatExpr
operator
*
(
double
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
*
(
double
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
*
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
CV_EXPORTS
MatExpr
operator
*
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
*
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
+
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
*
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
+
b
;
}
CV_EXPORTS
MatExpr
operator
/
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
/
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
/
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
/
(
const
Mat
&
a
,
double
s
);
...
@@ -3589,52 +3601,100 @@ CV_EXPORTS MatExpr operator / (const Mat& m, const MatExpr& e);
...
@@ -3589,52 +3601,100 @@ CV_EXPORTS MatExpr operator / (const Mat& m, const MatExpr& e);
CV_EXPORTS
MatExpr
operator
/
(
const
MatExpr
&
e
,
double
s
);
CV_EXPORTS
MatExpr
operator
/
(
const
MatExpr
&
e
,
double
s
);
CV_EXPORTS
MatExpr
operator
/
(
double
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
/
(
double
s
,
const
MatExpr
&
e
);
CV_EXPORTS
MatExpr
operator
/
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
CV_EXPORTS
MatExpr
operator
/
(
const
MatExpr
&
e1
,
const
MatExpr
&
e2
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
/
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
/
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
/
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
/
b
;
}
CV_EXPORTS
MatExpr
operator
<
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
<
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
<
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
<
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
<
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
<
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
<
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
<
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
<
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
<
b
;
}
CV_EXPORTS
MatExpr
operator
<=
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
<=
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
<=
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
<=
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
<=
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
<=
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
<=
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
<=
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
<=
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
<=
b
;
}
CV_EXPORTS
MatExpr
operator
==
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
==
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
==
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
==
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
==
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
==
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
==
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
==
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
==
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
==
b
;
}
CV_EXPORTS
MatExpr
operator
!=
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
!=
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
!=
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
!=
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
!=
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
!=
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
!=
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
!=
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
!=
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
!=
b
;
}
CV_EXPORTS
MatExpr
operator
>=
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
>=
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
>=
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
>=
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
>=
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
>=
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
>=
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
>=
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
>=
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
>=
b
;
}
CV_EXPORTS
MatExpr
operator
>
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
>
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
>
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
>
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
operator
>
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
>
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
>
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
>
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
>
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
>
b
;
}
CV_EXPORTS
MatExpr
operator
&
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
&
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
&
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
&
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
&
(
const
Scalar
&
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
&
(
const
Scalar
&
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
&
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
&
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
&
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
&
b
;
}
CV_EXPORTS
MatExpr
operator
|
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
|
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
|
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
|
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
|
(
const
Scalar
&
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
|
(
const
Scalar
&
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
|
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
|
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
|
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
|
b
;
}
CV_EXPORTS
MatExpr
operator
^
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
^
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
operator
^
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
^
(
const
Mat
&
a
,
const
Scalar
&
s
);
CV_EXPORTS
MatExpr
operator
^
(
const
Scalar
&
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
operator
^
(
const
Scalar
&
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
^
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
a
^
Mat
(
b
);
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
operator
^
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
Mat
(
a
)
^
b
;
}
CV_EXPORTS
MatExpr
operator
~
(
const
Mat
&
m
);
CV_EXPORTS
MatExpr
operator
~
(
const
Mat
&
m
);
CV_EXPORTS
MatExpr
min
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
min
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
min
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
min
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
min
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
min
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
min
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
min
(
a
,
Mat
(
b
));
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
min
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
min
(
Mat
(
a
),
b
);
}
CV_EXPORTS
MatExpr
max
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
max
(
const
Mat
&
a
,
const
Mat
&
b
);
CV_EXPORTS
MatExpr
max
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
max
(
const
Mat
&
a
,
double
s
);
CV_EXPORTS
MatExpr
max
(
double
s
,
const
Mat
&
a
);
CV_EXPORTS
MatExpr
max
(
double
s
,
const
Mat
&
a
);
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
max
(
const
Mat
&
a
,
const
Matx
<
_Tp
,
m
,
n
>&
b
)
{
return
max
(
a
,
Mat
(
b
));
}
template
<
typename
_Tp
,
int
m
,
int
n
>
static
inline
MatExpr
max
(
const
Matx
<
_Tp
,
m
,
n
>&
a
,
const
Mat
&
b
)
{
return
max
(
Mat
(
a
),
b
);
}
/** @brief Calculates an absolute value of each matrix element.
/** @brief Calculates an absolute value of each matrix element.
...
...
modules/core/include/opencv2/core/operations.hpp
View file @
85ade61e
...
@@ -258,48 +258,67 @@ Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) c
...
@@ -258,48 +258,67 @@ Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) c
template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, A, B) \
template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, const A, B)
template<typename _Tp> CV_MAT_AUG_OPERATOR1(op, cvop, const A, B)
#define CV_MAT_AUG_OPERATOR_TN(op, cvop, A) \
template<typename _Tp, int m, int n> static inline A& operator op (A& a, const Matx<_Tp,m,n>& b) { cvop; return a; } \
template<typename _Tp, int m, int n> static inline const A& operator op (const A& a, const Matx<_Tp,m,n>& b) { cvop; return a; }
CV_MAT_AUG_OPERATOR
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
+=
,
cv
::
add
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_TN
(
+=
,
cv
::
add
(
a
,
Mat
(
b
),
a
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
+=
,
cv
::
add
(
a
,
Mat
(
b
),
a
),
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
-=
,
cv
::
subtract
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_TN
(
-=
,
cv
::
subtract
(
a
,
Mat
(
b
),
a
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
-=
,
cv
::
subtract
(
a
,
Mat
(
b
),
a
),
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
*=
,
cv
::
gemm
(
a
,
b
,
1
,
Mat
(),
0
,
a
,
0
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
*=
,
cv
::
gemm
(
a
,
b
,
1
,
Mat
(),
0
,
a
,
0
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
*=
,
cv
::
gemm
(
a
,
b
,
1
,
Mat
(),
0
,
a
,
0
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
*=
,
cv
::
gemm
(
a
,
b
,
1
,
Mat
(),
0
,
a
,
0
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
*=
,
cv
::
gemm
(
a
,
b
,
1
,
Mat
(),
0
,
a
,
0
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
*=
,
cv
::
gemm
(
a
,
b
,
1
,
Mat
(),
0
,
a
,
0
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
*=
,
a
.
convertTo
(
a
,
-
1
,
b
),
Mat
,
double
)
CV_MAT_AUG_OPERATOR
(
*=
,
a
.
convertTo
(
a
,
-
1
,
b
),
Mat
,
double
)
CV_MAT_AUG_OPERATOR_T
(
*=
,
a
.
convertTo
(
a
,
-
1
,
b
),
Mat_
<
_Tp
>
,
double
)
CV_MAT_AUG_OPERATOR_T
(
*=
,
a
.
convertTo
(
a
,
-
1
,
b
),
Mat_
<
_Tp
>
,
double
)
CV_MAT_AUG_OPERATOR_TN
(
*=
,
cv
::
gemm
(
a
,
Mat
(
b
),
1
,
Mat
(),
0
,
a
,
0
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
*=
,
cv
::
gemm
(
a
,
Mat
(
b
),
1
,
Mat
(),
0
,
a
,
0
),
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
/=
,
cv
::
divide
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
/=
,
cv
::
divide
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
/=
,
cv
::
divide
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
/=
,
cv
::
divide
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
/=
,
cv
::
divide
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
/=
,
cv
::
divide
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
/=
,
a
.
convertTo
((
Mat
&
)
a
,
-
1
,
1.
/
b
),
Mat
,
double
)
CV_MAT_AUG_OPERATOR
(
/=
,
a
.
convertTo
((
Mat
&
)
a
,
-
1
,
1.
/
b
),
Mat
,
double
)
CV_MAT_AUG_OPERATOR_T
(
/=
,
a
.
convertTo
((
Mat
&
)
a
,
-
1
,
1.
/
b
),
Mat_
<
_Tp
>
,
double
)
CV_MAT_AUG_OPERATOR_T
(
/=
,
a
.
convertTo
((
Mat
&
)
a
,
-
1
,
1.
/
b
),
Mat_
<
_Tp
>
,
double
)
CV_MAT_AUG_OPERATOR_TN
(
/=
,
cv
::
divide
(
a
,
Mat
(
b
),
a
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
/=
,
cv
::
divide
(
a
,
Mat
(
b
),
a
),
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
&=
,
cv
::
bitwise_and
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_TN
(
&=
,
cv
::
bitwise_and
(
a
,
Mat
(
b
),
a
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
&=
,
cv
::
bitwise_and
(
a
,
Mat
(
b
),
a
),
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
|=
,
cv
::
bitwise_or
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_TN
(
|=
,
cv
::
bitwise_or
(
a
,
Mat
(
b
),
a
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
|=
,
cv
::
bitwise_or
(
a
,
Mat
(
b
),
a
),
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat
,
Mat
)
CV_MAT_AUG_OPERATOR
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat
)
CV_MAT_AUG_OPERATOR_T
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Scalar
)
CV_MAT_AUG_OPERATOR_T
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_T
(
^=
,
cv
::
bitwise_xor
(
a
,
b
,
a
),
Mat_
<
_Tp
>
,
Mat_
<
_Tp
>
)
CV_MAT_AUG_OPERATOR_TN
(
^=
,
cv
::
bitwise_xor
(
a
,
Mat
(
b
),
a
),
Mat
)
CV_MAT_AUG_OPERATOR_TN
(
^=
,
cv
::
bitwise_xor
(
a
,
Mat
(
b
),
a
),
Mat_
<
_Tp
>
)
#undef CV_MAT_AUG_OPERATOR_TN
#undef CV_MAT_AUG_OPERATOR_T
#undef CV_MAT_AUG_OPERATOR_T
#undef CV_MAT_AUG_OPERATOR
#undef CV_MAT_AUG_OPERATOR
#undef CV_MAT_AUG_OPERATOR1
#undef CV_MAT_AUG_OPERATOR1
...
...
modules/core/test/test_operations.cpp
View file @
85ade61e
...
@@ -69,6 +69,7 @@ protected:
...
@@ -69,6 +69,7 @@ protected:
bool
TestVec
();
bool
TestVec
();
bool
TestMatxMultiplication
();
bool
TestMatxMultiplication
();
bool
TestMatxElementwiseDivison
();
bool
TestMatxElementwiseDivison
();
bool
TestMatMatxCastSum
();
bool
TestSubMatAccess
();
bool
TestSubMatAccess
();
bool
TestExp
();
bool
TestExp
();
bool
TestSVD
();
bool
TestSVD
();
...
@@ -885,6 +886,74 @@ bool CV_OperationsTest::TestMatxMultiplication()
...
@@ -885,6 +886,74 @@ bool CV_OperationsTest::TestMatxMultiplication()
return
true
;
return
true
;
}
}
bool
CV_OperationsTest
::
TestMatMatxCastSum
()
{
try
{
Mat
ref1
=
(
Mat_
<
double
>
(
3
,
1
)
<<
1
,
2
,
3
);
Mat
ref2
=
(
Mat_
<
double
>
(
3
,
1
)
<<
3
,
4
,
5
);
Mat
ref3
=
Mat
::
ones
(
3
,
1
,
CV_64FC1
);
Mat
mat
=
Mat
::
zeros
(
3
,
1
,
CV_64FC1
);
Mat
tst1
=
ref1
.
clone
();
Mat_
<
double
>
tst2
=
ref2
.
clone
();
Matx
<
double
,
3
,
1
>
tst3
(
1
,
2
,
3
);
Vec3d
tst4
(
3
,
4
,
5
);
Scalar
tst5
(
1
,
2
,
3
);
Mat
res
;
res
=
mat
+
tst1
;
CHECK_DIFF_FLT
(
res
,
ref1
);
res
=
mat
+
tst2
;
CHECK_DIFF_FLT
(
res
,
ref2
);
res
=
mat
+
tst3
;
CHECK_DIFF_FLT
(
res
,
ref1
);
res
=
mat
+
tst4
;
CHECK_DIFF_FLT
(
res
,
ref2
);
res
=
mat
+
tst5
;
CHECK_DIFF_FLT
(
res
,
ref3
);
res
=
mat
+
1
;
CHECK_DIFF_FLT
(
res
,
ref3
);
cv
::
add
(
mat
,
tst1
,
res
);
CHECK_DIFF_FLT
(
res
,
ref1
);
cv
::
add
(
mat
,
tst2
,
res
);
CHECK_DIFF_FLT
(
res
,
ref2
);
cv
::
add
(
mat
,
tst3
,
res
);
CHECK_DIFF_FLT
(
res
,
ref1
);
cv
::
add
(
mat
,
tst4
,
res
);
CHECK_DIFF_FLT
(
res
,
ref2
);
cv
::
add
(
mat
,
tst5
,
res
);
CHECK_DIFF_FLT
(
res
,
ref3
);
cv
::
add
(
mat
,
1
,
res
);
CHECK_DIFF_FLT
(
res
,
ref3
);
res
=
mat
.
clone
();
res
+=
tst1
;
CHECK_DIFF_FLT
(
res
,
ref1
);
res
=
mat
.
clone
();
res
+=
tst2
;
CHECK_DIFF_FLT
(
res
,
ref2
);
res
=
mat
.
clone
();
res
+=
tst3
;
CHECK_DIFF_FLT
(
res
,
ref1
);
res
=
mat
.
clone
();
res
+=
tst4
;
CHECK_DIFF_FLT
(
res
,
ref2
);
res
=
mat
.
clone
();
res
+=
tst5
;
CHECK_DIFF_FLT
(
res
,
ref3
);
res
=
mat
.
clone
();
res
+=
1
;
CHECK_DIFF_FLT
(
res
,
ref3
);
}
catch
(
const
test_excep
&
e
)
{
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"%s
\n
"
,
e
.
s
.
c_str
());
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_MISMATCH
);
return
false
;
}
return
true
;
}
bool
CV_OperationsTest
::
TestMatxElementwiseDivison
()
bool
CV_OperationsTest
::
TestMatxElementwiseDivison
()
{
{
try
try
...
@@ -1135,6 +1204,9 @@ void CV_OperationsTest::run( int /* start_from */)
...
@@ -1135,6 +1204,9 @@ void CV_OperationsTest::run( int /* start_from */)
if
(
!
TestMatxElementwiseDivison
())
if
(
!
TestMatxElementwiseDivison
())
return
;
return
;
if
(
!
TestMatMatxCastSum
())
return
;
if
(
!
TestSubMatAccess
())
if
(
!
TestSubMatAccess
())
return
;
return
;
...
...
modules/features2d/src/draw.cpp
View file @
85ade61e
...
@@ -95,9 +95,9 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
...
@@ -95,9 +95,9 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
if
(
!
(
flags
&
DrawMatchesFlags
::
DRAW_OVER_OUTIMG
)
)
if
(
!
(
flags
&
DrawMatchesFlags
::
DRAW_OVER_OUTIMG
)
)
{
{
if
(
image
.
type
()
==
CV_8UC3
)
if
(
image
.
type
()
==
CV_8UC3
||
image
.
type
()
==
CV_8UC4
)
{
{
image
.
copyTo
(
outImage
);
image
.
copyTo
(
outImage
);
}
}
else
if
(
image
.
type
()
==
CV_8UC1
)
else
if
(
image
.
type
()
==
CV_8UC1
)
{
{
...
@@ -105,7 +105,7 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
...
@@ -105,7 +105,7 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
}
}
else
else
{
{
CV_Error
(
Error
::
StsBadArg
,
"Incorrect type of input image
.
\n
"
);
CV_Error
(
Error
::
StsBadArg
,
"Incorrect type of input image
: "
+
typeToString
(
image
.
type
())
);
}
}
}
}
...
@@ -122,6 +122,25 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
...
@@ -122,6 +122,25 @@ void drawKeypoints( InputArray image, const std::vector<KeyPoint>& keypoints, In
}
}
}
}
static
void
_prepareImage
(
InputArray
src
,
const
Mat
&
dst
)
{
CV_CheckType
(
src
.
type
(),
src
.
type
()
==
CV_8UC1
||
src
.
type
()
==
CV_8UC3
||
src
.
type
()
==
CV_8UC4
,
"Unsupported source image"
);
CV_CheckType
(
dst
.
type
(),
dst
.
type
()
==
CV_8UC3
||
dst
.
type
()
==
CV_8UC4
,
"Unsupported destination image"
);
const
int
src_cn
=
src
.
channels
();
const
int
dst_cn
=
dst
.
channels
();
if
(
src_cn
==
dst_cn
)
src
.
copyTo
(
dst
);
else
if
(
src_cn
==
1
)
cvtColor
(
src
,
dst
,
dst_cn
==
3
?
COLOR_GRAY2BGR
:
COLOR_GRAY2BGRA
);
else
if
(
src_cn
==
3
&&
dst_cn
==
4
)
cvtColor
(
src
,
dst
,
COLOR_BGR2BGRA
);
else
if
(
src_cn
==
4
&&
dst_cn
==
3
)
cvtColor
(
src
,
dst
,
COLOR_BGRA2BGR
);
else
CV_Error
(
Error
::
StsInternal
,
""
);
}
static
void
_prepareImgAndDrawKeypoints
(
InputArray
img1
,
const
std
::
vector
<
KeyPoint
>&
keypoints1
,
static
void
_prepareImgAndDrawKeypoints
(
InputArray
img1
,
const
std
::
vector
<
KeyPoint
>&
keypoints1
,
InputArray
img2
,
const
std
::
vector
<
KeyPoint
>&
keypoints2
,
InputArray
img2
,
const
std
::
vector
<
KeyPoint
>&
keypoints2
,
InputOutputArray
_outImg
,
Mat
&
outImg1
,
Mat
&
outImg2
,
InputOutputArray
_outImg
,
Mat
&
outImg1
,
Mat
&
outImg2
,
...
@@ -140,21 +159,16 @@ static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector<KeyP
...
@@ -140,21 +159,16 @@ static void _prepareImgAndDrawKeypoints( InputArray img1, const std::vector<KeyP
}
}
else
else
{
{
_outImg
.
create
(
size
,
CV_MAKETYPE
(
img1
.
depth
(),
3
)
);
const
int
cn1
=
img1
.
channels
(),
cn2
=
img2
.
channels
();
const
int
out_cn
=
std
::
max
(
3
,
std
::
max
(
cn1
,
cn2
));
_outImg
.
create
(
size
,
CV_MAKETYPE
(
img1
.
depth
(),
out_cn
));
outImg
=
_outImg
.
getMat
();
outImg
=
_outImg
.
getMat
();
outImg
=
Scalar
::
all
(
0
);
outImg
=
Scalar
::
all
(
0
);
outImg1
=
outImg
(
Rect
(
0
,
0
,
img1size
.
width
,
img1size
.
height
)
);
outImg1
=
outImg
(
Rect
(
0
,
0
,
img1size
.
width
,
img1size
.
height
)
);
outImg2
=
outImg
(
Rect
(
img1size
.
width
,
0
,
img2size
.
width
,
img2size
.
height
)
);
outImg2
=
outImg
(
Rect
(
img1size
.
width
,
0
,
img2size
.
width
,
img2size
.
height
)
);
if
(
img1
.
type
()
==
CV_8U
)
_prepareImage
(
img1
,
outImg1
);
cvtColor
(
img1
,
outImg1
,
COLOR_GRAY2BGR
);
_prepareImage
(
img2
,
outImg2
);
else
img1
.
copyTo
(
outImg1
);
if
(
img2
.
type
()
==
CV_8U
)
cvtColor
(
img2
,
outImg2
,
COLOR_GRAY2BGR
);
else
img2
.
copyTo
(
outImg2
);
}
}
// draw keypoints
// draw keypoints
...
...
modules/features2d/test/test_drawing.cpp
0 → 100644
View file @
85ade61e
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2018, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
#include "test_precomp.hpp"
namespace
opencv_test
{
namespace
{
static
Mat
getReference_DrawKeypoint
(
int
cn
)
{
static
Mat
ref
=
(
Mat_
<
uint8_t
>
(
11
,
11
)
<<
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
15
,
54
,
15
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
76
,
217
,
217
,
221
,
81
,
1
,
1
,
1
,
1
,
1
,
100
,
224
,
111
,
57
,
115
,
225
,
101
,
1
,
1
,
1
,
44
,
215
,
100
,
1
,
1
,
1
,
101
,
214
,
44
,
1
,
1
,
54
,
212
,
57
,
1
,
1
,
1
,
55
,
212
,
55
,
1
,
1
,
40
,
215
,
104
,
1
,
1
,
1
,
105
,
215
,
40
,
1
,
1
,
1
,
102
,
221
,
111
,
55
,
115
,
222
,
103
,
1
,
1
,
1
,
1
,
1
,
76
,
218
,
217
,
220
,
81
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
15
,
55
,
15
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
);
Mat
res
;
cvtColor
(
ref
,
res
,
(
cn
==
4
)
?
COLOR_GRAY2BGRA
:
COLOR_GRAY2BGR
);
return
res
;
}
typedef
testing
::
TestWithParam
<
MatType
>
Features2D_drawKeypoints
;
TEST_P
(
Features2D_drawKeypoints
,
Accuracy
)
{
const
int
cn
=
CV_MAT_CN
(
GetParam
());
Mat
inpImg
(
11
,
11
,
GetParam
(),
Scalar
(
1
,
1
,
1
,
255
)),
outImg
;
std
::
vector
<
KeyPoint
>
keypoints
(
1
,
KeyPoint
(
5
,
5
,
1
));
drawKeypoints
(
inpImg
,
keypoints
,
outImg
,
Scalar
::
all
(
255
));
ASSERT_EQ
(
outImg
.
channels
(),
(
cn
==
4
)
?
4
:
3
);
Mat
ref_
=
getReference_DrawKeypoint
(
cn
);
EXPECT_EQ
(
0
,
cv
::
norm
(
outImg
,
ref_
,
NORM_INF
));
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
Features2D_drawKeypoints
,
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
));
typedef
testing
::
TestWithParam
<
tuple
<
MatType
,
MatType
>
>
Features2D_drawMatches
;
TEST_P
(
Features2D_drawMatches
,
Accuracy
)
{
Mat
inpImg1
(
11
,
11
,
get
<
0
>
(
GetParam
()),
Scalar
(
1
,
1
,
1
,
255
));
Mat
inpImg2
(
11
,
11
,
get
<
1
>
(
GetParam
()),
Scalar
(
2
,
2
,
2
,
255
)),
outImg2
,
outImg
;
std
::
vector
<
KeyPoint
>
keypoints
(
1
,
KeyPoint
(
5
,
5
,
1
));
// Get outImg2 using drawKeypoints assuming that it works correctly (see the test above).
drawKeypoints
(
inpImg2
,
keypoints
,
outImg2
,
Scalar
::
all
(
255
));
ASSERT_EQ
(
outImg2
.
channels
(),
(
inpImg2
.
channels
()
==
4
)
?
4
:
3
);
// Merge both references.
const
int
cn
=
max
(
3
,
max
(
inpImg1
.
channels
(),
inpImg2
.
channels
()));
if
(
cn
==
4
&&
outImg2
.
channels
()
==
3
)
cvtColor
(
outImg2
,
outImg2
,
COLOR_BGR2BGRA
);
Mat
ref_
=
getReference_DrawKeypoint
(
cn
);
Mat
concattedRef
;
hconcat
(
ref_
,
outImg2
,
concattedRef
);
std
::
vector
<
DMatch
>
matches
;
drawMatches
(
inpImg1
,
keypoints
,
inpImg2
,
keypoints
,
matches
,
outImg
,
Scalar
::
all
(
255
),
Scalar
::
all
(
255
));
ASSERT_EQ
(
outImg
.
channels
(),
cn
);
EXPECT_EQ
(
0
,
cv
::
norm
(
outImg
,
concattedRef
,
NORM_INF
));
}
INSTANTIATE_TEST_CASE_P
(
/**/
,
Features2D_drawMatches
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
),
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
)
));
}}
// namespace
modules/highgui/src/window_w32.cpp
View file @
85ade61e
...
@@ -66,6 +66,7 @@
...
@@ -66,6 +66,7 @@
#include <functional>
#include <functional>
#include "opencv2/highgui.hpp"
#include "opencv2/highgui.hpp"
#include <GL/gl.h>
#include <GL/gl.h>
#include "opencv2/core/opengl.hpp"
#endif
#endif
static
const
char
*
trackbar_text
=
static
const
char
*
trackbar_text
=
...
@@ -1144,20 +1145,20 @@ static void icvUpdateWindowPos( CvWindow* window )
...
@@ -1144,20 +1145,20 @@ static void icvUpdateWindowPos( CvWindow* window )
{
{
RECT
rmw
,
rw
=
icvCalcWindowRect
(
window
);
RECT
rmw
,
rw
=
icvCalcWindowRect
(
window
);
MoveWindow
(
window
->
hwnd
,
rw
.
left
,
rw
.
top
,
MoveWindow
(
window
->
hwnd
,
rw
.
left
,
rw
.
top
,
rw
.
right
-
rw
.
left
+
1
,
rw
.
bottom
-
rw
.
top
+
1
,
FALSE
);
rw
.
right
-
rw
.
left
,
rw
.
bottom
-
rw
.
top
,
FALSE
);
GetClientRect
(
window
->
hwnd
,
&
rw
);
GetClientRect
(
window
->
hwnd
,
&
rw
);
GetWindowRect
(
window
->
frame
,
&
rmw
);
GetWindowRect
(
window
->
frame
,
&
rmw
);
// Resize the mainhWnd window in order to make the bitmap fit into the child window
// Resize the mainhWnd window in order to make the bitmap fit into the child window
MoveWindow
(
window
->
frame
,
rmw
.
left
,
rmw
.
top
,
MoveWindow
(
window
->
frame
,
rmw
.
left
,
rmw
.
top
,
rmw
.
right
-
rmw
.
left
+
size
.
cx
-
rw
.
right
+
rw
.
left
,
size
.
cx
+
(
rmw
.
right
-
rmw
.
left
)
-
(
rw
.
right
-
rw
.
left
)
,
rmw
.
bottom
-
rmw
.
top
+
size
.
cy
-
rw
.
bottom
+
rw
.
top
,
TRUE
);
size
.
cy
+
(
rmw
.
bottom
-
rmw
.
top
)
-
(
rw
.
bottom
-
rw
.
top
)
,
TRUE
);
}
}
}
}
rect
=
icvCalcWindowRect
(
window
);
rect
=
icvCalcWindowRect
(
window
);
MoveWindow
(
window
->
hwnd
,
rect
.
left
,
rect
.
top
,
MoveWindow
(
window
->
hwnd
,
rect
.
left
,
rect
.
top
,
rect
.
right
-
rect
.
left
+
1
,
rect
.
right
-
rect
.
left
,
rect
.
bottom
-
rect
.
top
+
1
,
TRUE
);
rect
.
bottom
-
rect
.
top
,
TRUE
);
}
}
CV_IMPL
void
CV_IMPL
void
...
@@ -1263,18 +1264,18 @@ CV_IMPL void cvResizeWindow(const char* name, int width, int height )
...
@@ -1263,18 +1264,18 @@ CV_IMPL void cvResizeWindow(const char* name, int width, int height )
{
{
rw
=
icvCalcWindowRect
(
window
);
rw
=
icvCalcWindowRect
(
window
);
MoveWindow
(
window
->
hwnd
,
rw
.
left
,
rw
.
top
,
MoveWindow
(
window
->
hwnd
,
rw
.
left
,
rw
.
top
,
rw
.
right
-
rw
.
left
+
1
,
rw
.
bottom
-
rw
.
top
+
1
,
FALSE
);
rw
.
right
-
rw
.
left
,
rw
.
bottom
-
rw
.
top
,
FALSE
);
GetClientRect
(
window
->
hwnd
,
&
rw
);
GetClientRect
(
window
->
hwnd
,
&
rw
);
GetWindowRect
(
window
->
frame
,
&
rmw
);
GetWindowRect
(
window
->
frame
,
&
rmw
);
// Resize the mainhWnd window in order to make the bitmap fit into the child window
// Resize the mainhWnd window in order to make the bitmap fit into the child window
MoveWindow
(
window
->
frame
,
rmw
.
left
,
rmw
.
top
,
MoveWindow
(
window
->
frame
,
rmw
.
left
,
rmw
.
top
,
rmw
.
right
-
rmw
.
left
+
width
-
rw
.
right
+
rw
.
left
,
width
+
(
rmw
.
right
-
rmw
.
left
)
-
(
rw
.
right
-
rw
.
left
)
,
rmw
.
bottom
-
rmw
.
top
+
height
-
rw
.
bottom
+
rw
.
top
,
TRUE
);
height
+
(
rmw
.
bottom
-
rmw
.
top
)
-
(
rw
.
bottom
-
rw
.
top
)
,
TRUE
);
}
}
rect
=
icvCalcWindowRect
(
window
);
rect
=
icvCalcWindowRect
(
window
);
MoveWindow
(
window
->
hwnd
,
rect
.
left
,
rect
.
top
,
MoveWindow
(
window
->
hwnd
,
rect
.
left
,
rect
.
top
,
rect
.
right
-
rect
.
left
+
1
,
rect
.
bottom
-
rect
.
top
+
1
,
TRUE
);
rect
.
right
-
rect
.
left
,
rect
.
bottom
-
rect
.
top
,
TRUE
);
__END__
;
__END__
;
}
}
...
@@ -1421,7 +1422,20 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
...
@@ -1421,7 +1422,20 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
GetClientRect
(
window
->
hwnd
,
&
rect
);
GetClientRect
(
window
->
hwnd
,
&
rect
);
SIZE
size
=
{
0
,
0
};
SIZE
size
=
{
0
,
0
};
icvGetBitmapData
(
window
,
&
size
,
0
,
0
);
#ifdef HAVE_OPENGL
if
(
window
->
useGl
)
{
cv
::
ogl
::
Texture2D
*
texObj
=
static_cast
<
cv
::
ogl
::
Texture2D
*>
(
window
->
glDrawData
);
size
.
cx
=
texObj
->
cols
();
size
.
cy
=
texObj
->
rows
();
}
else
{
icvGetBitmapData
(
window
,
&
size
,
0
,
0
);
}
#else
icvGetBitmapData
(
window
,
&
size
,
0
,
0
);
#endif
window
->
on_mouse
(
event
,
pt
.
x
*
size
.
cx
/
MAX
(
rect
.
right
-
rect
.
left
,
1
),
window
->
on_mouse
(
event
,
pt
.
x
*
size
.
cx
/
MAX
(
rect
.
right
-
rect
.
left
,
1
),
pt
.
y
*
size
.
cy
/
MAX
(
rect
.
bottom
-
rect
.
top
,
1
),
flags
,
pt
.
y
*
size
.
cy
/
MAX
(
rect
.
bottom
-
rect
.
top
,
1
),
flags
,
...
@@ -1561,8 +1575,8 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
...
@@ -1561,8 +1575,8 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
RECT
rect
=
icvCalcWindowRect
(
window
);
RECT
rect
=
icvCalcWindowRect
(
window
);
pos
->
x
=
rect
.
left
;
pos
->
x
=
rect
.
left
;
pos
->
y
=
rect
.
top
;
pos
->
y
=
rect
.
top
;
pos
->
cx
=
rect
.
right
-
rect
.
left
+
1
;
pos
->
cx
=
rect
.
right
-
rect
.
left
;
pos
->
cy
=
rect
.
bottom
-
rect
.
top
+
1
;
pos
->
cy
=
rect
.
bottom
-
rect
.
top
;
}
}
break
;
break
;
...
@@ -1615,7 +1629,21 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
...
@@ -1615,7 +1629,21 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
SIZE
size
=
{
0
,
0
};
SIZE
size
=
{
0
,
0
};
GetClientRect
(
window
->
hwnd
,
&
rect
);
GetClientRect
(
window
->
hwnd
,
&
rect
);
#ifdef HAVE_OPENGL
if
(
window
->
useGl
)
{
cv
::
ogl
::
Texture2D
*
texObj
=
static_cast
<
cv
::
ogl
::
Texture2D
*>
(
window
->
glDrawData
);
size
.
cx
=
texObj
->
cols
();
size
.
cy
=
texObj
->
rows
();
}
else
{
icvGetBitmapData
(
window
,
&
size
,
0
,
0
);
}
#else
icvGetBitmapData
(
window
,
&
size
,
0
,
0
);
icvGetBitmapData
(
window
,
&
size
,
0
,
0
);
#endif
window
->
on_mouse
(
event
,
pt
.
x
*
size
.
cx
/
MAX
(
rect
.
right
-
rect
.
left
,
1
),
window
->
on_mouse
(
event
,
pt
.
x
*
size
.
cx
/
MAX
(
rect
.
right
-
rect
.
left
,
1
),
pt
.
y
*
size
.
cy
/
MAX
(
rect
.
bottom
-
rect
.
top
,
1
),
flags
,
pt
.
y
*
size
.
cy
/
MAX
(
rect
.
bottom
-
rect
.
top
,
1
),
flags
,
...
...
modules/imgproc/src/filter.cpp
View file @
85ade61e
This diff is collapsed.
Click to expand it.
modules/imgproc/test/test_filter.cpp
View file @
85ade61e
...
@@ -403,9 +403,9 @@ void CV_FilterTest::get_test_array_types_and_sizes( int test_case_idx,
...
@@ -403,9 +403,9 @@ void CV_FilterTest::get_test_array_types_and_sizes( int test_case_idx,
{
{
CV_FilterBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
CV_FilterBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
RNG
&
rng
=
ts
->
get_rng
();
RNG
&
rng
=
ts
->
get_rng
();
int
depth
=
cvtest
::
randInt
(
rng
)
%
3
;
int
depth
=
cvtest
::
randInt
(
rng
)
%
4
;
int
cn
=
CV_MAT_CN
(
types
[
INPUT
][
0
]);
int
cn
=
CV_MAT_CN
(
types
[
INPUT
][
0
]);
depth
=
depth
==
0
?
CV_8U
:
depth
==
1
?
CV_16U
:
CV_32F
;
depth
=
depth
==
0
?
CV_8U
:
depth
==
1
?
CV_16U
:
depth
==
2
?
CV_16S
:
CV_32F
;
types
[
INPUT
][
0
]
=
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
cn
);
types
[
INPUT
][
0
]
=
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
cn
);
}
}
...
@@ -457,10 +457,11 @@ void CV_DerivBaseTest::get_test_array_types_and_sizes( int test_case_idx,
...
@@ -457,10 +457,11 @@ void CV_DerivBaseTest::get_test_array_types_and_sizes( int test_case_idx,
{
{
RNG
&
rng
=
ts
->
get_rng
();
RNG
&
rng
=
ts
->
get_rng
();
CV_FilterBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
CV_FilterBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
int
depth
=
cvtest
::
randInt
(
rng
)
%
2
;
int
depth
=
cvtest
::
randInt
(
rng
)
%
4
;
depth
=
depth
==
0
?
CV_8U
:
CV_32F
;
depth
=
depth
==
0
?
CV_8U
:
depth
==
1
?
CV_16U
:
depth
==
2
?
CV_16S
:
CV_32F
;
types
[
INPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
1
);
types
[
INPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
1
);
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_MAKETYPE
(
depth
==
CV_8U
?
CV_16S
:
CV_32F
,
1
);
int
sameDepth
=
cvtest
::
randInt
(
rng
)
%
2
;
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
sameDepth
?
depth
:
CV_MAKETYPE
(
depth
==
CV_8U
?
CV_16S
:
CV_32F
,
1
);
_aperture_size
=
(
cvtest
::
randInt
(
rng
)
%
5
)
*
2
-
1
;
_aperture_size
=
(
cvtest
::
randInt
(
rng
)
%
5
)
*
2
-
1
;
sizes
[
INPUT
][
1
]
=
aperture_size
=
cvSize
(
_aperture_size
,
_aperture_size
);
sizes
[
INPUT
][
1
]
=
aperture_size
=
cvSize
(
_aperture_size
,
_aperture_size
);
}
}
...
@@ -2211,4 +2212,27 @@ TEST(Imgproc_MedianBlur, hires_regression_13409)
...
@@ -2211,4 +2212,27 @@ TEST(Imgproc_MedianBlur, hires_regression_13409)
ASSERT_EQ
(
0.0
,
cvtest
::
norm
(
dst_hires
(
Rect
(
516
,
516
,
1016
,
1016
)),
dst_ref
(
Rect
(
4
,
4
,
1016
,
1016
)),
NORM_INF
));
ASSERT_EQ
(
0.0
,
cvtest
::
norm
(
dst_hires
(
Rect
(
516
,
516
,
1016
,
1016
)),
dst_ref
(
Rect
(
4
,
4
,
1016
,
1016
)),
NORM_INF
));
}
}
TEST
(
Imgproc_Sobel
,
s16_regression_13506
)
{
Mat
src
=
(
Mat_
<
short
>
(
8
,
16
)
<<
127
,
138
,
130
,
102
,
118
,
97
,
76
,
84
,
124
,
90
,
146
,
63
,
130
,
87
,
212
,
85
,
164
,
3
,
51
,
124
,
151
,
89
,
154
,
117
,
36
,
88
,
116
,
117
,
180
,
112
,
147
,
124
,
63
,
50
,
115
,
103
,
83
,
148
,
106
,
79
,
213
,
106
,
135
,
53
,
79
,
106
,
122
,
112
,
218
,
107
,
81
,
126
,
78
,
138
,
85
,
142
,
151
,
108
,
104
,
158
,
155
,
81
,
112
,
178
,
184
,
96
,
187
,
148
,
150
,
112
,
138
,
162
,
222
,
146
,
128
,
49
,
124
,
46
,
165
,
104
,
119
,
164
,
77
,
144
,
186
,
98
,
106
,
148
,
155
,
157
,
160
,
151
,
156
,
149
,
43
,
122
,
106
,
155
,
120
,
132
,
159
,
115
,
126
,
188
,
44
,
79
,
164
,
201
,
153
,
97
,
139
,
133
,
133
,
98
,
111
,
165
,
66
,
106
,
131
,
85
,
176
,
156
,
67
,
108
,
142
,
91
,
74
,
137
);
Mat
ref
=
(
Mat_
<
short
>
(
8
,
16
)
<<
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
-
1020
,
-
796
,
-
489
,
-
469
,
-
247
,
317
,
760
,
1429
,
1983
,
1384
,
254
,
-
459
,
-
899
,
-
1197
,
-
1172
,
-
1058
,
2552
,
2340
,
1617
,
591
,
9
,
96
,
722
,
1985
,
2746
,
1916
,
676
,
9
,
-
635
,
-
1115
,
-
779
,
-
380
,
3546
,
3349
,
2838
,
2206
,
1388
,
669
,
938
,
1880
,
2252
,
1785
,
1083
,
606
,
180
,
-
298
,
-
464
,
-
418
,
816
,
966
,
1255
,
1652
,
1619
,
924
,
535
,
288
,
5
,
601
,
1581
,
1870
,
1520
,
625
,
-
627
,
-
1260
,
-
782
,
-
610
,
-
395
,
-
267
,
-
122
,
-
42
,
-
317
,
-
1378
,
-
2293
,
-
1451
,
596
,
1870
,
1679
,
763
,
-
69
,
-
394
,
-
882
,
-
681
,
-
463
,
-
818
,
-
1167
,
-
732
,
-
463
,
-
1042
,
-
1604
,
-
1592
,
-
1047
,
-
334
,
-
104
,
-
117
,
229
,
512
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
);
Mat
dst
;
Sobel
(
src
,
dst
,
CV_16S
,
0
,
1
,
5
);
ASSERT_EQ
(
0.0
,
cvtest
::
norm
(
dst
,
ref
,
NORM_INF
));
}
}}
// namespace
}}
// namespace
modules/stitching/src/matchers.cpp
View file @
85ade61e
...
@@ -351,6 +351,7 @@ void FeaturesMatcher::operator ()(const std::vector<ImageFeatures> &features, st
...
@@ -351,6 +351,7 @@ void FeaturesMatcher::operator ()(const std::vector<ImageFeatures> &features, st
if
(
features
[
i
].
keypoints
.
size
()
>
0
&&
features
[
j
].
keypoints
.
size
()
>
0
&&
mask_
(
i
,
j
))
if
(
features
[
i
].
keypoints
.
size
()
>
0
&&
features
[
j
].
keypoints
.
size
()
>
0
&&
mask_
(
i
,
j
))
near_pairs
.
push_back
(
std
::
make_pair
(
i
,
j
));
near_pairs
.
push_back
(
std
::
make_pair
(
i
,
j
));
pairwise_matches
.
clear
();
// clear history values
pairwise_matches
.
resize
(
num_images
*
num_images
);
pairwise_matches
.
resize
(
num_images
*
num_images
);
MatchPairsBody
body
(
*
this
,
features
,
pairwise_matches
,
near_pairs
);
MatchPairsBody
body
(
*
this
,
features
,
pairwise_matches
,
near_pairs
);
...
...
samples/dnn/openpose.cpp
View file @
85ade61e
...
@@ -61,17 +61,22 @@ int main(int argc, char **argv)
...
@@ -61,17 +61,22 @@ int main(int argc, char **argv)
"{ p proto | | (required) model configuration, e.g. hand/pose.prototxt }"
"{ p proto | | (required) model configuration, e.g. hand/pose.prototxt }"
"{ m model | | (required) model weights, e.g. hand/pose_iter_102000.caffemodel }"
"{ m model | | (required) model weights, e.g. hand/pose_iter_102000.caffemodel }"
"{ i image | | (required) path to image file (containing a single person, or hand) }"
"{ i image | | (required) path to image file (containing a single person, or hand) }"
"{ d dataset | | specify what kind of model was trained. It could be (COCO, MPI, HAND) depends on dataset. }"
"{ width | 368 | Preprocess input image by resizing to a specific width. }"
"{ width | 368 | Preprocess input image by resizing to a specific width. }"
"{ height | 368 | Preprocess input image by resizing to a specific height. }"
"{ height | 368 | Preprocess input image by resizing to a specific height. }"
"{ t threshold | 0.1 | threshold or confidence value for the heatmap }"
"{ t threshold | 0.1 | threshold or confidence value for the heatmap }"
"{ s scale | 0.003922 | scale for blob }"
);
);
String
modelTxt
=
samples
::
findFile
(
parser
.
get
<
string
>
(
"proto"
));
String
modelTxt
=
samples
::
findFile
(
parser
.
get
<
string
>
(
"proto"
));
String
modelBin
=
samples
::
findFile
(
parser
.
get
<
string
>
(
"model"
));
String
modelBin
=
samples
::
findFile
(
parser
.
get
<
string
>
(
"model"
));
String
imageFile
=
samples
::
findFile
(
parser
.
get
<
String
>
(
"image"
));
String
imageFile
=
samples
::
findFile
(
parser
.
get
<
String
>
(
"image"
));
String
dataset
=
parser
.
get
<
String
>
(
"dataset"
);
int
W_in
=
parser
.
get
<
int
>
(
"width"
);
int
W_in
=
parser
.
get
<
int
>
(
"width"
);
int
H_in
=
parser
.
get
<
int
>
(
"height"
);
int
H_in
=
parser
.
get
<
int
>
(
"height"
);
float
thresh
=
parser
.
get
<
float
>
(
"threshold"
);
float
thresh
=
parser
.
get
<
float
>
(
"threshold"
);
float
scale
=
parser
.
get
<
float
>
(
"scale"
);
if
(
parser
.
get
<
bool
>
(
"help"
)
||
modelTxt
.
empty
()
||
modelBin
.
empty
()
||
imageFile
.
empty
())
if
(
parser
.
get
<
bool
>
(
"help"
)
||
modelTxt
.
empty
()
||
modelBin
.
empty
()
||
imageFile
.
empty
())
{
{
cout
<<
"A sample app to demonstrate human or hand pose detection with a pretrained OpenPose dnn."
<<
endl
;
cout
<<
"A sample app to demonstrate human or hand pose detection with a pretrained OpenPose dnn."
<<
endl
;
...
@@ -79,9 +84,18 @@ int main(int argc, char **argv)
...
@@ -79,9 +84,18 @@ int main(int argc, char **argv)
return
0
;
return
0
;
}
}
// read the network model
int
midx
,
npairs
,
nparts
;
Net
net
=
readNetFromCaffe
(
modelTxt
,
modelBin
);
if
(
!
dataset
.
compare
(
"COCO"
))
{
midx
=
0
;
npairs
=
17
;
nparts
=
18
;
}
else
if
(
!
dataset
.
compare
(
"MPI"
))
{
midx
=
1
;
npairs
=
14
;
nparts
=
16
;
}
else
if
(
!
dataset
.
compare
(
"HAND"
))
{
midx
=
2
;
npairs
=
20
;
nparts
=
22
;
}
else
{
std
::
cerr
<<
"Can't interpret dataset parameter: "
<<
dataset
<<
std
::
endl
;
exit
(
-
1
);
}
// read the network model
Net
net
=
readNet
(
modelBin
,
modelTxt
);
// and the image
// and the image
Mat
img
=
imread
(
imageFile
);
Mat
img
=
imread
(
imageFile
);
if
(
img
.
empty
())
if
(
img
.
empty
())
...
@@ -91,39 +105,14 @@ int main(int argc, char **argv)
...
@@ -91,39 +105,14 @@ int main(int argc, char **argv)
}
}
// send it through the network
// send it through the network
Mat
inputBlob
=
blobFromImage
(
img
,
1.0
/
255
,
Size
(
W_in
,
H_in
),
Scalar
(
0
,
0
,
0
),
false
,
false
);
Mat
inputBlob
=
blobFromImage
(
img
,
scale
,
Size
(
W_in
,
H_in
),
Scalar
(
0
,
0
,
0
),
false
,
false
);
net
.
setInput
(
inputBlob
);
net
.
setInput
(
inputBlob
);
Mat
result
=
net
.
forward
();
Mat
result
=
net
.
forward
();
// the result is an array of "heatmaps", the probability of a body part being in location x,y
// the result is an array of "heatmaps", the probability of a body part being in location x,y
int
midx
,
npairs
;
int
nparts
=
result
.
size
[
1
];
int
H
=
result
.
size
[
2
];
int
H
=
result
.
size
[
2
];
int
W
=
result
.
size
[
3
];
int
W
=
result
.
size
[
3
];
// find out, which model we have
if
(
nparts
==
19
)
{
// COCO body
midx
=
0
;
npairs
=
17
;
nparts
=
18
;
// skip background
}
else
if
(
nparts
==
16
)
{
// MPI body
midx
=
1
;
npairs
=
14
;
}
else
if
(
nparts
==
22
)
{
// hand
midx
=
2
;
npairs
=
20
;
}
else
{
cerr
<<
"there should be 19 parts for the COCO model, 16 for MPI, or 22 for the hand one, but this model has "
<<
nparts
<<
" parts."
<<
endl
;
return
(
0
);
}
// find the position of the body parts
// find the position of the body parts
vector
<
Point
>
points
(
22
);
vector
<
Point
>
points
(
22
);
for
(
int
n
=
0
;
n
<
nparts
;
n
++
)
for
(
int
n
=
0
;
n
<
nparts
;
n
++
)
...
...
samples/dnn/openpose.py
View file @
85ade61e
# To use Inference Engine backend, specify location of plugins:
# To use Inference Engine backend, specify location of plugins:
#
export LD_LIBRARY_PATH=/opt/intel/deeplearning_deploymenttoolkit/deployment_tools/external/mklml_lnx/lib:$LD_LIBRARY_PATH
#
source /opt/intel/computer_vision_sdk/bin/setupvars.sh
import
cv2
as
cv
import
cv2
as
cv
import
numpy
as
np
import
numpy
as
np
import
argparse
import
argparse
...
@@ -12,10 +12,11 @@ parser.add_argument('--input', help='Path to image or video. Skip to capture fra
...
@@ -12,10 +12,11 @@ parser.add_argument('--input', help='Path to image or video. Skip to capture fra
parser
.
add_argument
(
'--proto'
,
help
=
'Path to .prototxt'
)
parser
.
add_argument
(
'--proto'
,
help
=
'Path to .prototxt'
)
parser
.
add_argument
(
'--model'
,
help
=
'Path to .caffemodel'
)
parser
.
add_argument
(
'--model'
,
help
=
'Path to .caffemodel'
)
parser
.
add_argument
(
'--dataset'
,
help
=
'Specify what kind of model was trained. '
parser
.
add_argument
(
'--dataset'
,
help
=
'Specify what kind of model was trained. '
'It could be (COCO, MPI) depends on dataset.'
)
'It could be (COCO, MPI
, HAND
) depends on dataset.'
)
parser
.
add_argument
(
'--thr'
,
default
=
0.1
,
type
=
float
,
help
=
'Threshold value for pose parts heat map'
)
parser
.
add_argument
(
'--thr'
,
default
=
0.1
,
type
=
float
,
help
=
'Threshold value for pose parts heat map'
)
parser
.
add_argument
(
'--width'
,
default
=
368
,
type
=
int
,
help
=
'Resize input to specific width.'
)
parser
.
add_argument
(
'--width'
,
default
=
368
,
type
=
int
,
help
=
'Resize input to specific width.'
)
parser
.
add_argument
(
'--height'
,
default
=
368
,
type
=
int
,
help
=
'Resize input to specific height.'
)
parser
.
add_argument
(
'--height'
,
default
=
368
,
type
=
int
,
help
=
'Resize input to specific height.'
)
parser
.
add_argument
(
'--scale'
,
default
=
0.003922
,
type
=
float
,
help
=
'Scale for blob.'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -30,8 +31,7 @@ if args.dataset == 'COCO':
...
@@ -30,8 +31,7 @@ if args.dataset == 'COCO':
[
"Neck"
,
"RHip"
],
[
"RHip"
,
"RKnee"
],
[
"RKnee"
,
"RAnkle"
],
[
"Neck"
,
"LHip"
],
[
"Neck"
,
"RHip"
],
[
"RHip"
,
"RKnee"
],
[
"RKnee"
,
"RAnkle"
],
[
"Neck"
,
"LHip"
],
[
"LHip"
,
"LKnee"
],
[
"LKnee"
,
"LAnkle"
],
[
"Neck"
,
"Nose"
],
[
"Nose"
,
"REye"
],
[
"LHip"
,
"LKnee"
],
[
"LKnee"
,
"LAnkle"
],
[
"Neck"
,
"Nose"
],
[
"Nose"
,
"REye"
],
[
"REye"
,
"REar"
],
[
"Nose"
,
"LEye"
],
[
"LEye"
,
"LEar"
]
]
[
"REye"
,
"REar"
],
[
"Nose"
,
"LEye"
],
[
"LEye"
,
"LEar"
]
]
else
:
elif
args
.
dataset
==
'MPI'
:
assert
(
args
.
dataset
==
'MPI'
)
BODY_PARTS
=
{
"Head"
:
0
,
"Neck"
:
1
,
"RShoulder"
:
2
,
"RElbow"
:
3
,
"RWrist"
:
4
,
BODY_PARTS
=
{
"Head"
:
0
,
"Neck"
:
1
,
"RShoulder"
:
2
,
"RElbow"
:
3
,
"RWrist"
:
4
,
"LShoulder"
:
5
,
"LElbow"
:
6
,
"LWrist"
:
7
,
"RHip"
:
8
,
"RKnee"
:
9
,
"LShoulder"
:
5
,
"LElbow"
:
6
,
"LWrist"
:
7
,
"RHip"
:
8
,
"RKnee"
:
9
,
"RAnkle"
:
10
,
"LHip"
:
11
,
"LKnee"
:
12
,
"LAnkle"
:
13
,
"Chest"
:
14
,
"RAnkle"
:
10
,
"LHip"
:
11
,
"LKnee"
:
12
,
"LAnkle"
:
13
,
"Chest"
:
14
,
...
@@ -41,11 +41,33 @@ else:
...
@@ -41,11 +41,33 @@ else:
[
"RElbow"
,
"RWrist"
],
[
"Neck"
,
"LShoulder"
],
[
"LShoulder"
,
"LElbow"
],
[
"RElbow"
,
"RWrist"
],
[
"Neck"
,
"LShoulder"
],
[
"LShoulder"
,
"LElbow"
],
[
"LElbow"
,
"LWrist"
],
[
"Neck"
,
"Chest"
],
[
"Chest"
,
"RHip"
],
[
"RHip"
,
"RKnee"
],
[
"LElbow"
,
"LWrist"
],
[
"Neck"
,
"Chest"
],
[
"Chest"
,
"RHip"
],
[
"RHip"
,
"RKnee"
],
[
"RKnee"
,
"RAnkle"
],
[
"Chest"
,
"LHip"
],
[
"LHip"
,
"LKnee"
],
[
"LKnee"
,
"LAnkle"
]
]
[
"RKnee"
,
"RAnkle"
],
[
"Chest"
,
"LHip"
],
[
"LHip"
,
"LKnee"
],
[
"LKnee"
,
"LAnkle"
]
]
else
:
assert
(
args
.
dataset
==
'HAND'
)
BODY_PARTS
=
{
"Wrist"
:
0
,
"ThumbMetacarpal"
:
1
,
"ThumbProximal"
:
2
,
"ThumbMiddle"
:
3
,
"ThumbDistal"
:
4
,
"IndexFingerMetacarpal"
:
5
,
"IndexFingerProximal"
:
6
,
"IndexFingerMiddle"
:
7
,
"IndexFingerDistal"
:
8
,
"MiddleFingerMetacarpal"
:
9
,
"MiddleFingerProximal"
:
10
,
"MiddleFingerMiddle"
:
11
,
"MiddleFingerDistal"
:
12
,
"RingFingerMetacarpal"
:
13
,
"RingFingerProximal"
:
14
,
"RingFingerMiddle"
:
15
,
"RingFingerDistal"
:
16
,
"LittleFingerMetacarpal"
:
17
,
"LittleFingerProximal"
:
18
,
"LittleFingerMiddle"
:
19
,
"LittleFingerDistal"
:
20
,
}
POSE_PAIRS
=
[
[
"Wrist"
,
"ThumbMetacarpal"
],
[
"ThumbMetacarpal"
,
"ThumbProximal"
],
[
"ThumbProximal"
,
"ThumbMiddle"
],
[
"ThumbMiddle"
,
"ThumbDistal"
],
[
"Wrist"
,
"IndexFingerMetacarpal"
],
[
"IndexFingerMetacarpal"
,
"IndexFingerProximal"
],
[
"IndexFingerProximal"
,
"IndexFingerMiddle"
],
[
"IndexFingerMiddle"
,
"IndexFingerDistal"
],
[
"Wrist"
,
"MiddleFingerMetacarpal"
],
[
"MiddleFingerMetacarpal"
,
"MiddleFingerProximal"
],
[
"MiddleFingerProximal"
,
"MiddleFingerMiddle"
],
[
"MiddleFingerMiddle"
,
"MiddleFingerDistal"
],
[
"Wrist"
,
"RingFingerMetacarpal"
],
[
"RingFingerMetacarpal"
,
"RingFingerProximal"
],
[
"RingFingerProximal"
,
"RingFingerMiddle"
],
[
"RingFingerMiddle"
,
"RingFingerDistal"
],
[
"Wrist"
,
"LittleFingerMetacarpal"
],
[
"LittleFingerMetacarpal"
,
"LittleFingerProximal"
],
[
"LittleFingerProximal"
,
"LittleFingerMiddle"
],
[
"LittleFingerMiddle"
,
"LittleFingerDistal"
]
]
inWidth
=
args
.
width
inWidth
=
args
.
width
inHeight
=
args
.
height
inHeight
=
args
.
height
inScale
=
args
.
scale
net
=
cv
.
dnn
.
readNet
FromCaffe
(
cv
.
samples
.
findFile
(
args
.
proto
),
cv
.
samples
.
findFile
(
args
.
model
))
net
=
cv
.
dnn
.
readNet
(
cv
.
samples
.
findFile
(
args
.
proto
),
cv
.
samples
.
findFile
(
args
.
model
))
cap
=
cv
.
VideoCapture
(
args
.
input
if
args
.
input
else
0
)
cap
=
cv
.
VideoCapture
(
args
.
input
if
args
.
input
else
0
)
...
@@ -57,12 +79,12 @@ while cv.waitKey(1) < 0:
...
@@ -57,12 +79,12 @@ while cv.waitKey(1) < 0:
frameWidth
=
frame
.
shape
[
1
]
frameWidth
=
frame
.
shape
[
1
]
frameHeight
=
frame
.
shape
[
0
]
frameHeight
=
frame
.
shape
[
0
]
inp
=
cv
.
dnn
.
blobFromImage
(
frame
,
1.0
/
255
,
(
inWidth
,
inHeight
),
inp
=
cv
.
dnn
.
blobFromImage
(
frame
,
inScale
,
(
inWidth
,
inHeight
),
(
0
,
0
,
0
),
swapRB
=
False
,
crop
=
False
)
(
0
,
0
,
0
),
swapRB
=
False
,
crop
=
False
)
net
.
setInput
(
inp
)
net
.
setInput
(
inp
)
out
=
net
.
forward
()
out
=
net
.
forward
()
assert
(
len
(
BODY_PARTS
)
=
=
out
.
shape
[
1
])
assert
(
len
(
BODY_PARTS
)
<
=
out
.
shape
[
1
])
points
=
[]
points
=
[]
for
i
in
range
(
len
(
BODY_PARTS
)):
for
i
in
range
(
len
(
BODY_PARTS
)):
...
...
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