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
4f7cfbc2
Commit
4f7cfbc2
authored
Feb 26, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed gpu bitwise operations with scalars
parent
a138e12a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
23 deletions
+24
-23
element_operations.cu
modules/gpu/src/cuda/element_operations.cu
+6
-3
element_operations.cpp
modules/gpu/src/element_operations.cpp
+17
-19
test_core.cpp
modules/gpu/test/test_core.cpp
+1
-1
No files found.
modules/gpu/src/cuda/element_operations.cu
View file @
4f7cfbc2
...
...
@@ -2284,15 +2284,18 @@ namespace arithm
template void bitScalarAnd<uchar>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarAnd<ushort>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarAnd<uint>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarAnd<int>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarAnd<unsigned int>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarOr<uchar>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarOr<ushort>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarOr<uint>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarOr<int>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarOr<unsigned int>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarXor<uchar>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarXor<ushort>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarXor<uint>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarXor<int>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
template void bitScalarXor<unsigned int>(PtrStepSzb src1, uint src2, PtrStepSzb dst, cudaStream_t stream);
}
//////////////////////////////////////////////////////////////////////////
...
...
modules/gpu/src/element_operations.cpp
View file @
4f7cfbc2
...
...
@@ -2280,11 +2280,11 @@ namespace
{
typedef
void
(
*
bit_scalar_func_t
)(
PtrStepSzb
src1
,
unsigned
int
src2
,
PtrStepSzb
dst
,
cudaStream_t
stream
);
template
<
bit_scalar_func_t
func
>
struct
BitScalar
template
<
typename
T
,
bit_scalar_func_t
func
>
struct
BitScalar
{
static
void
call
(
const
GpuMat
&
src
,
Scalar
sc
,
GpuMat
&
dst
,
cudaStream_t
stream
)
{
func
(
src
,
s
tatic_cast
<
unsigned
int
>
(
sc
.
val
[
0
]),
dst
,
stream
);
func
(
src
,
s
aturate_cast
<
T
>
(
sc
.
val
[
0
]),
dst
,
stream
);
}
};
...
...
@@ -2292,14 +2292,12 @@ namespace
{
static
void
call
(
const
GpuMat
&
src
,
Scalar
sc
,
GpuMat
&
dst
,
cudaStream_t
stream
)
{
Scalar_
<
unsigned
int
>
isc
=
sc
;
unsigned
int
packedVal
=
0
;
packedVal
|=
(
isc
.
val
[
0
]
&
0xffff
);
packedVal
|=
(
isc
.
val
[
1
]
&
0xffff
)
<<
8
;
packedVal
|=
(
isc
.
val
[
2
]
&
0xffff
)
<<
16
;
packedVal
|=
(
isc
.
val
[
3
]
&
0xffff
)
<<
24
;
packedVal
|=
(
saturate_cast
<
unsigned
char
>
(
sc
.
val
[
0
])
&
0xffff
);
packedVal
|=
(
saturate_cast
<
unsigned
char
>
(
sc
.
val
[
1
])
&
0xffff
)
<<
8
;
packedVal
|=
(
saturate_cast
<
unsigned
char
>
(
sc
.
val
[
2
])
&
0xffff
)
<<
16
;
packedVal
|=
(
saturate_cast
<
unsigned
char
>
(
sc
.
val
[
3
])
&
0xffff
)
<<
24
;
func
(
src
,
packedVal
,
dst
,
stream
);
}
...
...
@@ -2330,7 +2328,7 @@ namespace
oSizeROI
.
width
=
src
.
cols
;
oSizeROI
.
height
=
src
.
rows
;
const
npp_t
pConstants
[]
=
{
s
tatic_cast
<
npp_t
>
(
sc
.
val
[
0
]),
static_cast
<
npp_t
>
(
sc
.
val
[
1
]),
static_cast
<
npp_t
>
(
sc
.
val
[
2
]),
static
_cast
<
npp_t
>
(
sc
.
val
[
3
])};
const
npp_t
pConstants
[]
=
{
s
aturate_cast
<
npp_t
>
(
sc
.
val
[
0
]),
saturate_cast
<
npp_t
>
(
sc
.
val
[
1
]),
saturate_cast
<
npp_t
>
(
sc
.
val
[
2
]),
saturate
_cast
<
npp_t
>
(
sc
.
val
[
3
])};
nppSafeCall
(
func
(
src
.
ptr
<
npp_t
>
(),
static_cast
<
int
>
(
src
.
step
),
pConstants
,
dst
.
ptr
<
npp_t
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
)
);
...
...
@@ -2350,7 +2348,7 @@ namespace
oSizeROI
.
width
=
src
.
cols
;
oSizeROI
.
height
=
src
.
rows
;
nppSafeCall
(
func
(
src
.
ptr
<
npp_t
>
(),
static_cast
<
int
>
(
src
.
step
),
s
tatic
_cast
<
npp_t
>
(
sc
.
val
[
0
]),
dst
.
ptr
<
npp_t
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
)
);
nppSafeCall
(
func
(
src
.
ptr
<
npp_t
>
(),
static_cast
<
int
>
(
src
.
step
),
s
aturate
_cast
<
npp_t
>
(
sc
.
val
[
0
]),
dst
.
ptr
<
npp_t
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
)
);
if
(
stream
==
0
)
cudaSafeCall
(
cudaDeviceSynchronize
()
);
...
...
@@ -2365,11 +2363,11 @@ void cv::gpu::bitwise_and(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stre
typedef
void
(
*
func_t
)(
const
GpuMat
&
src
,
Scalar
sc
,
GpuMat
&
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
5
][
4
]
=
{
{
BitScalar
<
bitScalarAnd
<
unsigned
char
>
>::
call
,
0
,
NppBitwiseC
<
CV_8U
,
3
,
nppiAndC_8u_C3R
>::
call
,
BitScalar4
<
bitScalarAnd
<
unsigned
int
>
>::
call
},
{
BitScalar
<
unsigned
char
,
bitScalarAnd
<
unsigned
char
>
>::
call
,
0
,
NppBitwiseC
<
CV_8U
,
3
,
nppiAndC_8u_C3R
>::
call
,
BitScalar4
<
bitScalarAnd
<
unsigned
int
>
>::
call
},
{
0
,
0
,
0
,
0
},
{
BitScalar
<
bitScalarAnd
<
unsigned
short
>
>::
call
,
0
,
NppBitwiseC
<
CV_16U
,
3
,
nppiAndC_16u_C3R
>::
call
,
NppBitwiseC
<
CV_16U
,
4
,
nppiAndC_16u_C4R
>::
call
},
{
BitScalar
<
unsigned
short
,
bitScalarAnd
<
unsigned
short
>
>::
call
,
0
,
NppBitwiseC
<
CV_16U
,
3
,
nppiAndC_16u_C3R
>::
call
,
NppBitwiseC
<
CV_16U
,
4
,
nppiAndC_16u_C4R
>::
call
},
{
0
,
0
,
0
,
0
},
{
BitScalar
<
bitScalarAnd
<
unsigned
int
>
>::
call
,
0
,
NppBitwiseC
<
CV_32S
,
3
,
nppiAndC_32s_C3R
>::
call
,
NppBitwiseC
<
CV_32S
,
4
,
nppiAndC_32s_C4R
>::
call
}
{
BitScalar
<
int
,
bitScalarAnd
<
int
>
>::
call
,
0
,
NppBitwiseC
<
CV_32S
,
3
,
nppiAndC_32s_C3R
>::
call
,
NppBitwiseC
<
CV_32S
,
4
,
nppiAndC_32s_C4R
>::
call
}
};
const
int
depth
=
src
.
depth
();
...
...
@@ -2390,11 +2388,11 @@ void cv::gpu::bitwise_or(const GpuMat& src, const Scalar& sc, GpuMat& dst, Strea
typedef
void
(
*
func_t
)(
const
GpuMat
&
src
,
Scalar
sc
,
GpuMat
&
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
5
][
4
]
=
{
{
BitScalar
<
bitScalarOr
<
unsigned
char
>
>::
call
,
0
,
NppBitwiseC
<
CV_8U
,
3
,
nppiOrC_8u_C3R
>::
call
,
BitScalar4
<
bitScalarOr
<
unsigned
int
>
>::
call
},
{
BitScalar
<
unsigned
char
,
bitScalarOr
<
unsigned
char
>
>::
call
,
0
,
NppBitwiseC
<
CV_8U
,
3
,
nppiOrC_8u_C3R
>::
call
,
BitScalar4
<
bitScalarOr
<
unsigned
int
>
>::
call
},
{
0
,
0
,
0
,
0
},
{
BitScalar
<
bitScalarOr
<
unsigned
short
>
>::
call
,
0
,
NppBitwiseC
<
CV_16U
,
3
,
nppiOrC_16u_C3R
>::
call
,
NppBitwiseC
<
CV_16U
,
4
,
nppiOrC_16u_C4R
>::
call
},
{
BitScalar
<
unsigned
short
,
bitScalarOr
<
unsigned
short
>
>::
call
,
0
,
NppBitwiseC
<
CV_16U
,
3
,
nppiOrC_16u_C3R
>::
call
,
NppBitwiseC
<
CV_16U
,
4
,
nppiOrC_16u_C4R
>::
call
},
{
0
,
0
,
0
,
0
},
{
BitScalar
<
bitScalarOr
<
unsigned
int
>
>::
call
,
0
,
NppBitwiseC
<
CV_32S
,
3
,
nppiOrC_32s_C3R
>::
call
,
NppBitwiseC
<
CV_32S
,
4
,
nppiOrC_32s_C4R
>::
call
}
{
BitScalar
<
int
,
bitScalarOr
<
int
>
>::
call
,
0
,
NppBitwiseC
<
CV_32S
,
3
,
nppiOrC_32s_C3R
>::
call
,
NppBitwiseC
<
CV_32S
,
4
,
nppiOrC_32s_C4R
>::
call
}
};
const
int
depth
=
src
.
depth
();
...
...
@@ -2415,11 +2413,11 @@ void cv::gpu::bitwise_xor(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stre
typedef
void
(
*
func_t
)(
const
GpuMat
&
src
,
Scalar
sc
,
GpuMat
&
dst
,
cudaStream_t
stream
);
static
const
func_t
funcs
[
5
][
4
]
=
{
{
BitScalar
<
bitScalarXor
<
unsigned
char
>
>::
call
,
0
,
NppBitwiseC
<
CV_8U
,
3
,
nppiXorC_8u_C3R
>::
call
,
BitScalar4
<
bitScalarXor
<
unsigned
int
>
>::
call
},
{
BitScalar
<
unsigned
char
,
bitScalarXor
<
unsigned
char
>
>::
call
,
0
,
NppBitwiseC
<
CV_8U
,
3
,
nppiXorC_8u_C3R
>::
call
,
BitScalar4
<
bitScalarXor
<
unsigned
int
>
>::
call
},
{
0
,
0
,
0
,
0
},
{
BitScalar
<
bitScalarXor
<
unsigned
short
>
>::
call
,
0
,
NppBitwiseC
<
CV_16U
,
3
,
nppiXorC_16u_C3R
>::
call
,
NppBitwiseC
<
CV_16U
,
4
,
nppiXorC_16u_C4R
>::
call
},
{
BitScalar
<
unsigned
short
,
bitScalarXor
<
unsigned
short
>
>::
call
,
0
,
NppBitwiseC
<
CV_16U
,
3
,
nppiXorC_16u_C3R
>::
call
,
NppBitwiseC
<
CV_16U
,
4
,
nppiXorC_16u_C4R
>::
call
},
{
0
,
0
,
0
,
0
},
{
BitScalar
<
bitScalarXor
<
unsigned
int
>
>::
call
,
0
,
NppBitwiseC
<
CV_32S
,
3
,
nppiXorC_32s_C3R
>::
call
,
NppBitwiseC
<
CV_32S
,
4
,
nppiXorC_32s_C4R
>::
call
}
{
BitScalar
<
int
,
bitScalarXor
<
int
>
>::
call
,
0
,
NppBitwiseC
<
CV_32S
,
3
,
nppiXorC_32s_C3R
>::
call
,
NppBitwiseC
<
CV_32S
,
4
,
nppiXorC_32s_C4R
>::
call
}
};
const
int
depth
=
src
.
depth
();
...
...
modules/gpu/test/test_core.cpp
View file @
4f7cfbc2
...
...
@@ -1873,7 +1873,7 @@ PARAM_TEST_CASE(Bitwise_Scalar, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channel
cv
::
gpu
::
setDevice
(
devInfo
.
deviceID
());
src
=
randomMat
(
size
,
CV_MAKE_TYPE
(
depth
,
channels
));
cv
::
Scalar_
<
int
>
ival
=
randomScalar
(
0.0
,
255.0
);
cv
::
Scalar_
<
int
>
ival
=
randomScalar
(
0.0
,
std
::
numeric_limits
<
int
>::
max
()
);
val
=
ival
;
}
};
...
...
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