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
7c8c836a
Commit
7c8c836a
authored
Aug 26, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switched to new device layer in polar <-> cart
parent
5522f43b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
106 deletions
+24
-106
polar_cart.cu
modules/cudaarithm/src/cuda/polar_cart.cu
+0
-0
element_operations.cpp
modules/cudaarithm/src/element_operations.cpp
+0
-106
functional.hpp
...les/cudev/include/opencv2/cudev/functional/functional.hpp
+24
-0
No files found.
modules/cudaarithm/src/cuda/polar_cart.cu
View file @
7c8c836a
This diff is collapsed.
Click to expand it.
modules/cudaarithm/src/element_operations.cpp
View file @
7c8c836a
...
...
@@ -493,110 +493,4 @@ void cv::cuda::magnitudeSqr(InputArray _src, OutputArray _dst, Stream& stream)
npp_magnitude
(
src
,
dst
,
nppiMagnitudeSqr_32fc32f_C1R
,
StreamAccessor
::
getStream
(
stream
));
}
////////////////////////////////////////////////////////////////////////
// Polar <-> Cart
namespace
cv
{
namespace
cuda
{
namespace
device
{
namespace
mathfunc
{
void
cartToPolar_gpu
(
PtrStepSzf
x
,
PtrStepSzf
y
,
PtrStepSzf
mag
,
bool
magSqr
,
PtrStepSzf
angle
,
bool
angleInDegrees
,
cudaStream_t
stream
);
void
polarToCart_gpu
(
PtrStepSzf
mag
,
PtrStepSzf
angle
,
PtrStepSzf
x
,
PtrStepSzf
y
,
bool
angleInDegrees
,
cudaStream_t
stream
);
}
}}}
namespace
{
void
cartToPolar_caller
(
const
GpuMat
&
x
,
const
GpuMat
&
y
,
GpuMat
*
mag
,
bool
magSqr
,
GpuMat
*
angle
,
bool
angleInDegrees
,
cudaStream_t
stream
)
{
using
namespace
::
cv
::
cuda
::
device
::
mathfunc
;
CV_Assert
(
x
.
size
()
==
y
.
size
()
&&
x
.
type
()
==
y
.
type
());
CV_Assert
(
x
.
depth
()
==
CV_32F
);
GpuMat
x1cn
=
x
.
reshape
(
1
);
GpuMat
y1cn
=
y
.
reshape
(
1
);
GpuMat
mag1cn
=
mag
?
mag
->
reshape
(
1
)
:
GpuMat
();
GpuMat
angle1cn
=
angle
?
angle
->
reshape
(
1
)
:
GpuMat
();
cartToPolar_gpu
(
x1cn
,
y1cn
,
mag1cn
,
magSqr
,
angle1cn
,
angleInDegrees
,
stream
);
}
void
polarToCart_caller
(
const
GpuMat
&
mag
,
const
GpuMat
&
angle
,
GpuMat
&
x
,
GpuMat
&
y
,
bool
angleInDegrees
,
cudaStream_t
stream
)
{
using
namespace
::
cv
::
cuda
::
device
::
mathfunc
;
CV_Assert
((
mag
.
empty
()
||
mag
.
size
()
==
angle
.
size
())
&&
mag
.
type
()
==
angle
.
type
());
CV_Assert
(
mag
.
depth
()
==
CV_32F
);
GpuMat
mag1cn
=
mag
.
reshape
(
1
);
GpuMat
angle1cn
=
angle
.
reshape
(
1
);
GpuMat
x1cn
=
x
.
reshape
(
1
);
GpuMat
y1cn
=
y
.
reshape
(
1
);
polarToCart_gpu
(
mag1cn
,
angle1cn
,
x1cn
,
y1cn
,
angleInDegrees
,
stream
);
}
}
void
cv
::
cuda
::
magnitude
(
InputArray
_x
,
InputArray
_y
,
OutputArray
_dst
,
Stream
&
stream
)
{
GpuMat
x
=
_x
.
getGpuMat
();
GpuMat
y
=
_y
.
getGpuMat
();
_dst
.
create
(
x
.
size
(),
CV_32FC1
);
GpuMat
dst
=
_dst
.
getGpuMat
();
cartToPolar_caller
(
x
,
y
,
&
dst
,
false
,
0
,
false
,
StreamAccessor
::
getStream
(
stream
));
}
void
cv
::
cuda
::
magnitudeSqr
(
InputArray
_x
,
InputArray
_y
,
OutputArray
_dst
,
Stream
&
stream
)
{
GpuMat
x
=
_x
.
getGpuMat
();
GpuMat
y
=
_y
.
getGpuMat
();
_dst
.
create
(
x
.
size
(),
CV_32FC1
);
GpuMat
dst
=
_dst
.
getGpuMat
();
cartToPolar_caller
(
x
,
y
,
&
dst
,
true
,
0
,
false
,
StreamAccessor
::
getStream
(
stream
));
}
void
cv
::
cuda
::
phase
(
InputArray
_x
,
InputArray
_y
,
OutputArray
_dst
,
bool
angleInDegrees
,
Stream
&
stream
)
{
GpuMat
x
=
_x
.
getGpuMat
();
GpuMat
y
=
_y
.
getGpuMat
();
_dst
.
create
(
x
.
size
(),
CV_32FC1
);
GpuMat
dst
=
_dst
.
getGpuMat
();
cartToPolar_caller
(
x
,
y
,
0
,
false
,
&
dst
,
angleInDegrees
,
StreamAccessor
::
getStream
(
stream
));
}
void
cv
::
cuda
::
cartToPolar
(
InputArray
_x
,
InputArray
_y
,
OutputArray
_mag
,
OutputArray
_angle
,
bool
angleInDegrees
,
Stream
&
stream
)
{
GpuMat
x
=
_x
.
getGpuMat
();
GpuMat
y
=
_y
.
getGpuMat
();
_mag
.
create
(
x
.
size
(),
CV_32FC1
);
GpuMat
mag
=
_mag
.
getGpuMat
();
_angle
.
create
(
x
.
size
(),
CV_32FC1
);
GpuMat
angle
=
_angle
.
getGpuMat
();
cartToPolar_caller
(
x
,
y
,
&
mag
,
false
,
&
angle
,
angleInDegrees
,
StreamAccessor
::
getStream
(
stream
));
}
void
cv
::
cuda
::
polarToCart
(
InputArray
_mag
,
InputArray
_angle
,
OutputArray
_x
,
OutputArray
_y
,
bool
angleInDegrees
,
Stream
&
stream
)
{
GpuMat
mag
=
_mag
.
getGpuMat
();
GpuMat
angle
=
_angle
.
getGpuMat
();
_x
.
create
(
mag
.
size
(),
CV_32FC1
);
GpuMat
x
=
_x
.
getGpuMat
();
_y
.
create
(
mag
.
size
(),
CV_32FC1
);
GpuMat
y
=
_y
.
getGpuMat
();
polarToCart_caller
(
mag
,
angle
,
x
,
y
,
angleInDegrees
,
StreamAccessor
::
getStream
(
stream
));
}
#endif
modules/cudev/include/opencv2/cudev/functional/functional.hpp
View file @
7c8c836a
...
...
@@ -616,6 +616,30 @@ template <typename T> struct magnitude_func : binary_function<T, T, typename fun
}
};
template
<
typename
T
>
struct
magnitude_sqr_func
:
binary_function
<
T
,
T
,
typename
functional_detail
::
FloatType
<
T
>::
type
>
{
__device__
__forceinline__
typename
functional_detail
::
FloatType
<
T
>::
type
operator
()(
typename
TypeTraits
<
T
>::
parameter_type
a
,
typename
TypeTraits
<
T
>::
parameter_type
b
)
const
{
return
a
*
a
+
b
*
b
;
}
};
template
<
typename
T
,
bool
angleInDegrees
>
struct
direction_func
:
binary_function
<
T
,
T
,
T
>
{
__device__
T
operator
()(
T
x
,
T
y
)
const
{
atan2_func
<
T
>
f
;
typename
atan2_func
<
T
>::
result_type
angle
=
f
(
y
,
x
);
angle
+=
(
angle
<
0
)
*
(
2.0
f
*
CV_PI_F
);
if
(
angleInDegrees
)
angle
*=
(
180.0
f
/
CV_PI_F
);
return
saturate_cast
<
T
>
(
angle
);
}
};
template
<
typename
T
>
struct
pow_func
:
binary_function
<
T
,
float
,
float
>
{
__device__
__forceinline__
float
operator
()(
T
val
,
float
power
)
const
...
...
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