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
a7036d96
Commit
a7036d96
authored
May 21, 2014
by
Elena Gvozdeva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed support for 3-channels, changed CCOEFF
parent
04628d77
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
34 deletions
+8
-34
match_template.cl
modules/imgproc/src/opencl/match_template.cl
+0
-0
templmatch.cpp
modules/imgproc/src/templmatch.cpp
+8
-34
No files found.
modules/imgproc/src/opencl/match_template.cl
View file @
a7036d96
This diff is collapsed.
Click to expand it.
modules/imgproc/src/templmatch.cpp
View file @
a7036d96
...
...
@@ -202,47 +202,31 @@ static bool matchTemplate_CCOEFF(InputArray _image, InputArray _templ, OutputArr
matchTemplate
(
_image
,
_templ
,
_result
,
CV_TM_CCORR
);
UMat
image_sums
,
temp
;
integral
(
_image
,
temp
);
if
(
temp
.
depth
()
==
CV_64F
)
temp
.
convertTo
(
image_sums
,
CV_32F
);
else
image_sums
=
temp
;
integral
(
_image
,
image_sums
,
CV_32F
);
int
type
=
image_sums
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
ocl
::
Kernel
k
(
"matchTemplate_Prepared_CCOEFF"
,
ocl
::
imgproc
::
match_template_oclsrc
,
format
(
"-D CCOEFF -D T=%s -D
elem_type
=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
format
(
"-D CCOEFF -D T=%s -D
T1
=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
if
(
k
.
empty
())
return
false
;
UMat
templ
=
_templ
.
getUMat
();
Size
size
=
_image
.
size
(),
tsize
=
templ
.
size
();
_result
.
create
(
size
.
height
-
templ
.
rows
+
1
,
size
.
width
-
templ
.
cols
+
1
,
CV_32F
);
UMat
result
=
_result
.
getUMat
();
Size
tsize
=
templ
.
size
();
if
(
cn
==
1
)
if
(
cn
==
1
)
{
float
templ_sum
=
static_cast
<
float
>
(
sum
(
_templ
)[
0
])
/
tsize
.
area
();
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
);
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
);
}
else
{
Vec4f
templ_sum
=
Vec4f
::
all
(
0
);
templ_sum
=
sum
(
templ
)
/
tsize
.
area
();
if
(
cn
==
2
)
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
[
0
],
templ_sum
[
1
]);
else
if
(
cn
==
3
)
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
]);
else
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sum
[
3
]);
}
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
);
}
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
return
k
.
run
(
2
,
globalsize
,
NULL
,
false
);
...
...
@@ -258,7 +242,7 @@ static bool matchTemplate_CCOEFF_NORMED(InputArray _image, InputArray _templ, Ou
int
type
=
image_sums
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
ocl
::
Kernel
k
(
"matchTemplate_CCOEFF_NORMED"
,
ocl
::
imgproc
::
match_template_oclsrc
,
format
(
"-D CCOEFF_NORMED -D
type=%s -D elem_type
=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
format
(
"-D CCOEFF_NORMED -D
T=%s -D T1
=%s -D cn=%d"
,
ocl
::
typeToStr
(
type
),
ocl
::
typeToStr
(
depth
),
cn
));
if
(
k
.
empty
())
return
false
;
...
...
@@ -308,19 +292,9 @@ static bool matchTemplate_CCOEFF_NORMED(InputArray _image, InputArray _templ, Ou
return
true
;
}
if
(
cn
==
2
)
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sqsum_sum
);
else
if
(
cn
==
3
)
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sqsum_sum
);
else
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sqsums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
scale
,
templ_sum
[
0
],
templ_sum
[
1
],
templ_sum
[
2
],
templ_sum
[
3
],
templ_sqsum_sum
);
}
templ_sum
,
templ_sqsum_sum
);
}
size_t
globalsize
[
2
]
=
{
result
.
cols
,
result
.
rows
};
return
k
.
run
(
2
,
globalsize
,
NULL
,
false
);
...
...
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