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
fd152879
Commit
fd152879
authored
Apr 13, 2013
by
Peng Xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass query type T into kernel
parent
63813e83
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
14 deletions
+38
-14
brute_force_matcher.cpp
modules/ocl/src/brute_force_matcher.cpp
+28
-8
brute_force_match.cl
modules/ocl/src/opencl/brute_force_match.cl
+10
-6
No files found.
modules/ocl/src/brute_force_matcher.cpp
View file @
fd152879
...
@@ -64,6 +64,8 @@ namespace cv
...
@@ -64,6 +64,8 @@ namespace cv
static
const
int
OPT_SIZE
=
100
;
static
const
int
OPT_SIZE
=
100
;
static
const
char
*
T_ARR
[]
=
{
"uchar"
,
"char"
,
"ushort"
,
"short"
,
"int"
,
"float"
,
"double"
};
template
<
int
BLOCK_SIZE
,
int
MAX_DESC_LEN
/*, typename Mask*/
>
template
<
int
BLOCK_SIZE
,
int
MAX_DESC_LEN
/*, typename Mask*/
>
void
matchUnrolledCached
(
const
oclMat
&
query
,
const
oclMat
&
train
,
const
oclMat
&
/*mask*/
,
void
matchUnrolledCached
(
const
oclMat
&
query
,
const
oclMat
&
train
,
const
oclMat
&
/*mask*/
,
const
oclMat
&
trainIdx
,
const
oclMat
&
distance
,
int
distType
)
const
oclMat
&
trainIdx
,
const
oclMat
&
distance
,
int
distType
)
...
@@ -78,7 +80,9 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat
...
@@ -78,7 +80,9 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, const oclMat
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
distType
,
block_size
,
m_size
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
,
m_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
...
@@ -119,7 +123,9 @@ void match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
...
@@ -119,7 +123,9 @@ void match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
distType
,
block_size
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
...
@@ -162,7 +168,9 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist
...
@@ -162,7 +168,9 @@ void matchUnrolledCached(const oclMat &query, const oclMat &train, float maxDist
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
distType
,
block_size
,
m_size
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
,
m_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
...
@@ -202,7 +210,9 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c
...
@@ -202,7 +210,9 @@ void radius_match(const oclMat &query, const oclMat &train, float maxDistance, c
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
distType
,
block_size
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
...
@@ -300,7 +310,9 @@ void knn_matchUnrolledCached(const oclMat &query, const oclMat &train, const ocl
...
@@ -300,7 +310,9 @@ void knn_matchUnrolledCached(const oclMat &query, const oclMat &train, const ocl
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
distType
,
block_size
,
m_size
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
,
m_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
...
@@ -334,7 +346,9 @@ void knn_match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
...
@@ -334,7 +346,9 @@ void knn_match(const oclMat &query, const oclMat &train, const oclMat &/*mask*/,
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
distType
,
block_size
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
...
@@ -368,7 +382,10 @@ void calcDistanceUnrolled(const oclMat &query, const oclMat &train, const oclMat
...
@@ -368,7 +382,10 @@ void calcDistanceUnrolled(const oclMat &query, const oclMat &train, const oclMat
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d"
,
distType
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d -D MAX_DESC_LEN=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
,
m_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
query
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
query
.
data
));
...
@@ -401,7 +418,10 @@ void calcDistance(const oclMat &query, const oclMat &train, const oclMat &/*mask
...
@@ -401,7 +418,10 @@ void calcDistance(const oclMat &query, const oclMat &train, const oclMat &/*mask
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
char
opt
[
OPT_SIZE
]
=
""
;
char
opt
[
OPT_SIZE
]
=
""
;
sprintf
(
opt
,
"-D DIST_TYPE=%d"
,
distType
);
sprintf
(
opt
,
"-D T=%s -D DIST_TYPE=%d -D BLOCK_SIZE=%d"
,
T_ARR
[
query
.
depth
()],
distType
,
block_size
);
if
(
globalSize
[
0
]
!=
0
)
if
(
globalSize
[
0
]
!=
0
)
{
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
query
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
),
(
void
*
)
&
query
.
data
));
...
...
modules/ocl/src/opencl/brute_force_match.cl
View file @
fd152879
...
@@ -47,6 +47,10 @@
...
@@ -47,6 +47,10 @@
#
pragma
OPENCL
EXTENSION
cl_khr_global_int32_base_atomics:enable
#
pragma
OPENCL
EXTENSION
cl_khr_global_int32_base_atomics:enable
#
define
MAX_FLOAT
3.40282e+038f
#
define
MAX_FLOAT
3.40282e+038f
#
ifndef
T
#
define
T
float
#
endif
#
ifndef
BLOCK_SIZE
#
ifndef
BLOCK_SIZE
#
define
BLOCK_SIZE
16
#
define
BLOCK_SIZE
16
#
endif
#
endif
...
@@ -54,7 +58,11 @@
...
@@ -54,7 +58,11 @@
#
define
MAX_DESC_LEN
64
#
define
MAX_DESC_LEN
64
#
endif
#
endif
int
bit1Count
(
float
x
)
#
ifndef
DIST_TYPE
#
define
DIST_TYPE
0
#
endif
int
bit1Count
(
int
x
)
{
{
int
c
=
0
;
int
c
=
0
;
int
ix
=
(
int
)
x
;
int
ix
=
(
int
)
x
;
...
@@ -63,13 +71,9 @@ int bit1Count(float x)
...
@@ -63,13 +71,9 @@ int bit1Count(float x)
c
+=
ix
&
0x1
;
c
+=
ix
&
0x1
;
ix
>>=
1
;
ix
>>=
1
;
}
}
return
(
float
)
c
;
return
c
;
}
}
#
ifndef
DIST_TYPE
#
define
DIST_TYPE
0
#
endif
#
if
(
DIST_TYPE
==
0
)
#
if
(
DIST_TYPE
==
0
)
#
define
DIST
(
x,
y
)
fabs
((
x
)
-
(
y
))
#
define
DIST
(
x,
y
)
fabs
((
x
)
-
(
y
))
#
elif
(
DIST_TYPE
==
1
)
#
elif
(
DIST_TYPE
==
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