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
3d8ca010
Commit
3d8ca010
authored
Apr 25, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switched to Input/Output Array in split/merge operations
parent
58c4d0ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
59 deletions
+49
-59
gpuarithm.hpp
modules/gpuarithm/include/opencv2/gpuarithm.hpp
+8
-12
core.cpp
modules/gpuarithm/src/core.cpp
+39
-45
split_merge.cu
modules/gpuarithm/src/cuda/split_merge.cu
+2
-2
No files found.
modules/gpuarithm/include/opencv2/gpuarithm.hpp
View file @
3d8ca010
...
...
@@ -162,6 +162,14 @@ CV_EXPORTS void cartToPolar(InputArray x, InputArray y, OutputArray magnitude, O
//! supports only floating-point source
CV_EXPORTS
void
polarToCart
(
InputArray
magnitude
,
InputArray
angle
,
OutputArray
x
,
OutputArray
y
,
bool
angleInDegrees
=
false
,
Stream
&
stream
=
Stream
::
Null
());
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS
void
merge
(
const
GpuMat
*
src
,
size_t
n
,
OutputArray
dst
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
merge
(
const
std
::
vector
<
GpuMat
>&
src
,
OutputArray
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS
void
split
(
InputArray
src
,
GpuMat
*
dst
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
void
split
(
InputArray
src
,
std
::
vector
<
GpuMat
>&
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! implements generalized matrix product algorithm GEMM from BLAS
CV_EXPORTS
void
gemm
(
const
GpuMat
&
src1
,
const
GpuMat
&
src2
,
double
alpha
,
const
GpuMat
&
src3
,
double
beta
,
GpuMat
&
dst
,
int
flags
=
0
,
Stream
&
stream
=
Stream
::
Null
());
...
...
@@ -179,18 +187,6 @@ CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode, Stream& stream =
//! supports CV_8UC1, CV_8UC3 types
CV_EXPORTS
void
LUT
(
const
GpuMat
&
src
,
const
Mat
&
lut
,
GpuMat
&
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS
void
merge
(
const
GpuMat
*
src
,
size_t
n
,
GpuMat
&
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! makes multi-channel array out of several single-channel arrays
CV_EXPORTS
void
merge
(
const
std
::
vector
<
GpuMat
>&
src
,
GpuMat
&
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS
void
split
(
const
GpuMat
&
src
,
GpuMat
*
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS
void
split
(
const
GpuMat
&
src
,
std
::
vector
<
GpuMat
>&
dst
,
Stream
&
stream
=
Stream
::
Null
());
//! scales and shifts array elements so that either the specified norm (alpha) or the minimum (alpha) and maximum (beta) array values get the specified values
CV_EXPORTS
void
normalize
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
double
alpha
=
1
,
double
beta
=
0
,
int
norm_type
=
NORM_L2
,
int
dtype
=
-
1
,
const
GpuMat
&
mask
=
GpuMat
());
...
...
modules/gpuarithm/src/core.cpp
View file @
3d8ca010
...
...
@@ -47,11 +47,11 @@ using namespace cv::gpu;
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
void
cv
::
gpu
::
merge
(
const
GpuMat
*
/*src*/
,
size_t
/*count*/
,
GpuMat
&
/*dst*/
,
Stream
&
/*stream*/
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
merge
(
const
std
::
vector
<
GpuMat
>&
/*src*/
,
GpuMat
&
/*dst*/
,
Stream
&
/*stream*/
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
merge
(
const
GpuMat
*
,
size_t
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
merge
(
const
std
::
vector
<
GpuMat
>&
,
OutputArray
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
split
(
const
GpuMat
&
/*src*/
,
GpuMat
*
/*dst*/
,
Stream
&
/*stream*/
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
split
(
const
GpuMat
&
/*src*/
,
std
::
vector
<
GpuMat
>&
/*dst*/
,
Stream
&
/*stream*/
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
split
(
InputArray
,
GpuMat
*
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
split
(
InputArray
,
std
::
vector
<
GpuMat
>&
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
transpose
(
const
GpuMat
&
,
GpuMat
&
,
Stream
&
)
{
throw_no_cuda
();
}
...
...
@@ -70,22 +70,27 @@ namespace cv { namespace gpu { namespace cudev
{
namespace
split_merge
{
void
merge
_caller
(
const
PtrStepSzb
*
src
,
PtrStepSzb
&
dst
,
int
total_channels
,
size_t
elem_size
,
const
cudaStream_t
&
stream
);
void
split
_caller
(
const
PtrStepSzb
&
src
,
PtrStepSzb
*
dst
,
int
num_channels
,
size_t
elem_size1
,
const
cudaStream_t
&
stream
);
void
merge
(
const
PtrStepSzb
*
src
,
PtrStepSzb
&
dst
,
int
total_channels
,
size_t
elem_size
,
const
cudaStream_t
&
stream
);
void
split
(
const
PtrStepSzb
&
src
,
PtrStepSzb
*
dst
,
int
num_channels
,
size_t
elem_size1
,
const
cudaStream_t
&
stream
);
}
}}}
namespace
{
void
merge
(
const
GpuMat
*
src
,
size_t
n
,
GpuMat
&
dst
,
const
cudaStream_t
&
stream
)
void
merge
_caller
(
const
GpuMat
*
src
,
size_t
n
,
OutputArray
_dst
,
Stream
&
stream
)
{
using
namespace
::
cv
::
gpu
::
cudev
::
split_merge
;
CV_Assert
(
src
!=
0
);
CV_Assert
(
n
>
0
&&
n
<=
4
);
CV_Assert
(
src
);
CV_Assert
(
n
>
0
);
const
int
depth
=
src
[
0
].
depth
(
);
const
Size
size
=
src
[
0
].
size
(
);
int
depth
=
src
[
0
].
depth
();
Size
size
=
src
[
0
].
size
();
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
CV_Assert
(
src
[
i
].
size
()
==
size
);
CV_Assert
(
src
[
i
].
depth
()
==
depth
);
CV_Assert
(
src
[
i
].
channels
()
==
1
);
}
if
(
depth
==
CV_64F
)
{
...
...
@@ -93,43 +98,32 @@ namespace
CV_Error
(
cv
::
Error
::
StsUnsupportedFormat
,
"The device doesn't support double"
);
}
bool
single_channel_only
=
true
;
int
total_channels
=
0
;
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
if
(
n
==
1
)
{
CV_Assert
(
src
[
i
].
size
()
==
size
);
CV_Assert
(
src
[
i
].
depth
()
==
depth
);
single_channel_only
=
single_channel_only
&&
src
[
i
].
channels
()
==
1
;
total_channels
+=
src
[
i
].
channels
();
src
[
0
].
copyTo
(
_dst
,
stream
);
}
CV_Assert
(
single_channel_only
);
CV_Assert
(
total_channels
<=
4
);
if
(
total_channels
==
1
)
src
[
0
].
copyTo
(
dst
);
else
{
dst
.
create
(
size
,
CV_MAKETYPE
(
depth
,
total_channels
));
_dst
.
create
(
size
,
CV_MAKE_TYPE
(
depth
,
(
int
)
n
));
GpuMat
dst
=
_dst
.
getGpuMat
();
PtrStepSzb
src_as_devmem
[
4
];
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
src_as_devmem
[
i
]
=
src
[
i
];
PtrStepSzb
dst_as_devmem
(
dst
);
merge_caller
(
src_as_devmem
,
dst_as_devmem
,
total_channels
,
CV_ELEM_SIZE
(
depth
),
stream
);
cv
::
gpu
::
cudev
::
split_merge
::
merge
(
src_as_devmem
,
dst_as_devmem
,
(
int
)
n
,
CV_ELEM_SIZE
(
depth
),
StreamAccessor
::
getStream
(
stream
)
);
}
}
void
split
(
const
GpuMat
&
src
,
GpuMat
*
dst
,
const
cudaStream_t
&
stream
)
void
split
_caller
(
const
GpuMat
&
src
,
GpuMat
*
dst
,
Stream
&
stream
)
{
using
namespace
::
cv
::
gpu
::
cudev
::
split_merge
;
CV_Assert
(
dst
!=
0
)
;
CV_Assert
(
dst
);
const
int
depth
=
src
.
depth
();
const
int
num_channels
=
src
.
channels
();
int
depth
=
src
.
depth
();
int
num_channels
=
src
.
channels
();
CV_Assert
(
num_channels
<=
4
);
if
(
depth
==
CV_64F
)
{
...
...
@@ -139,45 +133,45 @@ namespace
if
(
num_channels
==
1
)
{
src
.
copyTo
(
dst
[
0
]);
src
.
copyTo
(
dst
[
0
]
,
stream
);
return
;
}
for
(
int
i
=
0
;
i
<
num_channels
;
++
i
)
dst
[
i
].
create
(
src
.
size
(),
depth
);
CV_Assert
(
num_channels
<=
4
);
PtrStepSzb
dst_as_devmem
[
4
];
for
(
int
i
=
0
;
i
<
num_channels
;
++
i
)
dst_as_devmem
[
i
]
=
dst
[
i
];
PtrStepSzb
src_as_devmem
(
src
);
split_caller
(
src_as_devmem
,
dst_as_devmem
,
num_channels
,
src
.
elemSize1
(),
stream
);
cv
::
gpu
::
cudev
::
split_merge
::
split
(
src_as_devmem
,
dst_as_devmem
,
num_channels
,
src
.
elemSize1
(),
StreamAccessor
::
getStream
(
stream
)
);
}
}
void
cv
::
gpu
::
merge
(
const
GpuMat
*
src
,
size_t
n
,
GpuMat
&
dst
,
Stream
&
stream
)
void
cv
::
gpu
::
merge
(
const
GpuMat
*
src
,
size_t
n
,
OutputArray
dst
,
Stream
&
stream
)
{
::
merge
(
src
,
n
,
dst
,
StreamAccessor
::
getStream
(
stream
)
);
merge_caller
(
src
,
n
,
dst
,
stream
);
}
void
cv
::
gpu
::
merge
(
const
std
::
vector
<
GpuMat
>&
src
,
GpuMat
&
dst
,
Stream
&
stream
)
void
cv
::
gpu
::
merge
(
const
std
::
vector
<
GpuMat
>&
src
,
OutputArray
dst
,
Stream
&
stream
)
{
::
merge
(
&
src
[
0
],
src
.
size
(),
dst
,
StreamAccessor
::
getStream
(
stream
)
);
merge_caller
(
&
src
[
0
],
src
.
size
(),
dst
,
stream
);
}
void
cv
::
gpu
::
split
(
const
GpuMat
&
src
,
GpuMat
*
dst
,
Stream
&
stream
)
void
cv
::
gpu
::
split
(
InputArray
_
src
,
GpuMat
*
dst
,
Stream
&
stream
)
{
::
split
(
src
,
dst
,
StreamAccessor
::
getStream
(
stream
));
GpuMat
src
=
_src
.
getGpuMat
();
split_caller
(
src
,
dst
,
stream
);
}
void
cv
::
gpu
::
split
(
const
GpuMat
&
src
,
std
::
vector
<
GpuMat
>&
dst
,
Stream
&
stream
)
void
cv
::
gpu
::
split
(
InputArray
_
src
,
std
::
vector
<
GpuMat
>&
dst
,
Stream
&
stream
)
{
GpuMat
src
=
_src
.
getGpuMat
();
dst
.
resize
(
src
.
channels
());
if
(
src
.
channels
()
>
0
)
::
split
(
src
,
&
dst
[
0
],
StreamAccessor
::
getStream
(
stream
)
);
split_caller
(
src
,
&
dst
[
0
],
stream
);
}
////////////////////////////////////////////////////////////////////////
...
...
modules/gpuarithm/src/cuda/split_merge.cu
View file @
3d8ca010
...
...
@@ -278,7 +278,7 @@ namespace cv { namespace gpu { namespace cudev
}
void merge
_caller
(const PtrStepSzb* src, PtrStepSzb& dst,
void merge(const PtrStepSzb* src, PtrStepSzb& dst,
int total_channels, size_t elem_size,
const cudaStream_t& stream)
{
...
...
@@ -487,7 +487,7 @@ namespace cv { namespace gpu { namespace cudev
}
void split
_caller
(const PtrStepSzb& src, PtrStepSzb* dst, int num_channels, size_t elem_size1, const cudaStream_t& stream)
void split(const PtrStepSzb& src, PtrStepSzb* dst, int num_channels, size_t elem_size1, const cudaStream_t& stream)
{
static SplitFunction split_func_tbl[] =
{
...
...
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