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
2e3f4fda
Commit
2e3f4fda
authored
Feb 22, 2013
by
yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pyrLK's mismatch on Linux
parent
6ebb0e2a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
0 deletions
+101
-0
mcwutil.cpp
modules/ocl/src/mcwutil.cpp
+95
-0
mcwutil.hpp
modules/ocl/src/mcwutil.hpp
+6
-0
pyrlk.cpp
modules/ocl/src/pyrlk.cpp
+0
-0
No files found.
modules/ocl/src/mcwutil.cpp
View file @
2e3f4fda
...
...
@@ -123,6 +123,101 @@ namespace cv
openCLExecuteKernel_2
(
clCxt
,
source
,
kernelName
,
globalThreads
,
localThreads
,
args
,
channels
,
depth
,
build_options
,
finish_mode
);
}
cl_mem
bindTexture
(
const
oclMat
&
mat
)
{
cl_mem
texture
;
cl_image_format
format
;
int
err
;
int
depth
=
mat
.
depth
();
int
channels
=
mat
.
channels
();
switch
(
depth
)
{
case
CV_8U
:
format
.
image_channel_data_type
=
CL_UNSIGNED_INT8
;
break
;
case
CV_32S
:
format
.
image_channel_data_type
=
CL_UNSIGNED_INT32
;
break
;
case
CV_32F
:
format
.
image_channel_data_type
=
CL_FLOAT
;
break
;
default
:
throw
std
::
exception
();
break
;
}
switch
(
channels
)
{
case
1
:
format
.
image_channel_order
=
CL_R
;
break
;
case
3
:
format
.
image_channel_order
=
CL_RGB
;
break
;
case
4
:
format
.
image_channel_order
=
CL_RGBA
;
break
;
default
:
throw
std
::
exception
();
break
;
}
#if CL_VERSION_1_2
cl_image_desc
desc
;
desc
.
image_type
=
CL_MEM_OBJECT_IMAGE2D
;
desc
.
image_width
=
mat
.
cols
;
desc
.
image_height
=
mat
.
rows
;
desc
.
image_depth
=
0
;
desc
.
image_array_size
=
1
;
desc
.
image_row_pitch
=
0
;
desc
.
image_slice_pitch
=
0
;
desc
.
buffer
=
NULL
;
desc
.
num_mip_levels
=
0
;
desc
.
num_samples
=
0
;
texture
=
clCreateImage
(
mat
.
clCxt
->
impl
->
clContext
,
CL_MEM_READ_WRITE
,
&
format
,
&
desc
,
NULL
,
&
err
);
#else
texture
=
clCreateImage2D
(
mat
.
clCxt
->
impl
->
clContext
,
CL_MEM_READ_WRITE
,
&
format
,
mat
.
cols
,
mat
.
rows
,
0
,
NULL
,
&
err
);
#endif
size_t
origin
[]
=
{
0
,
0
,
0
};
size_t
region
[]
=
{
mat
.
cols
,
mat
.
rows
,
1
};
cl_mem
devData
;
if
(
mat
.
cols
*
mat
.
elemSize
()
!=
mat
.
step
)
{
devData
=
clCreateBuffer
(
mat
.
clCxt
->
impl
->
clContext
,
CL_MEM_READ_ONLY
,
mat
.
cols
*
mat
.
rows
*
mat
.
elemSize
(),
NULL
,
NULL
);
const
size_t
regin
[
3
]
=
{
mat
.
cols
*
mat
.
elemSize
(),
mat
.
rows
,
1
};
clEnqueueCopyBufferRect
(
mat
.
clCxt
->
impl
->
clCmdQueue
,
(
cl_mem
)
mat
.
data
,
devData
,
origin
,
origin
,
regin
,
mat
.
step
,
0
,
mat
.
cols
*
mat
.
elemSize
(),
0
,
0
,
NULL
,
NULL
);
}
else
{
devData
=
(
cl_mem
)
mat
.
data
;
}
clEnqueueCopyBufferToImage
(
mat
.
clCxt
->
impl
->
clCmdQueue
,
devData
,
texture
,
0
,
origin
,
region
,
0
,
NULL
,
0
);
if
((
mat
.
cols
*
mat
.
elemSize
()
!=
mat
.
step
))
{
clFinish
(
mat
.
clCxt
->
impl
->
clCmdQueue
);
clReleaseMemObject
(
devData
);
}
openCLSafeCall
(
err
);
return
texture
;
}
void
releaseTexture
(
cl_mem
&
texture
)
{
openCLFree
(
texture
);
}
}
//namespace ocl
}
//namespace cv
...
...
modules/ocl/src/mcwutil.hpp
View file @
2e3f4fda
...
...
@@ -67,6 +67,12 @@ namespace cv
void
openCLExecuteKernel2
(
Context
*
clCxt
,
const
char
**
source
,
string
kernelName
,
size_t
globalThreads
[
3
],
size_t
localThreads
[
3
],
vector
<
pair
<
size_t
,
const
void
*>
>
&
args
,
int
channels
,
int
depth
,
char
*
build_options
,
FLUSH_MODE
finish_mode
=
DISABLE
);
// bind oclMat to OpenCL image textures
// note:
// 1. there is no memory management. User need to explicitly release the resource
// 2. for faster clamping, there is no buffer padding for the constructed texture
cl_mem
bindTexture
(
const
oclMat
&
mat
);
void
releaseTexture
(
cl_mem
&
texture
);
}
//namespace ocl
}
//namespace cv
...
...
modules/ocl/src/pyrlk.cpp
View file @
2e3f4fda
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