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
1291bd1c
Commit
1291bd1c
authored
Mar 06, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ported fast calculation of covar data
parent
0692a674
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
20 deletions
+71
-20
corner.cpp
modules/imgproc/src/corner.cpp
+71
-20
covardata.cl
modules/imgproc/src/opencl/covardata.cl
+0
-0
No files found.
modules/imgproc/src/corner.cpp
View file @
1291bd1c
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
#define CV_OPENCL_RUN_ASSERT
#include "opencl_kernels.hpp"
#include "opencl_kernels.hpp"
namespace
cv
namespace
cv
...
@@ -304,6 +305,70 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
...
@@ -304,6 +305,70 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
#ifdef HAVE_OPENCL
#ifdef HAVE_OPENCL
static
bool
extractCovData
(
InputArray
_src
,
UMat
&
Dx
,
UMat
&
Dy
,
int
depth
,
int
block_size
,
int
aperture_size
,
int
borderType
,
const
char
*
const
borderTypeStr
)
{
float
scale
=
(
float
)(
1
<<
((
aperture_size
>
0
?
aperture_size
:
3
)
-
1
))
*
block_size
;
if
(
aperture_size
<
0
)
scale
*=
2.0
f
;
if
(
depth
==
CV_8U
)
scale
*=
255.0
f
;
scale
=
1.0
f
/
scale
;
UMat
src
=
_src
.
getUMat
();
Size
wholeSize
;
Point
ofs
;
src
.
locateROI
(
wholeSize
,
ofs
);
const
int
sobel_lsz
=
16
;
if
((
aperture_size
==
3
||
aperture_size
==
5
||
aperture_size
==
7
||
aperture_size
==
-
1
)
&&
wholeSize
.
height
>
sobel_lsz
+
(
aperture_size
>>
1
)
&&
wholeSize
.
width
>
sobel_lsz
+
(
aperture_size
>>
1
))
{
CV_Assert
(
depth
==
CV_8U
||
depth
==
CV_32F
);
Dx
.
create
(
src
.
size
(),
CV_32FC1
);
Dy
.
create
(
src
.
size
(),
CV_32FC1
);
size_t
localsize
[
2
]
=
{
sobel_lsz
,
sobel_lsz
};
size_t
globalsize
[
2
]
=
{
localsize
[
0
]
*
(
1
+
(
src
.
cols
-
1
)
/
localsize
[
0
]),
localsize
[
1
]
*
(
1
+
(
src
.
rows
-
1
)
/
localsize
[
1
])
};
int
src_offset_x
=
(
src
.
offset
%
src
.
step
)
/
src
.
elemSize
();
int
src_offset_y
=
src
.
offset
/
src
.
step
;
ocl
::
Kernel
k
(
format
(
"sobel%d"
,
aperture_size
).
c_str
(),
ocl
::
imgproc
::
covardata_oclsrc
,
cv
::
format
(
"-D BLK_X=%d -D BLK_Y=%d -D %s -D SRCTYPE=%s%s"
,
(
int
)
localsize
[
0
],
(
int
)
localsize
[
1
],
borderTypeStr
,
ocl
::
typeToStr
(
depth
),
aperture_size
<
0
?
" -D SCHARR"
:
""
));
if
(
k
.
empty
())
return
false
;
k
.
args
(
ocl
::
KernelArg
::
PtrReadOnly
(
src
),
(
int
)
src
.
step
,
src_offset_x
,
src_offset_y
,
ocl
::
KernelArg
::
WriteOnlyNoSize
(
Dx
),
ocl
::
KernelArg
::
WriteOnly
(
Dy
),
wholeSize
.
height
,
wholeSize
.
width
,
scale
);
return
k
.
run
(
2
,
globalsize
,
localsize
,
NULL
);
}
else
{
if
(
aperture_size
>
0
)
{
Sobel
(
_src
,
Dx
,
CV_32F
,
1
,
0
,
aperture_size
,
scale
,
0
,
borderType
);
Sobel
(
_src
,
Dy
,
CV_32F
,
0
,
1
,
aperture_size
,
scale
,
0
,
borderType
);
}
else
{
Scharr
(
_src
,
Dx
,
CV_32F
,
1
,
0
,
scale
,
0
,
borderType
);
Scharr
(
_src
,
Dy
,
CV_32F
,
0
,
1
,
scale
,
0
,
borderType
);
}
}
return
true
;
}
static
bool
ocl_cornerMinEigenValVecs
(
InputArray
_src
,
OutputArray
_dst
,
int
block_size
,
static
bool
ocl_cornerMinEigenValVecs
(
InputArray
_src
,
OutputArray
_dst
,
int
block_size
,
int
aperture_size
,
double
k
,
int
borderType
,
int
op_type
)
int
aperture_size
,
double
k
,
int
borderType
,
int
op_type
)
{
{
...
@@ -314,32 +379,18 @@ static bool ocl_cornerMinEigenValVecs(InputArray _src, OutputArray _dst, int blo
...
@@ -314,32 +379,18 @@ static bool ocl_cornerMinEigenValVecs(InputArray _src, OutputArray _dst, int blo
return
false
;
return
false
;
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
);
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
);
double
scale
=
(
double
)(
1
<<
((
aperture_size
>
0
?
aperture_size
:
3
)
-
1
))
*
block_size
;
if
(
aperture_size
<
0
)
scale
*=
2.0
;
if
(
depth
==
CV_8U
)
scale
*=
255.0
;
scale
=
1.0
/
scale
;
if
(
!
(
type
==
CV_8UC1
||
type
==
CV_32FC1
)
)
if
(
!
(
type
==
CV_8UC1
||
type
==
CV_32FC1
)
)
return
false
;
return
false
;
UMat
Dx
,
Dy
;
if
(
aperture_size
>
0
)
{
Sobel
(
_src
,
Dx
,
CV_32F
,
1
,
0
,
aperture_size
,
scale
,
0
,
borderType
);
Sobel
(
_src
,
Dy
,
CV_32F
,
0
,
1
,
aperture_size
,
scale
,
0
,
borderType
);
}
else
{
Scharr
(
_src
,
Dx
,
CV_32F
,
1
,
0
,
scale
,
0
,
borderType
);
Scharr
(
_src
,
Dy
,
CV_32F
,
0
,
1
,
scale
,
0
,
borderType
);
}
const
char
*
const
borderTypes
[]
=
{
"BORDER_CONSTANT"
,
"BORDER_REPLICATE"
,
"BORDER_REFLECT"
,
const
char
*
const
borderTypes
[]
=
{
"BORDER_CONSTANT"
,
"BORDER_REPLICATE"
,
"BORDER_REFLECT"
,
0
,
"BORDER_REFLECT101"
};
"BORDER_WRAP"
,
"BORDER_REFLECT101"
};
const
char
*
const
cornerType
[]
=
{
"CORNER_MINEIGENVAL"
,
"CORNER_HARRIS"
,
0
};
const
char
*
const
cornerType
[]
=
{
"CORNER_MINEIGENVAL"
,
"CORNER_HARRIS"
,
0
};
UMat
Dx
,
Dy
;
if
(
!
extractCovData
(
_src
,
Dx
,
Dy
,
depth
,
block_size
,
aperture_size
,
borderType
,
borderTypes
[
borderType
]))
return
false
;
ocl
::
Kernel
cornelKernel
(
"corner"
,
ocl
::
imgproc
::
corner_oclsrc
,
ocl
::
Kernel
cornelKernel
(
"corner"
,
ocl
::
imgproc
::
corner_oclsrc
,
format
(
"-D anX=%d -D anY=%d -D ksX=%d -D ksY=%d -D %s -D %s"
,
format
(
"-D anX=%d -D anY=%d -D ksX=%d -D ksY=%d -D %s -D %s"
,
block_size
/
2
,
block_size
/
2
,
block_size
,
block_size
,
block_size
/
2
,
block_size
/
2
,
block_size
,
block_size
,
...
...
modules/imgproc/src/opencl/covardata.cl
0 → 100644
View file @
1291bd1c
This diff is collapsed.
Click to expand it.
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