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
bbb2d27a
Commit
bbb2d27a
authored
Oct 25, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74 from taka-no-me/cl2cpp
parents
42414b56
63397e82
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
125 deletions
+51
-125
CMakeLists.txt
modules/ocl/CMakeLists.txt
+12
-24
cl2cpp.cmake
modules/ocl/cl2cpp.cmake
+35
-0
cl2cpp.js
modules/ocl/cl2cpp.js
+0
-40
cl2cpp.py
modules/ocl/cl2cpp.py
+0
-55
precomp.hpp
modules/ocl/src/precomp.hpp
+4
-6
No files found.
modules/ocl/CMakeLists.txt
View file @
bbb2d27a
...
...
@@ -4,26 +4,18 @@ if(NOT HAVE_OPENCL)
endif
()
set
(
the_description
"OpenCL-accelerated Computer Vision"
)
ocv_add_module
(
ocl opencv_core opencv_imgproc opencv_
calib3d opencv_objdetect opencv_video opencv_nonfree opencv_ts
)
ocv_add_module
(
ocl opencv_core opencv_imgproc opencv_
features2d opencv_objdetect opencv_video
)
ocv_module_include_directories
()
file
(
GLOB CL_FILES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/kernels/*.cl"
)
set
(
kernels_cpp
"
${
CMAKE_CURRENT_BINARY_DIR
}
/kernels.cpp"
)
set
(
cl2cpp_script
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cl2cpp.py"
)
set
(
cl2cpp_script_W32
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cl2cpp.js"
)
set
(
cl2cpp_script
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cl2cpp.cmake"
)
IF
(
0
)
add_custom_command
(
OUTPUT
${
kernels_cpp
}
COMMAND wscript.exe
${
cl2cpp_script_W32
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/kernels"
${
kernels_cpp
}
DEPENDS
${
CL_FILES
}
${
cl2cpp_script_W32
}
)
else
()
add_custom_command
(
OUTPUT
${
kernels_cpp
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
cl2cpp_script
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/kernels"
${
kernels_cpp
}
DEPENDS
${
CL_FILES
}
${
cl2cpp_script
}
)
ENDIF
()
add_custom_command
(
OUTPUT
${
kernels_cpp
}
COMMAND
${
CMAKE_COMMAND
}
-DCL_DIR=
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/kernels"
-DOUTPUT=
"
${
kernels_cpp
}
"
-P
${
cl2cpp_script
}
DEPENDS
${
CL_FILES
}
${
cl2cpp_script
}
)
file
(
GLOB lib_hdrs
"include/opencv2/
${
name
}
/*.hpp"
"include/opencv2/
${
name
}
/*.h"
)
file
(
GLOB lib_srcs
"src/*.cpp"
)
...
...
@@ -35,7 +27,7 @@ source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs} ${kernels_cpp})
if
(
HAVE_OPENCL
)
set
(
ocl_link_libs
${
OPENCL_LIBRARIES
}
)
if
(
OPENCL_INCLUDE_DIR
)
ocv_include_directories
(
${
OPENCL_INCLUDE_DIR
}
)
ocv_include_directories
(
${
OPENCL_INCLUDE_DIR
}
)
endif
()
if
(
HAVE_CLAMDFFT
)
set
(
ocl_link_libs
${
ocl_link_libs
}
${
CLAMDFFT_LIBRARIES
}
)
...
...
@@ -47,17 +39,12 @@ if (HAVE_OPENCL)
endif
()
endif
()
ocv_set_module_sources
(
HEADERS
${
lib_hdrs
}
SOURCES
${
lib_int_hdrs
}
${
lib_srcs
}
)
set
(
OPENCV_MODULE_opencv_ocl_SOURCES
${
OPENCV_MODULE_opencv_ocl_SOURCES
}
${
kernels_cpp
}
)
ocv_set_module_sources
(
HEADERS
${
lib_hdrs
}
SOURCES
${
lib_int_hdrs
}
${
lib_srcs
}
${
kernels_cpp
}
)
ocv_create_module
(
${
ocl_link_libs
}
)
install
(
FILES
${
lib_hdrs
}
DESTINATION include/opencv2/
${
name
}
COMPONENT main
)
DESTINATION include/opencv2/
${
name
}
COMPONENT main
)
ocv_add_precompiled_headers
(
${
the_module
}
)
...
...
@@ -69,6 +56,7 @@ file(GLOB test_hdrs "test/*.hpp" "test/*.h")
ocv_add_accuracy_tests
(
FILES
"Include"
${
test_hdrs
}
FILES
"Src"
${
test_srcs
}
)
################################################################################################################
################################ OpenCL Module Performance ##################################################
################################################################################################################
...
...
@@ -76,4 +64,4 @@ file(GLOB perf_srcs "perf/*.cpp")
file
(
GLOB perf_hdrs
"perf/*.hpp"
"perf/*.h"
)
ocv_add_perf_tests
(
FILES
"Include"
${
perf_hdrs
}
FILES
"Src"
${
perf_srcs
}
)
FILES
"Src"
${
perf_srcs
}
)
modules/ocl/cl2cpp.cmake
0 → 100644
View file @
bbb2d27a
file
(
GLOB cl_list
"
${
CL_DIR
}
/*.cl"
)
file
(
WRITE
${
OUTPUT
}
"// This file is auto-generated. Do not edit!
namespace cv
{
namespace ocl
{
"
)
foreach
(
cl
${
cl_list
}
)
get_filename_component
(
cl_filename
"
${
cl
}
"
NAME_WE
)
#message("${cl_filename}")
file
(
READ
"
${
cl
}
"
lines
)
string
(
REPLACE
"
\r
"
""
lines
"
${
lines
}
\n
"
)
string
(
REPLACE
"
\t
"
" "
lines
"
${
lines
}
"
)
string
(
REGEX REPLACE
"/
\\
*([^*]/|
\\
*[^/]|[^*/])*
\\
*/"
""
lines
"
${
lines
}
"
)
# multiline comments
string
(
REGEX REPLACE
"[ ]*//[^
\n
]*
\n
"
"
\n
"
lines
"
${
lines
}
"
)
# single-line comments
string
(
REGEX REPLACE
"
\n
[ ]*(
\n
[ ]*)*"
"
\n
"
lines
"
${
lines
}
"
)
# empty lines & leading whitespace
string
(
REGEX REPLACE
"^
\n
"
""
lines
"
${
lines
}
"
)
# leading new line
string
(
REPLACE
"
\\
"
"
\\\\
"
lines
"
${
lines
}
"
)
string
(
REPLACE
"
\"
"
"
\\\"
"
lines
"
${
lines
}
"
)
string
(
REPLACE
"
\n
"
"
\\
n
\"\n\"
"
lines
"
${
lines
}
"
)
string
(
REGEX REPLACE
"
\"
$"
""
lines
"
${
lines
}
"
)
# unneeded " at the eof
file
(
APPEND
${
OUTPUT
}
"const char*
${
cl_filename
}
=
\"
${
lines
}
;
\n
"
)
endforeach
()
file
(
APPEND
${
OUTPUT
}
"}
\n
}
\n
"
)
\ No newline at end of file
modules/ocl/cl2cpp.js
deleted
100644 → 0
View file @
42414b56
var
fso
=
new
ActiveXObject
(
"Scripting.FileSystemObject"
),
shell
=
new
ActiveXObject
(
"WScript.Shell"
),
args
=
WScript
.
Arguments
,
indir
=
args
[
0
],
outname
=
args
[
1
],
outDir
,
scriptFullPath
=
WScript
.
ScriptFullName
;
function
getDir
(
a
)
{
return
a
.
substring
(
0
,
a
.
lastIndexOf
(
"
\
\"
) || a.lastIndexOf("
/
"))
}
if (!indir || !outname) {
var scriptPath = getDir(WScript.ScriptFullName.toString()),
indir = indir || scriptPath + "
/
src
/
kernels
";
outname || (outname = scriptPath + "
/
kernels
.
cpp
", outDir = scriptPath)
} else {
outDir = getDir(outname);
try {
fso.CreateFolder(outDir)
} catch (err) {}
}
var infldr = fso.GetFolder(indir), clrx = /([
\
w-]+)
\
.cl$/i, stripBeginningRx = /^(
\
s)+/i, stripSinglelineMstyle = /
\
/
\
*.*?
\
*
\
//ig, outStream = fso.OpenTextFile(outname, 2, !0, -2);
outStream.write("
// This file is auto-generated. Do not edit!\n\nnamespace cv{\n\tnamespace ocl{\n");
for
(
var
res
,
cl_file
,
l
,
state
,
countFiles
=
0
,
codeRows
=
0
,
removedRows
=
0
,
filei
=
new
Enumerator
(
infldr
.
Files
);
!
filei
.
atEnd
();
filei
.
moveNext
())
if
(
cl_file
=
filei
.
item
(),
res
=
cl_file
.
Name
.
match
(
clrx
))
{
var
cl_filename
=
res
[
1
],
inStream
=
cl_file
.
OpenAsTextStream
(
1
);
outStream
.
writeLine
(
"
\
t
\
tconst char* "
+
cl_filename
+
"="
);
state
=
0
;
for
(
countFiles
++
;
!
inStream
.
AtEndOfStream
;
)
{
l
=
inStream
.
readLine
();
stripSinglelineMstyle
.
lastIndex
=
0
;
l
=
l
.
replace
(
stripSinglelineMstyle
,
""
);
var
mline
=
l
.
indexOf
(
"/*"
);
0
<=
mline
?
(
l
=
l
.
substr
(
0
,
mline
),
state
=
1
)
:
(
mline
=
l
.
indexOf
(
"*/"
),
0
<=
mline
&&
(
l
=
l
.
substr
(
mline
+
2
),
state
=
0
));
var
slineBegin
=
l
.
indexOf
(
"//"
);
0
<=
slineBegin
&&
(
l
=
l
.
substr
(
0
,
slineBegin
));
1
==
state
||
!
l
?
removedRows
++
:
(
l
=
l
.
replace
(
stripBeginningRx
,
"$1"
),
l
=
l
.
replace
(
"
\
\"
, "
\\\\
"), l = l.replace("
\
r
", ""), l = l.replace('"
', '
\\
"'), l = l.replace("
\
t
", "
"), codeRows++, outStream.writeLine('
\
t
\
t
\
t"
' + l + '
\\
n
"'))
}
outStream.writeLine("
\
t
\
t
;
");
inStream.close()
}
outStream.writeLine("
\
t
\
t
}
\
n
\
t
}
");
outStream.close();
shell.Popup("
Merging
OpenCL
Kernels
into
cpp
file
has
been
FINISHED
!
\
nFiles
:
" + countFiles + "
\
nCode
rows
:
" + codeRows + "
\
nRemoved
rows
:
" + removedRows, 1, "
OpenCL
Kernels
to
cpp
file
", 64);
modules/ocl/cl2cpp.py
deleted
100755 → 0
View file @
42414b56
import
os
,
os
.
path
,
sys
,
glob
indir
=
sys
.
argv
[
1
]
outname
=
sys
.
argv
[
2
]
#indir = "/Users/vp/work/ocv/opencv/modules/ocl/src/kernels"
#outname = "/Users/vp/work/ocv.build/xcode/modules/ocl/kernels.cpp"
try
:
os
.
mkdir
(
os
.
path
.
dirname
(
outname
))
except
OSError
:
pass
cl_list
=
glob
.
glob
(
os
.
path
.
join
(
indir
,
"*.cl"
))
kfile
=
open
(
outname
,
"wt"
)
kfile
.
write
(
"""// This file is auto-generated. Do not edit!
namespace cv
{
namespace ocl
{
"""
)
for
cl
in
cl_list
:
cl_file
=
open
(
cl
,
"rt"
)
cl_filename
=
os
.
path
.
basename
(
cl
)
cl_filename
=
cl_filename
[:
cl_filename
.
rfind
(
"."
)]
kfile
.
write
(
"const char*
%
s="
%
cl_filename
)
state
=
0
for
cl_line
in
cl_file
.
readlines
():
l
=
cl_line
.
strip
()
# skip the leading comments
if
l
.
startswith
(
"//"
)
and
l
.
find
(
"*/"
)
<
0
:
if
state
==
0
:
state
=
1
else
:
if
state
==
1
or
l
.
find
(
"*/"
)
>=
0
:
state
=
2
if
state
==
1
:
continue
l
=
l
.
replace
(
"
\\
"
,
"
\\\\
"
)
l
=
l
.
replace
(
"
\r
"
,
""
)
l
=
l
.
replace
(
"
\"
"
,
"
\\\"
"
)
l
=
l
.
replace
(
"
\t
"
,
" "
)
kfile
.
write
(
"
\"
%
s
\\
n
\"\n
"
%
l
)
kfile
.
write
(
";
\n
"
)
cl_file
.
close
()
kfile
.
write
(
"""}
}
"""
)
kfile
.
close
()
modules/ocl/src/precomp.hpp
View file @
bbb2d27a
...
...
@@ -63,16 +63,14 @@
#include <exception>
#include <stdio.h>
#include "opencv2/ocl/ocl.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/core_c.h"
//#include "opencv2/highgui/highgui.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/ocl/ocl.hpp"
#include "opencv2/core/internal.hpp"
//#include "opencv2/highgui/highgui.hpp"
#define __ATI__
...
...
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