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
43c29a67
Commit
43c29a67
authored
Apr 09, 2014
by
Elena Gvozdeva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
6119ae0e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
26 deletions
+51
-26
templmatch.cpp
modules/imgproc/src/templmatch.cpp
+51
-26
No files found.
modules/imgproc/src/templmatch.cpp
View file @
43c29a67
...
...
@@ -341,14 +341,13 @@ static bool ocl_matchTemplate( InputArray _img, InputArray _templ, OutputArray _
#endif
#if defined (HAVE_IPP)
#if defined (HAVE_IPP)
&& (IPP_VERSION_MAJOR >= 7)
typedef
IppStatus
(
CV_STDCALL
*
ippiGetBufferSize
)(
IppiSize
,
IppiSize
,
IppEnum
,
int
*
);
typedef
IppStatus
(
CV_STDCALL
*
ippimatchTemplate
)(
const
void
*
,
int
,
IppiSize
,
const
void
*
,
int
,
IppiSize
,
Ipp32f
*
,
int
,
IppEnum
,
Ipp8u
*
);
static
bool
ipp_
matchTemplate
(
const
Mat
&
src
,
const
Mat
&
tpl
,
Mat
&
dst
,
int
method
)
static
bool
ipp_
crossCorr
(
const
Mat
&
src
,
const
Mat
&
tpl
,
Mat
&
dst
)
{
if
(
src
.
channels
()
!=
1
||
(
method
!=
CV_TM_SQDIFF
&&
method
!=
CV_TM_CCORR
)
)
if
(
src
.
channels
()
!=
1
)
return
false
;
IppStatus
status
;
...
...
@@ -356,36 +355,57 @@ static bool ipp_matchTemplate(const Mat& src, const Mat& tpl, Mat& dst, int meth
IppiSize
srcRoiSize
=
{
src
.
cols
,
src
.
rows
};
IppiSize
tplRoiSize
=
{
tpl
.
cols
,
tpl
.
rows
};
IppEnum
funCfg
;
ippimatchTemplate
ippFunc
;
ippiGetBufferSize
ippGetBufSize
;
Ipp8u
*
pBuffer
;
int
bufSize
=
0
;
int
depth
=
src
.
depth
();
if
(
method
==
CV_TM_SQDIFF
)
{
ippFunc
=
depth
==
CV_8U
?
(
ippimatchTemplate
)
ippiSqrDistanceNorm_8u32f_C1R
:
depth
==
CV_32F
?
(
ippimatchTemplate
)
ippiSqrDistanceNorm_32f_C1R
:
0
;
ippGetBufSize
=
(
ippiGetBufferSize
)
ippiSqrDistanceNormGetBufferSize
;
}
else
{
ippFunc
=
ippimatchTemplate
ippFunc
=
depth
==
CV_8U
?
(
ippimatchTemplate
)
ippiCrossCorrNorm_8u32f_C1R
:
depth
==
CV_32F
?
(
ippimatchTemplate
)
ippiCrossCorrNorm_32f_C1R
:
0
;
ippGetBufSize
=
(
ippiGetBufferSize
)
ippiCrossCorrNormGetBufferSize
;
}
if
(
ippFunc
==
0
)
return
false
;
funCfg
=
(
IppEnum
)(
ippAlgAuto
|
ippiNormNone
|
ippiROIValid
);
IppEnum
funCfg
=
(
IppEnum
)(
ippAlgAuto
|
ippiNormNone
|
ippiROIValid
);
status
=
ippiCrossCorrNormGetBufferSize
(
srcRoiSize
,
tplRoiSize
,
funCfg
,
&
bufSize
);
if
(
status
<
0
)
return
false
;
pBuffer
=
ippsMalloc_8u
(
bufSize
);
status
=
ippFunc
(
src
.
data
,
(
int
)
src
.
step
,
srcRoiSize
,
tpl
.
data
,
(
int
)
tpl
.
step
,
tplRoiSize
,
(
Ipp32f
*
)
dst
.
data
,
(
int
)
dst
.
step
,
funCfg
,
pBuffer
);
ippsFree
(
pBuffer
);
return
status
>=
0
;
}
static
bool
ipp_sqrDistance
(
const
Mat
&
src
,
const
Mat
&
tpl
,
Mat
&
dst
)
{
if
(
src
.
channels
()
!=
1
)
return
false
;
IppStatus
status
;
IppiSize
srcRoiSize
=
{
src
.
cols
,
src
.
rows
};
IppiSize
tplRoiSize
=
{
tpl
.
cols
,
tpl
.
rows
};
Ipp8u
*
pBuffer
;
int
bufSize
=
0
;
int
depth
=
src
.
depth
();
ippimatchTemplate
ippFunc
=
depth
==
CV_8U
?
(
ippimatchTemplate
)
ippiSqrDistanceNorm_8u32f_C1R
:
depth
==
CV_32F
?
(
ippimatchTemplate
)
ippiSqrDistanceNorm_32f_C1R
:
0
;
if
(
ippFunc
==
0
)
return
false
;
IppEnum
funCfg
=
(
IppEnum
)(
ippAlgAuto
|
ippiNormNone
|
ippiROIValid
);
status
=
ipp
GetBuf
Size
(
srcRoiSize
,
tplRoiSize
,
funCfg
,
&
bufSize
);
status
=
ipp
iSqrDistanceNormGetBuffer
Size
(
srcRoiSize
,
tplRoiSize
,
funCfg
,
&
bufSize
);
if
(
status
<
0
)
return
false
;
...
...
@@ -403,6 +423,11 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
Size
corrsize
,
int
ctype
,
Point
anchor
,
double
delta
,
int
borderType
)
{
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if
(
ipp_crossCorr
(
img
,
_templ
,
corr
))
return
;
#endif
const
double
blockScale
=
4.5
;
const
int
minBlockSize
=
256
;
std
::
vector
<
uchar
>
buf
;
...
...
@@ -613,13 +638,13 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
_result
.
create
(
corrSize
,
CV_32F
);
Mat
result
=
_result
.
getMat
();
#if
defined (HAVE_IPP)
if
(
ipp_
matchTemplate
(
img
,
templ
,
result
,
method
))
#if
def HAVE_TEGRA_OPTIMIZATION
if
(
tegra
::
matchTemplate
(
img
,
templ
,
result
,
method
))
return
;
#endif
#if
def HAVE_TEGRA_OPTIMIZATION
if
(
tegra
::
matchTemplate
(
img
,
templ
,
result
,
method
))
#if
defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if
(
method
==
CV_TM_SQDIFF
&&
ipp_sqrDistance
(
img
,
templ
,
result
))
return
;
#endif
...
...
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