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
51e54305
Commit
51e54305
authored
May 10, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
parents
000a13b6
9e3b6a22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
162 additions
and
80 deletions
+162
-80
interoperability_with_OpenCV_1.markdown
...ity_with_OpenCV_1/interoperability_with_OpenCV_1.markdown
+1
-1
dnn_yolo.markdown
doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown
+2
-2
intrin_neon.hpp
modules/core/include/opencv2/core/hal/intrin_neon.hpp
+5
-1
intrin_vsx.hpp
modules/core/include/opencv2/core/hal/intrin_vsx.hpp
+23
-14
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+2
-2
test_intrin_utils.hpp
modules/core/test/test_intrin_utils.hpp
+12
-1
column_filter.hpp
modules/cudafilters/src/cuda/column_filter.hpp
+6
-13
row_filter.hpp
modules/cudafilters/src/cuda/row_filter.hpp
+6
-13
canny.cpp
modules/cudaimgproc/src/canny.cpp
+12
-5
canny.cu
modules/cudaimgproc/src/cuda/canny.cu
+0
-0
test_canny.cpp
modules/cudaimgproc/test/test_canny.cpp
+58
-1
color_hsv.cpp
modules/imgproc/src/color_hsv.cpp
+0
-0
test_hdr.cpp
modules/photo/test/test_hdr.cpp
+1
-1
blenders.hpp
...s/stitching/include/opencv2/stitching/detail/blenders.hpp
+1
-0
cap_ffmpeg_impl.hpp
modules/videoio/src/cap_ffmpeg_impl.hpp
+6
-1
cap_qt.cpp
modules/videoio/src/cap_qt.cpp
+3
-3
custom_layers.cpp
samples/cpp/tutorial_code/dnn/custom_layers.cpp
+10
-10
object_detection.cpp
samples/dnn/object_detection.cpp
+5
-4
openpose.cpp
samples/dnn/openpose.cpp
+4
-4
segmentation.cpp
samples/dnn/segmentation.cpp
+5
-4
No files found.
doc/tutorials/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.markdown
View file @
51e54305
...
@@ -69,7 +69,7 @@ CvMat* mI = &I.operator CvMat();
...
@@ -69,7 +69,7 @@ CvMat* mI = &I.operator CvMat();
@endcode
@endcode
One of the biggest complaints of the C interface is that it leaves all the memory management to you.
One of the biggest complaints of the C interface is that it leaves all the memory management to you.
You need to figure out when it is safe to release your unused objects and make sure you do so before
You need to figure out when it is safe to release your unused objects and make sure you do so before
the program finishes or you could have troublesome memory le
e
ks. To work around this issue in OpenCV
the program finishes or you could have troublesome memory le
a
ks. To work around this issue in OpenCV
there is introduced a sort of smart pointer. This will automatically release the object when it's no
there is introduced a sort of smart pointer. This will automatically release the object when it's no
longer in use. To use this declare the pointers as a specialization of the
*Ptr*
:
longer in use. To use this declare the pointers as a specialization of the
*Ptr*
:
@code{.cpp}
@code{.cpp}
...
...
doc/tutorials/dnn/dnn_yolo/dnn_yolo.markdown
View file @
51e54305
...
@@ -29,7 +29,7 @@ Execute in webcam:
...
@@ -29,7 +29,7 @@ Execute in webcam:
@code{.bash}
@code{.bash}
$ example_dnn_object_detection --config=
[
PATH-TO-DARKNET
]
/cfg/yolo.cfg --model=
[
PATH-TO-DARKNET
]
/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392
$ example_dnn_object_detection --config=
[
PATH-TO-DARKNET
]
/cfg/yolo.cfg --model=
[
PATH-TO-DARKNET
]
/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392
--rgb
@endcode
@endcode
...
@@ -37,7 +37,7 @@ Execute with image or video file:
...
@@ -37,7 +37,7 @@ Execute with image or video file:
@code{.bash}
@code{.bash}
$ example_dnn_object_detection --config=
[
PATH-TO-DARKNET
]
/cfg/yolo.cfg --model=
[
PATH-TO-DARKNET
]
/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392 --input=
[
PATH-TO-IMAGE-OR-VIDEO-FILE
]
$ example_dnn_object_detection --config=
[
PATH-TO-DARKNET
]
/cfg/yolo.cfg --model=
[
PATH-TO-DARKNET
]
/yolo.weights --classes=object_detection_classes_pascal_voc.txt --width=416 --height=416 --scale=0.00392 --input=
[
PATH-TO-IMAGE-OR-VIDEO-FILE
]
--rgb
@endcode
@endcode
...
...
modules/core/include/opencv2/core/hal/intrin_neon.hpp
View file @
51e54305
...
@@ -786,10 +786,14 @@ template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a) \
...
@@ -786,10 +786,14 @@ template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a) \
{ return _Tpvec(vextq_##suffix(a.val, vdupq_n_##suffix(0), n)); } \
{ return _Tpvec(vextq_##suffix(a.val, vdupq_n_##suffix(0), n)); } \
template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a) \
template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a) \
{ return _Tpvec(vextq_##suffix(vdupq_n_##suffix(0), a.val, _Tpvec::nlanes - n)); } \
{ return _Tpvec(vextq_##suffix(vdupq_n_##suffix(0), a.val, _Tpvec::nlanes - n)); } \
template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a) \
{ return a; } \
template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \
template<int n> inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vextq_##suffix(a.val, b.val, n)); } \
{ return _Tpvec(vextq_##suffix(a.val, b.val, n)); } \
template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \
template<int n> inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) \
{ return _Tpvec(vextq_##suffix(b.val, a.val, _Tpvec::nlanes - n)); }
{ return _Tpvec(vextq_##suffix(b.val, a.val, _Tpvec::nlanes - n)); } \
template<> inline _Tpvec v_rotate_left<0>(const _Tpvec& a, const _Tpvec& b) \
{ CV_UNUSED(b); return a; }
OPENCV_HAL_IMPL_NEON_ROTATE_OP
(
v_uint8x16
,
u8
)
OPENCV_HAL_IMPL_NEON_ROTATE_OP
(
v_uint8x16
,
u8
)
OPENCV_HAL_IMPL_NEON_ROTATE_OP
(
v_int8x16
,
s8
)
OPENCV_HAL_IMPL_NEON_ROTATE_OP
(
v_int8x16
,
s8
)
...
...
modules/core/include/opencv2/core/hal/intrin_vsx.hpp
View file @
51e54305
...
@@ -589,7 +589,7 @@ inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b)
...
@@ -589,7 +589,7 @@ inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b)
return
_Tpvec
(
vec_sld
(
a
.
val
,
b
.
val
,
CV_SHIFT
));
return
_Tpvec
(
vec_sld
(
a
.
val
,
b
.
val
,
CV_SHIFT
));
}
}
#define OPENCV_IMPL_VSX_ROTATE_64
(_Tpvec, suffix, rg1, rg2)
\
#define OPENCV_IMPL_VSX_ROTATE_64
_2RG(_Tpvec, suffix, rg1, rg2)
\
template<int imm> \
template<int imm> \
inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
{ \
{ \
...
@@ -598,11 +598,13 @@ inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
...
@@ -598,11 +598,13 @@ inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
return imm ? b : a; \
return imm ? b : a; \
}
}
OPENCV_IMPL_VSX_ROTATE_64
(
v_int64x2
,
right
,
a
,
b
)
#define OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(_Tpvec) \
OPENCV_IMPL_VSX_ROTATE_64
(
v_uint64x2
,
right
,
a
,
b
)
OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, left, b, a) \
OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, right, a, b)
OPENCV_IMPL_VSX_ROTATE_64
(
v_int64x2
,
left
,
b
,
a
)
OPENCV_IMPL_VSX_ROTATE_64_2RG_LR
(
v_float64x2
)
OPENCV_IMPL_VSX_ROTATE_64
(
v_uint64x2
,
left
,
b
,
a
)
OPENCV_IMPL_VSX_ROTATE_64_2RG_LR
(
v_uint64x2
)
OPENCV_IMPL_VSX_ROTATE_64_2RG_LR
(
v_int64x2
)
/* Extract */
/* Extract */
template
<
int
s
,
typename
_Tpvec
>
template
<
int
s
,
typename
_Tpvec
>
...
@@ -716,26 +718,33 @@ inline int v_signmask(const v_uint64x2& a)
...
@@ -716,26 +718,33 @@ inline int v_signmask(const v_uint64x2& a)
inline
int
v_signmask
(
const
v_float64x2
&
a
)
inline
int
v_signmask
(
const
v_float64x2
&
a
)
{
return
v_signmask
(
v_reinterpret_as_s64
(
a
));
}
{
return
v_signmask
(
v_reinterpret_as_s64
(
a
));
}
template
<
typename
_Tpvec
>
template
<
typename
_Tpvec
>
inline
bool
v_check_all
(
const
_Tpvec
&
a
)
inline
bool
v_check_all
(
const
_Tpvec
&
a
)
{
return
vec_all_lt
(
a
.
val
,
_Tpvec
().
val
);}
{
return
vec_all_lt
(
a
.
val
,
_Tpvec
().
val
);
}
inline
bool
v_check_all
(
const
v_uint8x16
&
a
)
inline
bool
v_check_all
(
const
v_uint8x16
&
a
)
{
return
v_check_all
(
v_reinterpret_as_s8
(
a
));
}
{
return
v_check_all
(
v_reinterpret_as_s8
(
a
));
}
inline
bool
v_check_all
(
const
v_uint16x8
&
a
)
inline
bool
v_check_all
(
const
v_uint16x8
&
a
)
{
return
v_check_all
(
v_reinterpret_as_s16
(
a
));
}
{
return
v_check_all
(
v_reinterpret_as_s16
(
a
));
}
inline
bool
v_check_all
(
const
v_uint32x4
&
a
)
inline
bool
v_check_all
(
const
v_uint32x4
&
a
)
{
return
v_check_all
(
v_reinterpret_as_s32
(
a
));
}
inline
bool
v_check_all
(
const
v_float32x4
&
a
)
{
return
v_check_all
(
v_reinterpret_as_s32
(
a
));
}
{
return
v_check_all
(
v_reinterpret_as_s32
(
a
));
}
inline
bool
v_check_all
(
const
v_float64x2
&
a
)
{
return
v_check_all
(
v_reinterpret_as_s64
(
a
));
}
template
<
typename
_Tpvec
>
template
<
typename
_Tpvec
>
inline
bool
v_check_any
(
const
_Tpvec
&
a
)
inline
bool
v_check_any
(
const
_Tpvec
&
a
)
{
return
vec_any_lt
(
a
.
val
,
_Tpvec
().
val
);}
{
return
vec_any_lt
(
a
.
val
,
_Tpvec
().
val
);
}
inline
bool
v_check_any
(
const
v_uint8x16
&
a
)
inline
bool
v_check_any
(
const
v_uint8x16
&
a
)
{
return
v_check_any
(
v_reinterpret_as_s8
(
a
));
}
{
return
v_check_any
(
v_reinterpret_as_s8
(
a
));
}
inline
bool
v_check_any
(
const
v_uint16x8
&
a
)
inline
bool
v_check_any
(
const
v_uint16x8
&
a
)
{
return
v_check_any
(
v_reinterpret_as_s16
(
a
));
}
{
return
v_check_any
(
v_reinterpret_as_s16
(
a
));
}
inline
bool
v_check_any
(
const
v_uint32x4
&
a
)
inline
bool
v_check_any
(
const
v_uint32x4
&
a
)
{
return
v_check_any
(
v_reinterpret_as_s32
(
a
));
}
inline
bool
v_check_any
(
const
v_float32x4
&
a
)
{
return
v_check_any
(
v_reinterpret_as_s32
(
a
));
}
{
return
v_check_any
(
v_reinterpret_as_s32
(
a
));
}
inline
bool
v_check_any
(
const
v_float64x2
&
a
)
{
return
v_check_any
(
v_reinterpret_as_s64
(
a
));
}
////////// Other math /////////
////////// Other math /////////
...
...
modules/core/include/opencv2/core/operations.hpp
View file @
51e54305
...
@@ -194,8 +194,8 @@ Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const
...
@@ -194,8 +194,8 @@ Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method, bool *p_is_ok /*= NULL*/) const
{
{
Matx
<
_Tp
,
n
,
m
>
b
;
Matx
<
_Tp
,
n
,
m
>
b
;
bool
ok
;
bool
ok
;
if
(
m
ethod
==
DECOMP_LU
||
method
==
DECOMP_CHOLESKY
)
if
(
m
==
n
&&
(
method
==
DECOMP_LU
||
method
==
DECOMP_CHOLESKY
)
)
ok
=
cv
::
internal
::
Matx_FastInvOp
<
_Tp
,
m
>
()(
*
this
,
b
,
method
);
ok
=
cv
::
internal
::
Matx_FastInvOp
<
_Tp
,
m
>
()(
*
reinterpret_cast
<
const
Matx
<
_Tp
,
m
,
m
>*>
(
this
),
reinterpret_cast
<
Matx
<
_Tp
,
m
,
m
>&>
(
b
)
,
method
);
else
else
{
{
Mat
A
(
*
this
,
false
),
B
(
b
,
false
);
Mat
A
(
*
this
,
false
),
B
(
b
,
false
);
...
...
modules/core/test/test_intrin_utils.hpp
View file @
51e54305
...
@@ -837,17 +837,28 @@ template<typename R> struct TheTest
...
@@ -837,17 +837,28 @@ template<typename R> struct TheTest
Data
<
R
>
resC
=
v_rotate_right
<
s
>
(
a
);
Data
<
R
>
resC
=
v_rotate_right
<
s
>
(
a
);
Data
<
R
>
resD
=
v_rotate_right
<
s
>
(
a
,
b
);
Data
<
R
>
resD
=
v_rotate_right
<
s
>
(
a
,
b
);
Data
<
R
>
resE
=
v_rotate_left
<
s
>
(
a
);
Data
<
R
>
resF
=
v_rotate_left
<
s
>
(
a
,
b
);
for
(
int
i
=
0
;
i
<
R
::
nlanes
;
++
i
)
for
(
int
i
=
0
;
i
<
R
::
nlanes
;
++
i
)
{
{
if
(
i
+
s
>=
R
::
nlanes
)
if
(
i
+
s
>=
R
::
nlanes
)
{
{
EXPECT_EQ
((
LaneType
)
0
,
resC
[
i
]);
EXPECT_EQ
((
LaneType
)
0
,
resC
[
i
]);
EXPECT_EQ
(
dataB
[
i
-
R
::
nlanes
+
s
],
resD
[
i
]);
EXPECT_EQ
(
dataB
[
i
-
R
::
nlanes
+
s
],
resD
[
i
]);
EXPECT_EQ
((
LaneType
)
0
,
resE
[
i
-
R
::
nlanes
+
s
]);
EXPECT_EQ
(
dataB
[
i
],
resF
[
i
-
R
::
nlanes
+
s
]);
}
}
else
else
{
EXPECT_EQ
(
dataA
[
i
+
s
],
resC
[
i
]);
EXPECT_EQ
(
dataA
[
i
+
s
],
resC
[
i
]);
}
EXPECT_EQ
(
dataA
[
i
+
s
],
resD
[
i
]);
EXPECT_EQ
(
dataA
[
i
],
resE
[
i
+
s
]);
EXPECT_EQ
(
dataA
[
i
],
resF
[
i
+
s
]);
}
}
return
*
this
;
return
*
this
;
}
}
...
...
modules/cudafilters/src/cuda/column_filter.hpp
View file @
51e54305
...
@@ -52,10 +52,8 @@ namespace column_filter
...
@@ -52,10 +52,8 @@ namespace column_filter
{
{
#define MAX_KERNEL_SIZE 32
#define MAX_KERNEL_SIZE 32
__constant__
float
c_kernel
[
MAX_KERNEL_SIZE
];
template
<
int
KSIZE
,
typename
T
,
typename
D
,
typename
B
>
template
<
int
KSIZE
,
typename
T
,
typename
D
,
typename
B
>
__global__
void
linearColumnFilter
(
const
PtrStepSz
<
T
>
src
,
PtrStep
<
D
>
dst
,
const
int
anchor
,
const
B
brd
)
__global__
void
linearColumnFilter
(
const
PtrStepSz
<
T
>
src
,
PtrStep
<
D
>
dst
,
const
float
*
kernel
,
const
int
anchor
,
const
B
brd
)
{
{
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200)
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200)
const
int
BLOCK_DIM_X
=
16
;
const
int
BLOCK_DIM_X
=
16
;
...
@@ -135,7 +133,7 @@ namespace column_filter
...
@@ -135,7 +133,7 @@ namespace column_filter
#pragma unroll
#pragma unroll
for
(
int
k
=
0
;
k
<
KSIZE
;
++
k
)
for
(
int
k
=
0
;
k
<
KSIZE
;
++
k
)
sum
=
sum
+
smem
[
threadIdx
.
y
+
HALO_SIZE
*
BLOCK_DIM_Y
+
j
*
BLOCK_DIM_Y
-
anchor
+
k
][
threadIdx
.
x
]
*
c_
kernel
[
k
];
sum
=
sum
+
smem
[
threadIdx
.
y
+
HALO_SIZE
*
BLOCK_DIM_Y
+
j
*
BLOCK_DIM_Y
-
anchor
+
k
][
threadIdx
.
x
]
*
kernel
[
k
];
dst
(
y
,
x
)
=
saturate_cast
<
D
>
(
sum
);
dst
(
y
,
x
)
=
saturate_cast
<
D
>
(
sum
);
}
}
...
@@ -143,7 +141,7 @@ namespace column_filter
...
@@ -143,7 +141,7 @@ namespace column_filter
}
}
template
<
int
KSIZE
,
typename
T
,
typename
D
,
template
<
typename
>
class
B
>
template
<
int
KSIZE
,
typename
T
,
typename
D
,
template
<
typename
>
class
B
>
void
caller
(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
int
anchor
,
int
cc
,
cudaStream_t
stream
)
void
caller
(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
const
float
*
kernel
,
int
anchor
,
int
cc
,
cudaStream_t
stream
)
{
{
int
BLOCK_DIM_X
;
int
BLOCK_DIM_X
;
int
BLOCK_DIM_Y
;
int
BLOCK_DIM_Y
;
...
@@ -167,7 +165,7 @@ namespace column_filter
...
@@ -167,7 +165,7 @@ namespace column_filter
B
<
T
>
brd
(
src
.
rows
);
B
<
T
>
brd
(
src
.
rows
);
linearColumnFilter
<
KSIZE
,
T
,
D
><<<
grid
,
block
,
0
,
stream
>>>
(
src
,
dst
,
anchor
,
brd
);
linearColumnFilter
<
KSIZE
,
T
,
D
><<<
grid
,
block
,
0
,
stream
>>>
(
src
,
dst
,
kernel
,
anchor
,
brd
);
cudaSafeCall
(
cudaGetLastError
()
);
cudaSafeCall
(
cudaGetLastError
()
);
...
@@ -181,7 +179,7 @@ namespace filter
...
@@ -181,7 +179,7 @@ namespace filter
template
<
typename
T
,
typename
D
>
template
<
typename
T
,
typename
D
>
void
linearColumn
(
PtrStepSzb
src
,
PtrStepSzb
dst
,
const
float
*
kernel
,
int
ksize
,
int
anchor
,
int
brd_type
,
int
cc
,
cudaStream_t
stream
)
void
linearColumn
(
PtrStepSzb
src
,
PtrStepSzb
dst
,
const
float
*
kernel
,
int
ksize
,
int
anchor
,
int
brd_type
,
int
cc
,
cudaStream_t
stream
)
{
{
typedef
void
(
*
caller_t
)(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
int
anchor
,
int
cc
,
cudaStream_t
stream
);
typedef
void
(
*
caller_t
)(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
const
float
*
kernel
,
int
anchor
,
int
cc
,
cudaStream_t
stream
);
static
const
caller_t
callers
[
5
][
33
]
=
static
const
caller_t
callers
[
5
][
33
]
=
{
{
...
@@ -362,11 +360,6 @@ namespace filter
...
@@ -362,11 +360,6 @@ namespace filter
}
}
};
};
if
(
stream
==
0
)
callers
[
brd_type
][
ksize
]((
PtrStepSz
<
T
>
)
src
,
(
PtrStepSz
<
D
>
)
dst
,
kernel
,
anchor
,
cc
,
stream
);
cudaSafeCall
(
cudaMemcpyToSymbol
(
column_filter
::
c_kernel
,
kernel
,
ksize
*
sizeof
(
float
),
0
,
cudaMemcpyDeviceToDevice
)
);
else
cudaSafeCall
(
cudaMemcpyToSymbolAsync
(
column_filter
::
c_kernel
,
kernel
,
ksize
*
sizeof
(
float
),
0
,
cudaMemcpyDeviceToDevice
,
stream
)
);
callers
[
brd_type
][
ksize
]((
PtrStepSz
<
T
>
)
src
,
(
PtrStepSz
<
D
>
)
dst
,
anchor
,
cc
,
stream
);
}
}
}
}
modules/cudafilters/src/cuda/row_filter.hpp
View file @
51e54305
...
@@ -52,10 +52,8 @@ namespace row_filter
...
@@ -52,10 +52,8 @@ namespace row_filter
{
{
#define MAX_KERNEL_SIZE 32
#define MAX_KERNEL_SIZE 32
__constant__
float
c_kernel
[
MAX_KERNEL_SIZE
];
template
<
int
KSIZE
,
typename
T
,
typename
D
,
typename
B
>
template
<
int
KSIZE
,
typename
T
,
typename
D
,
typename
B
>
__global__
void
linearRowFilter
(
const
PtrStepSz
<
T
>
src
,
PtrStep
<
D
>
dst
,
const
int
anchor
,
const
B
brd
)
__global__
void
linearRowFilter
(
const
PtrStepSz
<
T
>
src
,
PtrStep
<
D
>
dst
,
const
float
*
kernel
,
const
int
anchor
,
const
B
brd
)
{
{
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200)
#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 200)
const
int
BLOCK_DIM_X
=
32
;
const
int
BLOCK_DIM_X
=
32
;
...
@@ -135,7 +133,7 @@ namespace row_filter
...
@@ -135,7 +133,7 @@ namespace row_filter
#pragma unroll
#pragma unroll
for
(
int
k
=
0
;
k
<
KSIZE
;
++
k
)
for
(
int
k
=
0
;
k
<
KSIZE
;
++
k
)
sum
=
sum
+
smem
[
threadIdx
.
y
][
threadIdx
.
x
+
HALO_SIZE
*
BLOCK_DIM_X
+
j
*
BLOCK_DIM_X
-
anchor
+
k
]
*
c_
kernel
[
k
];
sum
=
sum
+
smem
[
threadIdx
.
y
][
threadIdx
.
x
+
HALO_SIZE
*
BLOCK_DIM_X
+
j
*
BLOCK_DIM_X
-
anchor
+
k
]
*
kernel
[
k
];
dst
(
y
,
x
)
=
saturate_cast
<
D
>
(
sum
);
dst
(
y
,
x
)
=
saturate_cast
<
D
>
(
sum
);
}
}
...
@@ -143,7 +141,7 @@ namespace row_filter
...
@@ -143,7 +141,7 @@ namespace row_filter
}
}
template
<
int
KSIZE
,
typename
T
,
typename
D
,
template
<
typename
>
class
B
>
template
<
int
KSIZE
,
typename
T
,
typename
D
,
template
<
typename
>
class
B
>
void
caller
(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
int
anchor
,
int
cc
,
cudaStream_t
stream
)
void
caller
(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
const
float
*
kernel
,
int
anchor
,
int
cc
,
cudaStream_t
stream
)
{
{
int
BLOCK_DIM_X
;
int
BLOCK_DIM_X
;
int
BLOCK_DIM_Y
;
int
BLOCK_DIM_Y
;
...
@@ -167,7 +165,7 @@ namespace row_filter
...
@@ -167,7 +165,7 @@ namespace row_filter
B
<
T
>
brd
(
src
.
cols
);
B
<
T
>
brd
(
src
.
cols
);
linearRowFilter
<
KSIZE
,
T
,
D
><<<
grid
,
block
,
0
,
stream
>>>
(
src
,
dst
,
anchor
,
brd
);
linearRowFilter
<
KSIZE
,
T
,
D
><<<
grid
,
block
,
0
,
stream
>>>
(
src
,
dst
,
kernel
,
anchor
,
brd
);
cudaSafeCall
(
cudaGetLastError
()
);
cudaSafeCall
(
cudaGetLastError
()
);
if
(
stream
==
0
)
if
(
stream
==
0
)
...
@@ -180,7 +178,7 @@ namespace filter
...
@@ -180,7 +178,7 @@ namespace filter
template
<
typename
T
,
typename
D
>
template
<
typename
T
,
typename
D
>
void
linearRow
(
PtrStepSzb
src
,
PtrStepSzb
dst
,
const
float
*
kernel
,
int
ksize
,
int
anchor
,
int
brd_type
,
int
cc
,
cudaStream_t
stream
)
void
linearRow
(
PtrStepSzb
src
,
PtrStepSzb
dst
,
const
float
*
kernel
,
int
ksize
,
int
anchor
,
int
brd_type
,
int
cc
,
cudaStream_t
stream
)
{
{
typedef
void
(
*
caller_t
)(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
int
anchor
,
int
cc
,
cudaStream_t
stream
);
typedef
void
(
*
caller_t
)(
PtrStepSz
<
T
>
src
,
PtrStepSz
<
D
>
dst
,
const
float
*
kernel
,
int
anchor
,
int
cc
,
cudaStream_t
stream
);
static
const
caller_t
callers
[
5
][
33
]
=
static
const
caller_t
callers
[
5
][
33
]
=
{
{
...
@@ -361,11 +359,6 @@ namespace filter
...
@@ -361,11 +359,6 @@ namespace filter
}
}
};
};
if
(
stream
==
0
)
callers
[
brd_type
][
ksize
]((
PtrStepSz
<
T
>
)
src
,
(
PtrStepSz
<
D
>
)
dst
,
kernel
,
anchor
,
cc
,
stream
);
cudaSafeCall
(
cudaMemcpyToSymbol
(
row_filter
::
c_kernel
,
kernel
,
ksize
*
sizeof
(
float
),
0
,
cudaMemcpyDeviceToDevice
)
);
else
cudaSafeCall
(
cudaMemcpyToSymbolAsync
(
row_filter
::
c_kernel
,
kernel
,
ksize
*
sizeof
(
float
),
0
,
cudaMemcpyDeviceToDevice
,
stream
)
);
callers
[
brd_type
][
ksize
]((
PtrStepSz
<
T
>
)
src
,
(
PtrStepSz
<
D
>
)
dst
,
anchor
,
cc
,
stream
);
}
}
}
}
modules/cudaimgproc/src/canny.cpp
View file @
51e54305
...
@@ -58,9 +58,9 @@ namespace canny
...
@@ -58,9 +58,9 @@ namespace canny
void
calcMap
(
PtrStepSzi
dx
,
PtrStepSzi
dy
,
PtrStepSzf
mag
,
PtrStepSzi
map
,
float
low_thresh
,
float
high_thresh
,
cudaStream_t
stream
);
void
calcMap
(
PtrStepSzi
dx
,
PtrStepSzi
dy
,
PtrStepSzf
mag
,
PtrStepSzi
map
,
float
low_thresh
,
float
high_thresh
,
cudaStream_t
stream
);
void
edgesHysteresisLocal
(
PtrStepSzi
map
,
short2
*
st1
,
cudaStream_t
stream
);
void
edgesHysteresisLocal
(
PtrStepSzi
map
,
short2
*
st1
,
int
*
d_counter
,
cudaStream_t
stream
);
void
edgesHysteresisGlobal
(
PtrStepSzi
map
,
short2
*
st1
,
short2
*
st2
,
cudaStream_t
stream
);
void
edgesHysteresisGlobal
(
PtrStepSzi
map
,
short2
*
st1
,
short2
*
st2
,
int
*
d_counter
,
cudaStream_t
stream
);
void
getEdges
(
PtrStepSzi
map
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
void
getEdges
(
PtrStepSzi
map
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
}
}
...
@@ -127,6 +127,8 @@ namespace
...
@@ -127,6 +127,8 @@ namespace
Ptr
<
Filter
>
filterDX_
,
filterDY_
;
Ptr
<
Filter
>
filterDX_
,
filterDY_
;
#endif
#endif
int
old_apperture_size_
;
int
old_apperture_size_
;
int
*
d_counter
;
};
};
void
CannyImpl
::
detect
(
InputArray
_image
,
OutputArray
_edges
,
Stream
&
stream
)
void
CannyImpl
::
detect
(
InputArray
_image
,
OutputArray
_edges
,
Stream
&
stream
)
...
@@ -218,12 +220,17 @@ namespace
...
@@ -218,12 +220,17 @@ namespace
void
CannyImpl
::
CannyCaller
(
GpuMat
&
edges
,
Stream
&
stream
)
void
CannyImpl
::
CannyCaller
(
GpuMat
&
edges
,
Stream
&
stream
)
{
{
map_
.
setTo
(
Scalar
::
all
(
0
));
map_
.
setTo
(
Scalar
::
all
(
0
),
stream
);
canny
::
calcMap
(
dx_
,
dy_
,
mag_
,
map_
,
static_cast
<
float
>
(
low_thresh_
),
static_cast
<
float
>
(
high_thresh_
),
StreamAccessor
::
getStream
(
stream
));
canny
::
calcMap
(
dx_
,
dy_
,
mag_
,
map_
,
static_cast
<
float
>
(
low_thresh_
),
static_cast
<
float
>
(
high_thresh_
),
StreamAccessor
::
getStream
(
stream
));
canny
::
edgesHysteresisLocal
(
map_
,
st1_
.
ptr
<
short2
>
(),
StreamAccessor
::
getStream
(
stream
));
cudaSafeCall
(
cudaMalloc
(
&
d_counter
,
sizeof
(
int
))
);
canny
::
edgesHysteresisLocal
(
map_
,
st1_
.
ptr
<
short2
>
(),
d_counter
,
StreamAccessor
::
getStream
(
stream
));
canny
::
edgesHysteresisGlobal
(
map_
,
st1_
.
ptr
<
short2
>
(),
st2_
.
ptr
<
short2
>
(),
d_counter
,
StreamAccessor
::
getStream
(
stream
));
c
anny
::
edgesHysteresisGlobal
(
map_
,
st1_
.
ptr
<
short2
>
(),
st2_
.
ptr
<
short2
>
(),
StreamAccessor
::
getStream
(
stream
)
);
c
udaSafeCall
(
cudaFree
(
d_counter
)
);
canny
::
getEdges
(
map_
,
edges
,
StreamAccessor
::
getStream
(
stream
));
canny
::
getEdges
(
map_
,
edges
,
StreamAccessor
::
getStream
(
stream
));
}
}
...
...
modules/cudaimgproc/src/cuda/canny.cu
View file @
51e54305
This diff is collapsed.
Click to expand it.
modules/cudaimgproc/test/test_canny.cpp
View file @
51e54305
...
@@ -92,9 +92,66 @@ CUDA_TEST_P(Canny, Accuracy)
...
@@ -92,9 +92,66 @@ CUDA_TEST_P(Canny, Accuracy)
EXPECT_MAT_SIMILAR
(
edges_gold
,
edges
,
2e-2
);
EXPECT_MAT_SIMILAR
(
edges_gold
,
edges
,
2e-2
);
}
}
class
CannyAsyncParallelLoopBody
:
public
cv
::
ParallelLoopBody
{
public
:
CannyAsyncParallelLoopBody
(
const
cv
::
cuda
::
GpuMat
&
d_img_
,
cv
::
cuda
::
GpuMat
*
edges_
,
double
low_thresh_
,
double
high_thresh_
,
int
apperture_size_
,
bool
useL2gradient_
)
:
d_img
(
d_img_
),
edges
(
edges_
),
low_thresh
(
low_thresh_
),
high_thresh
(
high_thresh_
),
apperture_size
(
apperture_size_
),
useL2gradient
(
useL2gradient_
)
{}
~
CannyAsyncParallelLoopBody
()
{};
void
operator
()(
const
cv
::
Range
&
r
)
const
{
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
cv
::
cuda
::
Stream
stream
;
cv
::
Ptr
<
cv
::
cuda
::
CannyEdgeDetector
>
canny
=
cv
::
cuda
::
createCannyEdgeDetector
(
low_thresh
,
high_thresh
,
apperture_size
,
useL2gradient
);
canny
->
detect
(
d_img
,
edges
[
i
],
stream
);
stream
.
waitForCompletion
();
}
}
protected
:
const
cv
::
cuda
::
GpuMat
&
d_img
;
cv
::
cuda
::
GpuMat
*
edges
;
double
low_thresh
;
double
high_thresh
;
int
apperture_size
;
bool
useL2gradient
;
};
#define NUM_STREAMS 64
CUDA_TEST_P
(
Canny
,
Async
)
{
if
(
!
supportFeature
(
devInfo
,
cv
::
cuda
::
FEATURE_SET_COMPUTE_30
))
{
throw
SkipTestException
(
"CUDA device doesn't support texture objects"
);
}
else
{
const
cv
::
Mat
img
=
readImage
(
"stereobm/aloe-L.png"
,
cv
::
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
img
.
empty
());
const
cv
::
cuda
::
GpuMat
d_img_roi
=
loadMat
(
img
,
useRoi
);
double
low_thresh
=
50.0
;
double
high_thresh
=
100.0
;
// Synchronous call
cv
::
Ptr
<
cv
::
cuda
::
CannyEdgeDetector
>
canny
=
cv
::
cuda
::
createCannyEdgeDetector
(
low_thresh
,
high_thresh
,
apperture_size
,
useL2gradient
);
cv
::
cuda
::
GpuMat
edges_gold
;
canny
->
detect
(
d_img_roi
,
edges_gold
);
// Asynchronous call
cv
::
cuda
::
GpuMat
edges
[
NUM_STREAMS
];
cv
::
parallel_for_
(
cv
::
Range
(
0
,
NUM_STREAMS
),
CannyAsyncParallelLoopBody
(
d_img_roi
,
edges
,
low_thresh
,
high_thresh
,
apperture_size
,
useL2gradient
));
// Compare the results of synchronous call and asynchronous call
for
(
int
i
=
0
;
i
<
NUM_STREAMS
;
i
++
)
EXPECT_MAT_NEAR
(
edges_gold
,
edges
[
i
],
0.0
);
}
}
INSTANTIATE_TEST_CASE_P
(
CUDA_ImgProc
,
Canny
,
testing
::
Combine
(
INSTANTIATE_TEST_CASE_P
(
CUDA_ImgProc
,
Canny
,
testing
::
Combine
(
ALL_DEVICES
,
ALL_DEVICES
,
testing
::
Values
(
AppertureSize
(
3
),
AppertureSize
(
5
)),
testing
::
Values
(
AppertureSize
(
3
),
AppertureSize
(
5
)
,
AppertureSize
(
7
)
),
testing
::
Values
(
L2gradient
(
false
),
L2gradient
(
true
)),
testing
::
Values
(
L2gradient
(
false
),
L2gradient
(
true
)),
WHOLE_SUBMAT
));
WHOLE_SUBMAT
));
...
...
modules/imgproc/src/color_hsv.cpp
View file @
51e54305
This diff is collapsed.
Click to expand it.
modules/photo/test/test_hdr.cpp
View file @
51e54305
...
@@ -213,7 +213,7 @@ TEST(Photo_MergeRobertson, regression)
...
@@ -213,7 +213,7 @@ TEST(Photo_MergeRobertson, regression)
loadImage
(
test_path
+
"merge/robertson.hdr"
,
expected
);
loadImage
(
test_path
+
"merge/robertson.hdr"
,
expected
);
merge
->
process
(
images
,
result
,
times
);
merge
->
process
(
images
,
result
,
times
);
#if
def __aarch64__
#if
defined(__aarch64__) || defined(__PPC64__)
const
float
eps
=
6.
f
;
const
float
eps
=
6.
f
;
#else
#else
const
float
eps
=
5.
f
;
const
float
eps
=
5.
f
;
...
...
modules/stitching/include/opencv2/stitching/detail/blenders.hpp
View file @
51e54305
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
#endif
#endif
#include "opencv2/core.hpp"
#include "opencv2/core.hpp"
#include "opencv2/core/cuda.hpp"
namespace
cv
{
namespace
cv
{
namespace
detail
{
namespace
detail
{
...
...
modules/videoio/src/cap_ffmpeg_impl.hpp
View file @
51e54305
...
@@ -870,7 +870,12 @@ bool CvCapture_FFMPEG::open( const char* _filename )
...
@@ -870,7 +870,12 @@ bool CvCapture_FFMPEG::open( const char* _filename )
int
enc_width
=
enc
->
width
;
int
enc_width
=
enc
->
width
;
int
enc_height
=
enc
->
height
;
int
enc_height
=
enc
->
height
;
AVCodec
*
codec
=
avcodec_find_decoder
(
enc
->
codec_id
);
AVCodec
*
codec
;
if
(
av_dict_get
(
dict
,
"video_codec"
,
NULL
,
0
)
==
NULL
)
{
codec
=
avcodec_find_decoder
(
enc
->
codec_id
);
}
else
{
codec
=
avcodec_find_decoder_by_name
(
av_dict_get
(
dict
,
"video_codec"
,
NULL
,
0
)
->
value
);
}
if
(
!
codec
||
if
(
!
codec
||
#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
avcodec_open2
(
enc
,
codec
,
NULL
)
avcodec_open2
(
enc
,
codec
,
NULL
)
...
...
modules/videoio/src/cap_qt.cpp
View file @
51e54305
...
@@ -634,11 +634,11 @@ static int icvOpenCamera_QT (CvCapture_QT_Cam * capture, const int index)
...
@@ -634,11 +634,11 @@ static int icvOpenCamera_QT (CvCapture_QT_Cam * capture, const int index)
OPENCV_ASSERT
(
capture
,
"icvOpenCamera_QT"
,
"'capture' is a NULL-pointer"
);
OPENCV_ASSERT
(
capture
,
"icvOpenCamera_QT"
,
"'capture' is a NULL-pointer"
);
OPENCV_ASSERT
(
index
>=
0
,
"icvOpenCamera_QT"
,
"camera index is negative"
);
OPENCV_ASSERT
(
index
>=
0
,
"icvOpenCamera_QT"
,
"camera index is negative"
);
ComponentDescription
component_description
;
ComponentDescription
component_description
;
Component
component
=
0
;
Component
component
=
0
;
int
number_of_inputs
=
0
;
int
number_of_inputs
=
0
;
Rect
myRect
;
Rect
myRect
;
ComponentResult
result
=
noErr
;
ComponentResult
result
=
noErr
;
// travers all components and count video digitizer channels
// travers all components and count video digitizer channels
...
...
samples/cpp/tutorial_code/dnn/custom_layers.cpp
View file @
51e54305
...
@@ -16,18 +16,18 @@ public:
...
@@ -16,18 +16,18 @@ public:
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
std
::
vector
<
int
>
>
&
inputs
,
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
std
::
vector
<
int
>
>
&
inputs
,
const
int
requiredOutputs
,
const
int
requiredOutputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
outputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
outputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
internals
)
const
;
std
::
vector
<
std
::
vector
<
int
>
>
&
internals
)
const
CV_OVERRIDE
;
//! [MyLayer::getMemoryShapes]
//! [MyLayer::getMemoryShapes]
//! [MyLayer::forward]
//! [MyLayer::forward]
virtual
void
forward
(
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
,
std
::
vector
<
cv
::
Mat
>
&
internals
);
virtual
void
forward
(
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
,
std
::
vector
<
cv
::
Mat
>
&
internals
)
CV_OVERRIDE
;
//! [MyLayer::forward]
//! [MyLayer::forward]
//! [MyLayer::finalize]
//! [MyLayer::finalize]
virtual
void
finalize
(
const
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
);
virtual
void
finalize
(
const
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
)
CV_OVERRIDE
;
//! [MyLayer::finalize]
//! [MyLayer::finalize]
virtual
void
forward
(
cv
::
InputArrayOfArrays
inputs
,
cv
::
OutputArrayOfArrays
outputs
,
cv
::
OutputArrayOfArrays
internals
);
virtual
void
forward
(
cv
::
InputArrayOfArrays
inputs
,
cv
::
OutputArrayOfArrays
outputs
,
cv
::
OutputArrayOfArrays
internals
)
CV_OVERRIDE
;
};
};
//! [A custom layer interface]
//! [A custom layer interface]
...
@@ -49,7 +49,7 @@ public:
...
@@ -49,7 +49,7 @@ public:
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
std
::
vector
<
int
>
>
&
inputs
,
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
std
::
vector
<
int
>
>
&
inputs
,
const
int
requiredOutputs
,
const
int
requiredOutputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
outputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
outputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
internals
)
const
std
::
vector
<
std
::
vector
<
int
>
>
&
internals
)
const
CV_OVERRIDE
{
{
CV_UNUSED
(
requiredOutputs
);
CV_UNUSED
(
internals
);
CV_UNUSED
(
requiredOutputs
);
CV_UNUSED
(
internals
);
std
::
vector
<
int
>
outShape
(
4
);
std
::
vector
<
int
>
outShape
(
4
);
...
@@ -62,7 +62,7 @@ public:
...
@@ -62,7 +62,7 @@ public:
}
}
// Implementation of this custom layer is based on https://github.com/cdmh/deeplab-public/blob/master/src/caffe/layers/interp_layer.cpp
// Implementation of this custom layer is based on https://github.com/cdmh/deeplab-public/blob/master/src/caffe/layers/interp_layer.cpp
virtual
void
forward
(
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
,
std
::
vector
<
cv
::
Mat
>
&
internals
)
virtual
void
forward
(
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
,
std
::
vector
<
cv
::
Mat
>
&
internals
)
CV_OVERRIDE
{
{
CV_UNUSED
(
internals
);
CV_UNUSED
(
internals
);
cv
::
Mat
&
inp
=
*
inputs
[
0
];
cv
::
Mat
&
inp
=
*
inputs
[
0
];
...
@@ -105,7 +105,7 @@ public:
...
@@ -105,7 +105,7 @@ public:
}
}
}
}
virtual
void
forward
(
cv
::
InputArrayOfArrays
,
cv
::
OutputArrayOfArrays
,
cv
::
OutputArrayOfArrays
)
{}
virtual
void
forward
(
cv
::
InputArrayOfArrays
,
cv
::
OutputArrayOfArrays
,
cv
::
OutputArrayOfArrays
)
CV_OVERRIDE
{}
private
:
private
:
int
outWidth
,
outHeight
;
int
outWidth
,
outHeight
;
...
@@ -132,7 +132,7 @@ public:
...
@@ -132,7 +132,7 @@ public:
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
std
::
vector
<
int
>
>
&
inputs
,
virtual
bool
getMemoryShapes
(
const
std
::
vector
<
std
::
vector
<
int
>
>
&
inputs
,
const
int
requiredOutputs
,
const
int
requiredOutputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
outputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
outputs
,
std
::
vector
<
std
::
vector
<
int
>
>
&
internals
)
const
std
::
vector
<
std
::
vector
<
int
>
>
&
internals
)
const
CV_OVERRIDE
{
{
CV_UNUSED
(
requiredOutputs
);
CV_UNUSED
(
internals
);
CV_UNUSED
(
requiredOutputs
);
CV_UNUSED
(
internals
);
std
::
vector
<
int
>
outShape
(
4
);
std
::
vector
<
int
>
outShape
(
4
);
...
@@ -146,7 +146,7 @@ public:
...
@@ -146,7 +146,7 @@ public:
// This implementation is based on a reference implementation from
// This implementation is based on a reference implementation from
// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/kernels/internal/reference/reference_ops.h
// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/kernels/internal/reference/reference_ops.h
virtual
void
forward
(
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
,
std
::
vector
<
cv
::
Mat
>
&
internals
)
virtual
void
forward
(
std
::
vector
<
cv
::
Mat
*>
&
inputs
,
std
::
vector
<
cv
::
Mat
>
&
outputs
,
std
::
vector
<
cv
::
Mat
>
&
internals
)
CV_OVERRIDE
{
{
CV_UNUSED
(
internals
);
CV_UNUSED
(
internals
);
cv
::
Mat
&
inp
=
*
inputs
[
0
];
cv
::
Mat
&
inp
=
*
inputs
[
0
];
...
@@ -187,7 +187,7 @@ public:
...
@@ -187,7 +187,7 @@ public:
}
}
}
}
virtual
void
forward
(
cv
::
InputArrayOfArrays
,
cv
::
OutputArrayOfArrays
,
cv
::
OutputArrayOfArrays
)
{}
virtual
void
forward
(
cv
::
InputArrayOfArrays
,
cv
::
OutputArrayOfArrays
,
cv
::
OutputArrayOfArrays
)
CV_OVERRIDE
{}
private
:
private
:
static
inline
int
offset
(
const
cv
::
MatSize
&
size
,
int
c
,
int
x
,
int
y
,
int
b
)
static
inline
int
offset
(
const
cv
::
MatSize
&
size
,
int
c
,
int
x
,
int
y
,
int
b
)
...
...
samples/dnn/object_detection.cpp
View file @
51e54305
...
@@ -7,12 +7,13 @@
...
@@ -7,12 +7,13 @@
const
char
*
keys
=
const
char
*
keys
=
"{ help h | | Print help message. }"
"{ help h | | Print help message. }"
"{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}"
"{ device | 0 | camera device number. }"
"{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera. }"
"{ model m | | Path to a binary file of model contains trained weights. "
"{ model m | | Path to a binary file of model contains trained weights. "
"It could be a file with extensions .caffemodel (Caffe), "
"It could be a file with extensions .caffemodel (Caffe), "
".pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet)
}"
".pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet)
.
}"
"{ config c | | Path to a text file of model contains network configuration. "
"{ config c | | Path to a text file of model contains network configuration. "
"It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet)
}"
"It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet)
.
}"
"{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }"
"{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }"
"{ classes | | Optional path to a text file with names of classes to label detected objects. }"
"{ classes | | Optional path to a text file with names of classes to label detected objects. }"
"{ mean | | Preprocess input image by subtracting mean values. Mean values should be in BGR order and delimited by spaces. }"
"{ mean | | Preprocess input image by subtracting mean values. Mean values should be in BGR order and delimited by spaces. }"
...
@@ -91,7 +92,7 @@ int main(int argc, char** argv)
...
@@ -91,7 +92,7 @@ int main(int argc, char** argv)
if
(
parser
.
has
(
"input"
))
if
(
parser
.
has
(
"input"
))
cap
.
open
(
parser
.
get
<
String
>
(
"input"
));
cap
.
open
(
parser
.
get
<
String
>
(
"input"
));
else
else
cap
.
open
(
0
);
cap
.
open
(
parser
.
get
<
int
>
(
"device"
)
);
// Process frames.
// Process frames.
Mat
frame
,
blob
;
Mat
frame
,
blob
;
...
...
samples/dnn/openpose.cpp
View file @
51e54305
...
@@ -61,12 +61,16 @@ int main(int argc, char **argv)
...
@@ -61,12 +61,16 @@ 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) }"
"{ width | 368 | Preprocess input image by resizing to a specific width. }"
"{ 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 }"
);
);
String
modelTxt
=
parser
.
get
<
string
>
(
"proto"
);
String
modelTxt
=
parser
.
get
<
string
>
(
"proto"
);
String
modelBin
=
parser
.
get
<
string
>
(
"model"
);
String
modelBin
=
parser
.
get
<
string
>
(
"model"
);
String
imageFile
=
parser
.
get
<
String
>
(
"image"
);
String
imageFile
=
parser
.
get
<
String
>
(
"image"
);
int
W_in
=
parser
.
get
<
int
>
(
"width"
);
int
H_in
=
parser
.
get
<
int
>
(
"height"
);
float
thresh
=
parser
.
get
<
float
>
(
"threshold"
);
float
thresh
=
parser
.
get
<
float
>
(
"threshold"
);
if
(
parser
.
get
<
bool
>
(
"help"
)
||
modelTxt
.
empty
()
||
modelBin
.
empty
()
||
imageFile
.
empty
())
if
(
parser
.
get
<
bool
>
(
"help"
)
||
modelTxt
.
empty
()
||
modelBin
.
empty
()
||
imageFile
.
empty
())
{
{
...
@@ -75,10 +79,6 @@ int main(int argc, char **argv)
...
@@ -75,10 +79,6 @@ int main(int argc, char **argv)
return
0
;
return
0
;
}
}
// fixed input size for the pretrained network
int
W_in
=
368
;
int
H_in
=
368
;
// read the network model
// read the network model
Net
net
=
readNetFromCaffe
(
modelTxt
,
modelBin
);
Net
net
=
readNetFromCaffe
(
modelTxt
,
modelBin
);
...
...
samples/dnn/segmentation.cpp
View file @
51e54305
...
@@ -7,12 +7,13 @@
...
@@ -7,12 +7,13 @@
const
char
*
keys
=
const
char
*
keys
=
"{ help h | | Print help message. }"
"{ help h | | Print help message. }"
"{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera.}"
"{ device | 0 | camera device number. }"
"{ input i | | Path to input image or video file. Skip this argument to capture frames from a camera. }"
"{ model m | | Path to a binary file of model contains trained weights. "
"{ model m | | Path to a binary file of model contains trained weights. "
"It could be a file with extensions .caffemodel (Caffe), "
"It could be a file with extensions .caffemodel (Caffe), "
".pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet) }"
".pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet)
.
}"
"{ config c | | Path to a text file of model contains network configuration. "
"{ config c | | Path to a text file of model contains network configuration. "
"It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet) }"
"It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet)
.
}"
"{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }"
"{ framework f | | Optional name of an origin framework of the model. Detect it automatically if it does not set. }"
"{ classes | | Optional path to a text file with names of classes. }"
"{ classes | | Optional path to a text file with names of classes. }"
"{ colors | | Optional path to a text file with colors for an every class. "
"{ colors | | Optional path to a text file with colors for an every class. "
...
@@ -111,7 +112,7 @@ int main(int argc, char** argv)
...
@@ -111,7 +112,7 @@ int main(int argc, char** argv)
if
(
parser
.
has
(
"input"
))
if
(
parser
.
has
(
"input"
))
cap
.
open
(
parser
.
get
<
String
>
(
"input"
));
cap
.
open
(
parser
.
get
<
String
>
(
"input"
));
else
else
cap
.
open
(
0
);
cap
.
open
(
parser
.
get
<
int
>
(
"device"
)
);
//! [Open a video file or an image file or a camera stream]
//! [Open a video file or an image file or a camera stream]
// Process frames.
// Process frames.
...
...
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