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
31415e34
Commit
31415e34
authored
Jun 19, 2013
by
hbristow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Matlab binding generation now at build time
parent
884f36ba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
24 deletions
+24
-24
CMakeLists.txt
modules/matlab/CMakeLists.txt
+20
-20
gen_matlab.py
modules/matlab/generator/gen_matlab.py
+0
-2
gen_matlab_caller.py
modules/matlab/generator/gen_matlab_caller.py
+4
-2
No files found.
modules/matlab/CMakeLists.txt
View file @
31415e34
...
...
@@ -3,7 +3,7 @@
#
# Matlab code generation and compilation is broken down into two distinct
# stages: configure time and build time. The idea is that we want to give
# the user reasonable guarantees that once they type 'make' wrapper
# the user reasonable guarantees that once they type 'make'
,
wrapper
# generation is unlikely to fail. Therefore we run a series of tests at
# configure time to check the working status of the core components.
#
...
...
@@ -37,6 +37,7 @@ endmacro()
# make sure we're on a supported architecture with Matlab and python installed
if
(
IOS OR ANDROID OR NOT MATLAB_FOUND OR NOT PYTHONLIBS_FOUND
)
ocv_module_disable
(
matlab
)
return
()
endif
()
set
(
the_description
"The Matlab/Octave bindings"
)
...
...
@@ -45,9 +46,7 @@ ocv_add_module(matlab BINDINGS opencv_core opencv_imgproc
opencv_highgui opencv_ml opencv_calib3d opencv_photo
opencv_nonfree opencv_calib
)
# add the python generator to the python path
set
(
PYPATH_CACHE $ENV{PYTHONPATH}
)
set
(
ENV{PYTHONPATH}
${
OPENCV_MODULE_opencv_python_LOCATION
}
/src2:$ENV{PYTHONPATH}
)
set
(
HDR_PARSER_PATH
${
OPENCV_MODULE_opencv_python_LOCATION
}
/src2
)
# get the include path of the Bridge
prepend
(
"-I"
MEX_INCLUDES
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
)
...
...
@@ -57,7 +56,8 @@ prepend("-I" MEX_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include)
# ----------------------------------------------------------------------------
message
(
"-- Trying to generate Matlab code"
)
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab_caller.py
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab_caller.py
${
HDR_PARSER_PATH
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/test_generator.hpp
${
CMAKE_CURRENT_BINARY_DIR
}
ERROR_VARIABLE GEN_ERROR
OUTPUT_QUIET
...
...
@@ -66,8 +66,6 @@ execute_process(
if
(
GEN_ERROR
)
message
(
${
GEN_ERROR
}
)
message
(
"-- Error generating Matlab code. Disabling Matlab bindings..."
)
# restore the pythonpath
set
(
ENV{PYTHONPATH}
${
PYPATH_CACHE
}
)
return
()
else
()
message
(
"-- Trying to generate Matlab code - OK"
)
...
...
@@ -86,8 +84,6 @@ execute_process(
if
(
MEX_ERROR
)
message
(
${
MEX_ERROR
}
)
message
(
"-- Error compiling mex file. Disabling Matlab bindings..."
)
# restore the pythonpath
set
(
ENV{PYTHONPATH}
${
PYPATH_CACHE
}
)
return
()
else
()
message
(
"-- Trying to compile mex file - OK"
)
...
...
@@ -95,7 +91,6 @@ endif()
# if we make it here, mex works!
set_property
(
GLOBAL PROPERTY MEX_WORKS TRUE
)
return
()
# ----------------------------------------------------------------------------
# Build time components
...
...
@@ -108,19 +103,24 @@ foreach(module ${OPENCV_MATLAB_MODULES})
prepend
(
"-I"
MEX_INCLUDES
"
${
OPENCV_MODULE_opencv_
${
module
}
_LOCATION
}
/include"
)
endif
()
endforeach
()
message
(
${
MEX_INCLUDES
}
)
# synthesise the matlab sources
# TODO:These should be build-time (ie add_custom_command)
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab_caller.py
${
opencv_hdrs
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
add_custom_target
(
opencv_matlab_sources ALL
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab_caller.py
${
HDR_PARSER_PATH
}
${
opencv_hdrs
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
#
compile
the matlab sources
file
(
GLOB SOURCE_FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/src
)
#
get
the matlab sources
file
(
GLOB SOURCE_FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/*.cpp"
)
foreach
(
SOURCE_FILE
${
SOURCE_FILES
}
)
get_filename_component
(
FILENAME
${
SOURCE_FILE
}
NAME_WE
)
# compile the source file using mex
add_custom_target
(
"opencv_matlab_
${
FILENAME
}
"
ALL
COMMAND
"/usr/bin/true"
#COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_INCLUDES}
# ${SOURCE_FILE}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/src
DEPENDS opencv_matlab_sources
)
endforeach
()
# restore the pythonpath
set
(
ENV{PYTHONPATH}
${
PYPATH_CACHE
}
)
modules/matlab/generator/gen_matlab.py
View file @
31415e34
...
...
@@ -18,12 +18,10 @@ class MatlabWrapperGenerator(object):
# get the file name
name
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
file
))[
0
]
ns
[
name
]
=
parser
.
parse
(
file
)
print
ns
[
name
]
# cleanify the parser output
parse_tree
=
ParseTree
()
parse_tree
.
build
(
ns
)
print
parse_tree
# setup the template engine
jtemplate
=
Environment
(
loader
=
PackageLoader
(
'templates'
,
''
),
trim_blocks
=
True
,
lstrip_blocks
=
True
)
...
...
modules/matlab/generator/gen_matlab_caller.py
View file @
31415e34
#/usr/bin/env python
# add the hdr_parser to the path
import
sys
from
gen_matlab
import
MatlabWrapperGenerator
sys
.
path
.
append
(
sys
.
argv
[
1
])
# get the IO from the command line arguments
input_files
=
sys
.
argv
[
1
:
-
1
]
input_files
=
sys
.
argv
[
2
:
-
1
]
output_dir
=
sys
.
argv
[
-
1
]
# create the generator
from
gen_matlab
import
MatlabWrapperGenerator
mwg
=
MatlabWrapperGenerator
()
mwg
.
gen
(
input_files
,
output_dir
)
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