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
47b572f9
Commit
47b572f9
authored
Jan 16, 2014
by
Elena Gvozdeva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
da4d33ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
58 deletions
+78
-58
templmatch.cpp
modules/imgproc/src/templmatch.cpp
+77
-57
test_match_template.cpp
modules/imgproc/test/ocl/test_match_template.cpp
+1
-1
No files found.
modules/imgproc/src/templmatch.cpp
View file @
47b572f9
...
@@ -45,17 +45,17 @@
...
@@ -45,17 +45,17 @@
//////////////////////////////////////////////////matchTemplate//////////////////////////////////////////////////////////
//////////////////////////////////////////////////matchTemplate//////////////////////////////////////////////////////////
namespace
cv
namespace
cv
{
{
static
bool
matchTemplate_CCORR
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
);
static
bool
matchTemplate_CCORR
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
);
static
bool
matchTemplate_CCORR_NORMED
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
);
static
bool
matchTemplate_CCORR_NORMED
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
);
static
bool
matchTemplate_SQDIFF
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
);
static
bool
matchTemplate_SQDIFF
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
);
static
bool
matchTemplate_SQDIFF_NORMED
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
);
static
bool
matchTemplate_SQDIFF_NORMED
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
);
static
bool
matchTemplate_CCOEFF
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
);
static
bool
matchTemplate_CCOEFF
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
);
static
bool
matchTemplate_CCOEFF_NORMED
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
);
static
bool
matchTemplate_CCOEFF_NORMED
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
);
static
bool
matchTemplateNaive_CCORR
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
,
int
cn
);
static
bool
matchTemplateNaive_CCORR
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
,
int
cn
);
static
bool
matchTemplateNaive_SQDIFF
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
,
int
cn
);
static
bool
matchTemplateNaive_SQDIFF
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
,
int
cn
);
static
bool
useNaive
(
int
method
,
int
depth
,
Size
size
)
static
bool
useNaive
(
int
method
,
int
depth
,
Size
size
)
{
{
...
@@ -76,39 +76,41 @@ namespace cv
...
@@ -76,39 +76,41 @@ namespace cv
///////////////////////////////////////////////////CCORR//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////CCORR//////////////////////////////////////////////////////////////
static
bool
matchTemplate_CCORR
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
)
static
bool
matchTemplate_CCORR
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
)
{
{
if
(
useNaive
(
TM_CCORR
,
image
.
depth
(),
templ
.
size
())
)
if
(
useNaive
(
TM_CCORR
,
_image
.
depth
(),
_
templ
.
size
())
)
return
matchTemplateNaive_CCORR
(
image
,
templ
,
result
,
image
.
channels
());
return
matchTemplateNaive_CCORR
(
_image
,
_templ
,
_result
,
_
image
.
channels
());
else
else
return
false
;
return
false
;
}
}
static
bool
matchTemplateNaive_CCORR
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
,
int
cn
)
static
bool
matchTemplateNaive_CCORR
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
,
int
cn
)
{
{
int
type
=
image
.
type
();
int
type
=
_
image
.
type
();
int
depth
=
CV_MAT_DEPTH
(
type
);
int
depth
=
CV_MAT_DEPTH
(
type
);
CV_Assert
(
result
.
channels
()
==
1
);
const
char
*
kernelName
=
"matchTemplate_Naive_CCORR"
;
const
char
*
kernelName
=
"matchTemplate_Naive_CCORR"
;
ocl
::
Kernel
k
(
kernelName
,
ocl
::
imgproc
::
match_template_oclsrc
,
format
(
"-D type=%s -D elem_type=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
ocl
::
Kernel
k
(
kernelName
,
ocl
::
imgproc
::
match_template_oclsrc
,
format
(
"-D type=%s -D elem_type=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
UMat
image
=
_image
.
getUMat
();
UMat
templ
=
_templ
.
getUMat
(),
result
;
_result
.
create
(
image
.
rows
-
templ
.
rows
+
1
,
image
.
cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
localsize
[
2
]
=
{
16
,
16
};
size_t
localsize
[
2
]
=
{
16
,
16
};
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image
),
ocl
::
KernelArg
::
ReadOnly
(
templ
),
ocl
::
KernelArg
::
WriteOnly
(
result
)).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image
),
ocl
::
KernelArg
::
ReadOnly
(
templ
),
ocl
::
KernelArg
::
WriteOnly
(
result
)).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
static
bool
matchTemplate_CCORR_NORMED
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
)
static
bool
matchTemplate_CCORR_NORMED
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
)
{
{
if
(
!
matchTemplate_CCORR
(
image
,
templ
,
result
))
matchTemplate
(
_image
,
_templ
,
_result
,
CV_TM_CCORR
);
return
false
;
int
type
=
image
.
type
();
int
type
=
_
image
.
type
();
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
const
char
*
kernelName
=
"matchTemplate_CCORR_NORMED"
;
const
char
*
kernelName
=
"matchTemplate_CCORR_NORMED"
;
...
@@ -117,6 +119,11 @@ namespace cv
...
@@ -117,6 +119,11 @@ namespace cv
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
UMat
image
=
_image
.
getUMat
();
UMat
templ
=
_templ
.
getUMat
(),
result
;
_result
.
create
(
image
.
rows
-
templ
.
rows
+
1
,
image
.
cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
UMat
temp
,
image_sums
,
image_sqsums
;
UMat
temp
,
image_sums
,
image_sqsums
;
integral
(
image
.
reshape
(
1
),
image_sums
,
temp
);
integral
(
image
.
reshape
(
1
),
image_sums
,
temp
);
...
@@ -134,46 +141,48 @@ namespace cv
...
@@ -134,46 +141,48 @@ namespace cv
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
localsize
[
2
]
=
{
16
,
16
};
size_t
localsize
[
2
]
=
{
16
,
16
};
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sqsum
).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sqsum
).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
//////////////////////////////////////SQDIFF//////////////////////////////////////////////////////////////
//////////////////////////////////////SQDIFF//////////////////////////////////////////////////////////////
static
bool
matchTemplate_SQDIFF
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
)
static
bool
matchTemplate_SQDIFF
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
)
{
{
if
(
useNaive
(
TM_SQDIFF
,
image
.
depth
(),
templ
.
size
()))
if
(
useNaive
(
TM_SQDIFF
,
_image
.
depth
(),
_
templ
.
size
()))
{
{
return
matchTemplateNaive_SQDIFF
(
image
,
templ
,
result
,
image
.
channels
());;
return
matchTemplateNaive_SQDIFF
(
_image
,
_templ
,
_result
,
_
image
.
channels
());;
}
}
else
else
return
false
;
return
false
;
}
}
static
bool
matchTemplateNaive_SQDIFF
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
,
int
cn
)
static
bool
matchTemplateNaive_SQDIFF
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
,
int
cn
)
{
{
int
type
=
image
.
type
();
int
type
=
_
image
.
type
();
int
depth
=
CV_MAT_DEPTH
(
type
);
int
depth
=
CV_MAT_DEPTH
(
type
);
CV_Assert
(
result
.
channels
()
==
1
);
const
char
*
kernelName
=
"matchTemplate_Naive_SQDIFF"
;
const
char
*
kernelName
=
"matchTemplate_Naive_SQDIFF"
;
ocl
::
Kernel
k
(
kernelName
,
ocl
::
imgproc
::
match_template_oclsrc
,
format
(
"-D type=%s -D elem_type=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
ocl
::
Kernel
k
(
kernelName
,
ocl
::
imgproc
::
match_template_oclsrc
,
format
(
"-D type=%s -D elem_type=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
UMat
image
=
_image
.
getUMat
();
UMat
templ
=
_templ
.
getUMat
(),
result
;
_result
.
create
(
image
.
rows
-
templ
.
rows
+
1
,
image
.
cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
localsize
[
2
]
=
{
16
,
16
};
size_t
localsize
[
2
]
=
{
16
,
16
};
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image
),
ocl
::
KernelArg
::
ReadOnly
(
templ
),
ocl
::
KernelArg
::
WriteOnly
(
result
)).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image
),
ocl
::
KernelArg
::
ReadOnly
(
templ
),
ocl
::
KernelArg
::
WriteOnly
(
result
)).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
static
bool
matchTemplate_SQDIFF_NORMED
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
)
static
bool
matchTemplate_SQDIFF_NORMED
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
)
{
{
if
(
!
matchTemplate_CCORR
(
image
,
templ
,
result
))
matchTemplate
(
_image
,
_templ
,
_result
,
CV_TM_CCORR
);
return
false
;
int
type
=
image
.
type
();
int
type
=
_
image
.
type
();
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
const
char
*
kernelName
=
"matchTemplate_SQDIFF_NORMED"
;
const
char
*
kernelName
=
"matchTemplate_SQDIFF_NORMED"
;
...
@@ -182,6 +191,11 @@ namespace cv
...
@@ -182,6 +191,11 @@ namespace cv
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
UMat
image
=
_image
.
getUMat
();
UMat
templ
=
_templ
.
getUMat
(),
result
;
_result
.
create
(
image
.
rows
-
templ
.
rows
+
1
,
image
.
cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
UMat
temp
,
image_sums
,
image_sqsums
;
UMat
temp
,
image_sums
,
image_sqsums
;
integral
(
image
.
reshape
(
1
),
image_sums
,
temp
);
integral
(
image
.
reshape
(
1
),
image_sums
,
temp
);
...
@@ -199,18 +213,17 @@ namespace cv
...
@@ -199,18 +213,17 @@ namespace cv
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
localsize
[
2
]
=
{
16
,
16
};
size_t
localsize
[
2
]
=
{
16
,
16
};
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sqsum
).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sqsum
).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
/////////////////////////////////////CCOEFF/////////////////////////////////////////////////////////////////
/////////////////////////////////////CCOEFF/////////////////////////////////////////////////////////////////
static
bool
matchTemplate_CCOEFF
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
)
static
bool
matchTemplate_CCOEFF
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
)
{
{
if
(
!
matchTemplate_CCORR
(
image
,
templ
,
result
))
matchTemplate
(
_image
,
_templ
,
_result
,
CV_TM_CCORR
);
return
false
;
UMat
image_sums
;
UMat
image_sums
;
integral
(
image
,
image_sums
);
integral
(
_
image
,
image_sums
);
int
type
=
image_sums
.
type
();
int
type
=
image_sums
.
type
();
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
...
@@ -228,13 +241,18 @@ namespace cv
...
@@ -228,13 +241,18 @@ namespace cv
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
UMat
templ
=
_templ
.
getUMat
(),
result
;
int
image_rows
=
_image
.
size
().
height
,
image_cols
=
_image
.
size
().
width
;
_result
.
create
(
image_rows
-
templ
.
rows
+
1
,
image_cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
size_t
localsize
[
2
]
=
{
16
,
16
};
size_t
localsize
[
2
]
=
{
16
,
16
};
if
(
cn
==
1
)
if
(
cn
==
1
)
{
{
float
templ_sum
=
(
float
)
sum
(
templ
)[
0
]
/
templ
.
size
().
area
();
float
templ_sum
=
(
float
)
sum
(
_templ
)[
0
]
/
_
templ
.
size
().
area
();
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
else
else
{
{
...
@@ -242,26 +260,26 @@ namespace cv
...
@@ -242,26 +260,26 @@ namespace cv
templ_sum
=
sum
(
templ
)
/
templ
.
size
().
area
();
templ_sum
=
sum
(
templ
)
/
templ
.
size
().
area
();
if
(
cn
==
2
)
if
(
cn
==
2
)
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
[
0
],
templ_sum
[
1
]).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
templ_sum
[
0
],
templ_sum
[
1
]).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sum
[
3
]).
run
(
2
,
globalsize
,
localsize
,
tru
e
);
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sum
[
3
]).
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
}
}
static
bool
matchTemplate_CCOEFF_NORMED
(
const
UMat
&
image
,
const
UMat
&
templ
,
UMat
&
result
)
static
bool
matchTemplate_CCOEFF_NORMED
(
InputArray
_image
,
InputArray
_templ
,
OutputArray
_
result
)
{
{
UMat
imagef
,
templf
;
UMat
imagef
,
templf
;
image
.
convertTo
(
imagef
,
CV_32F
);
templ
.
convertTo
(
templf
,
CV_32F
);
if
(
!
matchTemplate_CCORR
(
imagef
,
templf
,
result
))
_image
.
getUMat
().
convertTo
(
imagef
,
CV_32F
);
return
false
;
_templ
.
getUMat
().
convertTo
(
templf
,
CV_32F
);
matchTemplate
(
imagef
,
templf
,
_result
,
CV_TM_CCORR
);
const
char
*
kernelName
;
const
char
*
kernelName
;
UMat
temp
,
image_sums
,
image_sqsums
;
UMat
temp
,
image_sums
,
image_sqsums
;
integral
(
image
,
image_sums
,
temp
);
integral
(
_
image
,
image_sums
,
temp
);
int
type
=
image_sums
.
type
();
int
type
=
image_sums
.
type
();
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
int
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
...
@@ -278,6 +296,12 @@ namespace cv
...
@@ -278,6 +296,12 @@ namespace cv
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
UMat
image
=
_image
.
getUMat
();
UMat
templ
=
_templ
.
getUMat
(),
result
;
int
image_rows
=
_image
.
size
().
height
,
image_cols
=
_image
.
size
().
width
;
_result
.
create
(
image_rows
-
templ
.
rows
+
1
,
image_cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
if
(
temp
.
depth
()
==
CV_64F
)
if
(
temp
.
depth
()
==
CV_64F
)
temp
.
convertTo
(
image_sqsums
,
CV_32F
);
temp
.
convertTo
(
image_sqsums
,
CV_32F
);
else
else
...
@@ -306,7 +330,7 @@ namespace cv
...
@@ -306,7 +330,7 @@ namespace cv
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
,
templ_sqsum
)
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
,
templ_sqsum
)
.
run
(
2
,
globalsize
,
localsize
,
tru
e
);
.
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
else
else
{
{
...
@@ -336,12 +360,12 @@ namespace cv
...
@@ -336,12 +360,12 @@ namespace cv
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sqsum_sum
)
templ_sum
[
0
],
templ_sum
[
1
],
templ_sqsum_sum
)
.
run
(
2
,
globalsize
,
localsize
,
tru
e
);
.
run
(
2
,
globalsize
,
localsize
,
fals
e
);
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
return
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
ocl
::
KernelArg
::
WriteOnly
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sum
[
3
],
templ_sqsum_sum
)
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sum
[
3
],
templ_sqsum_sum
)
.
run
(
2
,
globalsize
,
localsize
,
tru
e
);
.
run
(
2
,
globalsize
,
localsize
,
fals
e
);
}
}
}
}
...
@@ -355,7 +379,7 @@ namespace cv
...
@@ -355,7 +379,7 @@ namespace cv
CV_Assert
(
cn
==
_templ
.
channels
()
&&
cn
!=
3
&&
cn
<=
4
);
CV_Assert
(
cn
==
_templ
.
channels
()
&&
cn
!=
3
&&
cn
<=
4
);
typedef
bool
(
*
Caller
)(
const
UMat
&
,
const
UMat
&
,
UMat
&
);
typedef
bool
(
*
Caller
)(
InputArray
_img
,
InputArray
_templ
,
OutputArray
_result
);
const
Caller
callers
[]
=
const
Caller
callers
[]
=
{
{
...
@@ -365,11 +389,7 @@ namespace cv
...
@@ -365,11 +389,7 @@ namespace cv
Caller
caller
=
callers
[
method
];
Caller
caller
=
callers
[
method
];
UMat
image
=
_img
.
getUMat
();
return
caller
(
_img
,
_templ
,
_result
);
UMat
templ
=
_templ
.
getUMat
(),
result
;
_result
.
create
(
image
.
rows
-
templ
.
rows
+
1
,
image
.
cols
-
templ
.
cols
+
1
,
CV_32F
);
result
=
_result
.
getUMat
();
return
caller
(
image
,
templ
,
result
);
}
}
}
}
...
...
modules/imgproc/test/ocl/test_match_template.cpp
View file @
47b572f9
...
@@ -74,7 +74,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool)
...
@@ -74,7 +74,7 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, int, bool)
virtual
void
generateTestData
()
virtual
void
generateTestData
()
{
{
Size
image_roiSize
=
randomSize
(
2
,
2
0
);
Size
image_roiSize
=
randomSize
(
2
,
10
0
);
Size
templ_roiSize
=
Size
(
randomInt
(
1
,
image_roiSize
.
width
),
randomInt
(
1
,
image_roiSize
.
height
));
Size
templ_roiSize
=
Size
(
randomInt
(
1
,
image_roiSize
.
width
),
randomInt
(
1
,
image_roiSize
.
height
));
Size
result_roiSize
=
Size
(
image_roiSize
.
width
-
templ_roiSize
.
width
+
1
,
Size
result_roiSize
=
Size
(
image_roiSize
.
width
-
templ_roiSize
.
width
+
1
,
image_roiSize
.
height
-
templ_roiSize
.
height
+
1
);
image_roiSize
.
height
-
templ_roiSize
.
height
+
1
);
...
...
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