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
7e5bbec8
Commit
7e5bbec8
authored
Sep 02, 2013
by
hbristow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing trailing whitespace and expanded tabs
parent
f57145dc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
191 additions
and
193 deletions
+191
-193
OpenCVFindMatlab.cmake
cmake/OpenCVFindMatlab.cmake
+55
-55
CMakeLists.txt
modules/matlab/CMakeLists.txt
+10
-10
LICENSE
modules/matlab/LICENSE
+1
-2
README.md
modules/matlab/README.md
+0
-0
compile.cmake
modules/matlab/compile.cmake
+2
-2
build_info.py
modules/matlab/generator/build_info.py
+2
-2
cvmex.py
modules/matlab/generator/cvmex.py
+1
-1
filters.py
modules/matlab/generator/filters.py
+4
-4
gen_matlab.py
modules/matlab/generator/gen_matlab.py
+6
-6
__init__.py
modules/matlab/generator/jinja2/markupsafe/__init__.py
+1
-1
parser.py
modules/matlab/generator/jinja2/parser.py
+1
-1
parse_tree.py
modules/matlab/generator/parse_tree.py
+9
-9
functional.cpp
modules/matlab/generator/templates/functional.cpp
+6
-6
template_build_info.m
modules/matlab/generator/templates/template_build_info.m
+2
-2
template_class_base.cpp
modules/matlab/generator/templates/template_class_base.cpp
+2
-2
template_class_base.m
modules/matlab/generator/templates/template_class_base.m
+1
-1
template_cvmex_base.m
modules/matlab/generator/templates/template_cvmex_base.m
+3
-3
template_function_base.cpp
...les/matlab/generator/templates/template_function_base.cpp
+2
-3
template_map_base.m
modules/matlab/generator/templates/template_map_base.m
+7
-7
bridge.hpp
modules/matlab/include/opencv2/matlab/bridge.hpp
+43
-43
map.hpp
modules/matlab/include/opencv2/matlab/map.hpp
+1
-1
mxarray.hpp
modules/matlab/include/opencv2/matlab/mxarray.hpp
+21
-21
transpose.hpp
modules/matlab/include/opencv2/matlab/transpose.hpp
+1
-1
OpenCVTest.m
modules/matlab/test/OpenCVTest.m
+1
-1
cv_exception.cpp
modules/matlab/test/cv_exception.cpp
+2
-2
exception.cpp
modules/matlab/test/exception.cpp
+2
-2
std_exception.cpp
modules/matlab/test/std_exception.cpp
+2
-2
test_compiler.cpp
modules/matlab/test/test_compiler.cpp
+2
-2
test_generator.hpp
modules/matlab/test/test_generator.hpp
+1
-1
No files found.
cmake/OpenCVFindMatlab.cmake
View file @
7e5bbec8
# ----- Find Matlab/Octave -----
#
# OpenCVFindMatlab.cmake attempts to locate the install path of Matlab in order
# to extract the mex headers, libraries and shell scripts. If found
# to extract the mex headers, libraries and shell scripts. If found
# successfully, the following variables will be defined
#
# MATLAB_FOUND: true/false
...
...
@@ -13,7 +13,7 @@
# MATLAB_LIBRARY_DIR: Path to mex and matrix libraries
# MATLAB_LIBS: The Matlab libs, usually mx, mex, mat
# MATLAB_MEXEXT: The mex library extension. It will be one of:
# mexwin32, mexwin64, mexglx, mexa64, mexmac,
# mexwin32, mexwin64, mexglx, mexa64, mexmac,
# mexmaci, mexmaci64, mexsol, mexs64
# MATLAB_ARCH: The installation architecture. It is simply
# the MEXEXT with the preceding "mex" removed
...
...
@@ -30,23 +30,23 @@
#
# Matlab tends to use some non-standard prefixes and suffixes on its libraries.
# For example, libmx.dll on Windows (Windows does not add prefixes) and
# mkl.dylib on OS X (OS X uses "lib" prefixes).
# mkl.dylib on OS X (OS X uses "lib" prefixes).
# On some versions of Windows the .dll suffix also appears to not be checked.
#
# This function modifies the library prefixes and suffixes used by
# This function modifies the library prefixes and suffixes used by
# find_library when finding Matlab libraries. It does not affect scopes
# outside of this file.
function
(
set_libarch_prefix_suffix
)
if
(
UNIX AND NOT APPLE
)
set
(
CMAKE_FIND_LIBRARY_PREFIXES
"lib"
PARENT_SCOPE
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
".so"
".a"
PARENT_SCOPE
)
elseif
(
APPLE
)
set
(
CMAKE_FIND_LIBRARY_PREFIXES
"lib"
PARENT_SCOPE
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
".dylib"
".a"
PARENT_SCOPE
)
elseif
(
WIN32
)
set
(
CMAKE_FIND_LIBRARY_PREFIXES
"lib"
PARENT_SCOPE
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
".lib"
".dll"
PARENT_SCOPE
)
endif
()
if
(
UNIX AND NOT APPLE
)
set
(
CMAKE_FIND_LIBRARY_PREFIXES
"lib"
PARENT_SCOPE
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
".so"
".a"
PARENT_SCOPE
)
elseif
(
APPLE
)
set
(
CMAKE_FIND_LIBRARY_PREFIXES
"lib"
PARENT_SCOPE
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
".dylib"
".a"
PARENT_SCOPE
)
elseif
(
WIN32
)
set
(
CMAKE_FIND_LIBRARY_PREFIXES
"lib"
PARENT_SCOPE
)
set
(
CMAKE_FIND_LIBRARY_SUFFIXES
".lib"
".dll"
PARENT_SCOPE
)
endif
()
endfunction
()
...
...
@@ -56,7 +56,7 @@ endfunction()
# Attempt to find the path to the Matlab installation. If successful, sets
# the absolute path in the variable MATLAB_ROOT_DIR
function
(
locate_matlab_root
)
# --- LINUX ---
if
(
UNIX AND NOT APPLE
)
# possible root locations, in order of likelihood
...
...
@@ -90,40 +90,40 @@ function(locate_matlab_root)
# --- WINDOWS ---
elseif
(
WIN32
)
# search the path to see if Matlab exists there
# search the path to see if Matlab exists there
# Contrary to EVERY OTHER REGEX IMPLEMENTATION ON EARTH, cmake returns
# the entire input string if no matches for the capture group are found.
string
(
REGEX REPLACE
".*[;=](.*[Mm][Aa][Tt][Ll][Aa][Bb][^;]*)
\\\\
bin.*"
"
\\
1"
MATLAB_ROOT_DIR_
"$ENV{PATH}"
)
string
(
REGEX REPLACE
".*[;=](.*[Mm][Aa][Tt][Ll][Aa][Bb][^;]*)
\\\\
bin.*"
"
\\
1"
MATLAB_ROOT_DIR_
"$ENV{PATH}"
)
if
(
"
${
MATLAB_ROOT_DIR_
}
"
STREQUAL
"$ENV{PATH}"
)
set
(
MATLAB_ROOT_DIR_
)
endif
()
# registry-hacking
# registry-hacking
# determine the available Matlab versions
set
(
REG_EXTENSION_
"SOFTWARE
\\
Mathworks
\\
MATLAB"
)
set
(
REG_EXTENSION_
"SOFTWARE
\\
Mathworks
\\
MATLAB"
)
set
(
REG_ROOTS_
"HKEY_LOCAL_MACHINE"
"HKEY_CURRENT_USER"
)
foreach
(
REG_ROOT_
${
REG_ROOTS_
}
)
execute_process
(
COMMAND reg query
"
${
REG_ROOT_
}
\\
${
REG_EXTENSION_
}
"
OUTPUT_VARIABLE QUERY_RESPONSE_
)
if
(
QUERY_RESPONSE_
)
execute_process
(
COMMAND reg query
"
${
REG_ROOT_
}
\\
${
REG_EXTENSION_
}
"
OUTPUT_VARIABLE QUERY_RESPONSE_
)
if
(
QUERY_RESPONSE_
)
string
(
REGEX MATCHALL
"[0-9]
\\
.[0-9]"
VERSION_STRINGS_
${
QUERY_RESPONSE_
}
)
list
(
APPEND VERSIONS_
${
VERSION_STRINGS_
}
)
endif
()
endforeach
()
# select the highest version
list
(
APPEND VERSIONS_
"0.0"
)
list
(
SORT VERSIONS_
)
list
(
REVERSE VERSIONS_
)
list
(
GET VERSIONS_ 0 VERSION_
)
# request the MATLABROOT from the registry
foreach
(
REG_ROOT_
${
REG_ROOTS_
}
)
get_filename_component
(
QUERY_RESPONSE_ [
${
REG_ROOT_
}
\\
${
REG_EXTENSION_
}
\\
${
VERSION_
}
;MATLABROOT] ABSOLUTE
)
if
(
"
${
MATLAB_ROOT_DIR_
}
"
STREQUAL
""
AND NOT
${
QUERY_RESPONSE_
}
MATCHES
"registry$"
)
set
(
MATLAB_ROOT_DIR_
${
QUERY_RESPONSE_
}
)
endif
()
endforeach
()
endif
()
endif
()
endforeach
()
# select the highest version
list
(
APPEND VERSIONS_
"0.0"
)
list
(
SORT VERSIONS_
)
list
(
REVERSE VERSIONS_
)
list
(
GET VERSIONS_ 0 VERSION_
)
# request the MATLABROOT from the registry
foreach
(
REG_ROOT_
${
REG_ROOTS_
}
)
get_filename_component
(
QUERY_RESPONSE_ [
${
REG_ROOT_
}
\\
${
REG_EXTENSION_
}
\\
${
VERSION_
}
;MATLABROOT] ABSOLUTE
)
if
(
"
${
MATLAB_ROOT_DIR_
}
"
STREQUAL
""
AND NOT
${
QUERY_RESPONSE_
}
MATCHES
"registry$"
)
set
(
MATLAB_ROOT_DIR_
${
QUERY_RESPONSE_
}
)
endif
()
endforeach
()
endif
()
# export the root into the parent scope
if
(
MATLAB_ROOT_DIR_
)
...
...
@@ -149,28 +149,28 @@ function(locate_matlab_components MATLAB_ROOT_DIR)
return
()
endif
()
string
(
STRIP
${
MATLAB_MEXEXT_
}
MATLAB_MEXEXT_
)
# map the mexext to an architecture extension
set
(
ARCHITECTURES_
"maci64"
"maci"
"glnxa64"
"glnx64"
"sol64"
"sola64"
"win32"
"win64"
)
foreach
(
ARCHITECTURE_
${
ARCHITECTURES_
}
)
if
(
EXISTS
${
MATLAB_ROOT_DIR
}
/bin/
${
ARCHITECTURE_
}
)
set
(
MATLAB_ARCH_
${
ARCHITECTURE_
}
)
break
()
endif
()
endforeach
()
# map the mexext to an architecture extension
set
(
ARCHITECTURES_
"maci64"
"maci"
"glnxa64"
"glnx64"
"sol64"
"sola64"
"win32"
"win64"
)
foreach
(
ARCHITECTURE_
${
ARCHITECTURES_
}
)
if
(
EXISTS
${
MATLAB_ROOT_DIR
}
/bin/
${
ARCHITECTURE_
}
)
set
(
MATLAB_ARCH_
${
ARCHITECTURE_
}
)
break
()
endif
()
endforeach
()
# get the path to the libraries
set
(
MATLAB_LIBRARY_DIR_
${
MATLAB_ROOT_DIR
}
/bin/
${
MATLAB_ARCH_
}
)
# get the libraries
set_libarch_prefix_suffix
()
set_libarch_prefix_suffix
()
find_library
(
MATLAB_LIB_MX_ mx PATHS
${
MATLAB_LIBRARY_DIR_
}
NO_DEFAULT_PATH
)
find_library
(
MATLAB_LIB_MEX_ mex PATHS
${
MATLAB_LIBRARY_DIR_
}
NO_DEFAULT_PATH
)
find_library
(
MATLAB_LIB_MAT_ mat PATHS
${
MATLAB_LIBRARY_DIR_
}
NO_DEFAULT_PATH
)
set
(
MATLAB_LIBS_
${
MATLAB_LIB_MX_
}
${
MATLAB_LIB_MEX_
}
${
MATLAB_LIB_MAT_
}
)
# get the include path
find_path
(
MATLAB_INCLUDE_DIR_ mex.h
${
MATLAB_ROOT_DIR
}
/extern/include
)
find_path
(
MATLAB_INCLUDE_DIR_ mex.h
${
MATLAB_ROOT_DIR
}
/extern/include
)
# get the mex shell script
find_file
(
MATLAB_MEX_SCRIPT_ NAMES mex mex.bat PATHS
${
MATLAB_ROOT_DIR
}
/bin NO_DEFAULT_PATH
)
...
...
@@ -197,7 +197,7 @@ endfunction()
# FIND MATLAB COMPONENTS
# ----------------------------------------------------------------------------
if
(
NOT MATLAB_FOUND
)
# guilty until proven innocent
set
(
MATLAB_FOUND FALSE
)
...
...
@@ -206,11 +206,11 @@ if (NOT MATLAB_FOUND)
locate_matlab_root
()
endif
()
# given the matlab root folder, find the library locations
# given the matlab root folder, find the library locations
if
(
MATLAB_ROOT_DIR
)
locate_matlab_components
(
${
MATLAB_ROOT_DIR
}
)
endif
()
find_package_handle_standard_args
(
Matlab DEFAULT_MSG MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIR
MATLAB_ROOT_DIR MATLAB_LIBS MATLAB_LIBRARY_DIR
find_package_handle_standard_args
(
Matlab DEFAULT_MSG MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIR
MATLAB_ROOT_DIR MATLAB_LIBS MATLAB_LIBRARY_DIR
MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN
)
endif
()
modules/matlab/CMakeLists.txt
View file @
7e5bbec8
...
...
@@ -56,7 +56,7 @@ elseif (NOT PYTHONLIBS_FOUND)
ocv_module_disable
(
matlab
)
return
()
endif
()
# If the user built OpenCV as X-bit, but they have a Y-bit version of Matlab,
# attempting to link to OpenCV during binding generation will fail, since
...
...
@@ -89,7 +89,7 @@ ocv_add_module(matlab BINDINGS
opencv_objdetect opencv_flann opencv_features2d
opencv_photo opencv_video opencv_videostab
opencv_calib opencv_calib3d
opencv_stitching opencv_superres
opencv_stitching opencv_superres
opencv_nonfree
)
...
...
@@ -147,14 +147,14 @@ if (NOT MEX_WORKS)
# attempt to generate a gateway for a function
message
(
STATUS
"Trying to generate Matlab code"
)
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab.py
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab.py
--hdrparser
${
HDR_PARSER_PATH
}
--rstparser
${
RST_PARSER_PATH
}
--extra
"test=
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/test_generator.hpp"
--outdir
${
CMAKE_BINARY_DIR
}
/junk
ERROR_VARIABLE GEN_ERROR
OUTPUT_QUIET
OUTPUT_QUIET
)
if
(
GEN_ERROR
)
...
...
@@ -207,23 +207,23 @@ file(REMOVE ${GENERATE_PROXY} ${COMPILE_PROXY})
# call the python executable to generate the Matlab gateways
add_custom_command
(
OUTPUT
${
GENERATE_PROXY
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab.py
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/gen_matlab.py
--hdrparser
${
HDR_PARSER_PATH
}
--rstparser
${
RST_PARSER_PATH
}
--moduleroot
${
CMAKE_SOURCE_DIR
}
/modules
--modules
${
opencv_modules
}
--extra
${
opencv_extra_hdrs
}
--extra
${
opencv_extra_hdrs
}
--outdir
${
CMAKE_CURRENT_BINARY_DIR
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/generator/build_info.py
--os
${
CMAKE_SYSTEM
}
--os
${
CMAKE_SYSTEM
}
--arch
${
ARCH
}
${
CMAKE_SYSTEM_PROCESSOR
}
--compiler
${
CMAKE_CXX_COMPILER_ID
}
${
CMAKE_CXX_COMPILER_VERSION
}
--mex_arch
${
MATLAB_ARCH
}
--mex_script
${
MATLAB_MEX_SCRIPT
}
--cxx_flags
${
MEX_CXXFLAGS
}
--opencv_version
${
OPENCV_VERSION
}
--opencv_version
${
OPENCV_VERSION
}
--commit
${
GIT_COMMIT
}
--modules
${
opencv_modules
}
--configuration
"$(Configuration)"
${
CMAKE_BUILD_TYPE
}
...
...
modules/matlab/LICENSE
View file @
7e5bbec8
...
...
@@ -39,4 +39,4 @@
// arising in any way out of the use of this software, even if advised of the
// possibility of such damage.
//
////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file
////////////////////////////////////////////////////////////////////////////////
modules/matlab/README.md
View file @
7e5bbec8
This diff is collapsed.
Click to expand it.
modules/matlab/compile.cmake
View file @
7e5bbec8
...
...
@@ -34,7 +34,7 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
# compile the source file using mex
if
(
NOT EXISTS
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv/
${
FILENAME
}
.
${
MATLAB_MEXEXT
}
)
execute_process
(
COMMAND
${
MATLAB_MEX_SCRIPT
}
${
MEX_OPTS
}
"CXXFLAGS=
\$
CXXFLAGS
${
MEX_CXXFLAGS
}
"
${
MEX_INCLUDE_DIRS_LIST
}
COMMAND
${
MATLAB_MEX_SCRIPT
}
${
MEX_OPTS
}
"CXXFLAGS=
\$
CXXFLAGS
${
MEX_CXXFLAGS
}
"
${
MEX_INCLUDE_DIRS_LIST
}
${
MEX_LIB_DIR
}
${
MEX_LIBS_LIST
}
${
SOURCE_FILE
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/+cv
OUTPUT_QUIET
...
...
@@ -42,7 +42,7 @@ foreach(SOURCE_FILE ${SOURCE_FILES})
)
endif
()
# TODO: If a mex file fails to compile, should we error out?
# TODO: Warnings are currently treated as errors...
# TODO: Warnings are currently treated as errors...
if
(
FAILED
)
message
(
FATAL_ERROR
"Failed to compile
${
FILENAME
}
:
${
FAILED
}
"
)
endif
()
...
...
modules/matlab/generator/build_info.py
View file @
7e5bbec8
...
...
@@ -44,9 +44,9 @@ if __name__ == "__main__":
given the information passed to this module. build_info.py invokes Jinja2
on the template_build_info.m template.
"""
# parse the input options
import
sys
,
re
,
os
,
time
import
sys
,
re
,
os
,
time
from
argparse
import
ArgumentParser
parser
=
ArgumentParser
()
parser
.
add_argument
(
'--os'
)
...
...
modules/matlab/generator/cvmex.py
View file @
7e5bbec8
...
...
@@ -38,7 +38,7 @@ if __name__ == "__main__":
same as the builtin mex compiler, with added cv qualification:
>> cv.mex(..., ...);
"""
# parse the input options
import
sys
,
re
,
os
,
time
from
argparse
import
ArgumentParser
...
...
modules/matlab/generator/filters.py
View file @
7e5bbec8
...
...
@@ -65,7 +65,7 @@ def binaryToDecimal(string):
def
formatMatlabConstant
(
string
,
table
):
'''
Given a string representing a Constant, and a table of all Constants,
Given a string representing a Constant, and a table of all Constants,
attempt to resolve the Constant into a valid Matlab expression
For example, the input
DEPENDENT_VALUE = 1 << FIXED_VALUE
...
...
@@ -75,7 +75,7 @@ def formatMatlabConstant(string, table):
# split the string into expressions
words
=
re
.
split
(
'(
\
W+)'
,
string
)
# add a 'cv' prefix if an expression is also a key in the lookup table
words
=
''
.
join
([(
'cv.'
+
word
if
word
in
table
else
word
)
for
word
in
words
])
words
=
''
.
join
([(
'cv.'
+
word
if
word
in
table
else
word
)
for
word
in
words
])
# attempt to convert arithmetic expressions and binary/hex to decimal
words
=
binaryToDecimal
(
words
)
# convert any remaining bitshifts to Matlab 'bitshift' methods
...
...
@@ -155,11 +155,11 @@ def stripExtraSpaces(text):
'''Removes superfluous whitespace from a string, including the removal
of all leading and trailing whitespace'''
return
' '
.
join
(
text
.
split
())
def
comment
(
text
,
wrap
=
80
,
escape
=
'
%
'
,
escape_first
=
''
,
escape_last
=
''
):
'''comment filter
Takes a string in text, and wraps it to wrap characters in length with
preceding comment escape sequence on each line. escape_first and
preceding comment escape sequence on each line. escape_first and
escape_last can be used for languages which define block comments.
Examples:
C++ inline comment comment(80, '// ')
...
...
modules/matlab/generator/gen_matlab.py
View file @
7e5bbec8
...
...
@@ -75,7 +75,7 @@ class MatlabWrapperGenerator(object):
jtemplate
.
filters
[
'qualify'
]
=
qualify
jtemplate
.
filters
[
'slugify'
]
=
slugify
jtemplate
.
filters
[
'only'
]
=
only
jtemplate
.
filters
[
'void'
]
=
void
jtemplate
.
filters
[
'void'
]
=
void
jtemplate
.
filters
[
'not'
]
=
flip
# load the templates
...
...
@@ -87,7 +87,7 @@ class MatlabWrapperGenerator(object):
# create the build directory
output_source_dir
=
output_dir
+
'/src'
output_private_dir
=
output_source_dir
+
'/private'
output_private_dir
=
output_source_dir
+
'/private'
output_class_dir
=
output_dir
+
'/+cv'
output_map_dir
=
output_dir
+
'/map'
if
not
os
.
path
.
isdir
(
output_source_dir
):
...
...
@@ -142,7 +142,7 @@ if __name__ == "__main__":
1. constructs the headers to parse from the module root and list of modules
2. parses the headers using CppHeaderParser
3. refactors the definitions using ParseTree
4. parses .rst docs using RstParser
4. parses .rst docs using RstParser
5. populates the templates for classes, function, enums and docs from the
definitions
...
...
@@ -156,14 +156,14 @@ if __name__ == "__main__":
to produce bindings for. The path to the include directories
as well as the namespaces are constructed from the modules
and the moduleroot
--extra extra headers explicitly defined to parse. This must be in
--extra extra headers explicitly defined to parse. This must be in
the format "namepsace=/path/to/extra/header.hpp". For example,
the core module requires the extra header:
"core=/opencv/modules/core/include/opencv2/core/core/base.hpp"
--outdir the output directory to put the generated matlab sources. In
the OpenCV build this is "${CMAKE_CURRENT_BUILD_DIR}/src"
"""
# parse the input options
import
sys
,
re
,
os
,
time
from
argparse
import
ArgumentParser
...
...
@@ -172,7 +172,7 @@ if __name__ == "__main__":
parser
.
add_argument
(
'--rstparser'
)
parser
.
add_argument
(
'--moduleroot'
,
default
=
''
,
required
=
False
)
parser
.
add_argument
(
'--modules'
,
nargs
=
'*'
,
default
=
[],
required
=
False
)
parser
.
add_argument
(
'--extra'
,
nargs
=
'*'
,
default
=
[],
required
=
False
)
parser
.
add_argument
(
'--extra'
,
nargs
=
'*'
,
default
=
[],
required
=
False
)
parser
.
add_argument
(
'--outdir'
)
args
=
parser
.
parse_args
()
...
...
modules/matlab/generator/jinja2/markupsafe/__init__.py
View file @
7e5bbec8
...
...
@@ -41,7 +41,7 @@ class Markup(text_type):
>>> class Foo(object):
... def __html__(self):
... return '<a href="#">foo</a>'
...
...
>>> Markup(Foo())
Markup(u'<a href="#">foo</a>')
...
...
modules/matlab/generator/jinja2/parser.py
View file @
7e5bbec8
...
...
@@ -14,7 +14,7 @@ from jinja2.lexer import describe_token, describe_token_expr
from
jinja2._compat
import
imap
#: statements that callinto
#: statements that callinto
_statement_keywords
=
frozenset
([
'for'
,
'if'
,
'block'
,
'extends'
,
'print'
,
'macro'
,
'include'
,
'from'
,
'import'
,
'set'
])
...
...
modules/matlab/generator/parse_tree.py
View file @
7e5bbec8
...
...
@@ -4,7 +4,7 @@ from filters import *
class
ParseTree
(
object
):
"""
The ParseTree class produces a semantic tree of C++ definitions given
The ParseTree class produces a semantic tree of C++ definitions given
the output of the CppHeaderParser (from opencv/modules/python/src2/hdr_parser.py)
The full hierarchy is as follows:
...
...
@@ -83,7 +83,7 @@ class ParseTree(object):
methods
=
[]
constants
=
[]
for
defn
in
definitions
:
obj
=
babel
.
translate
(
defn
)
obj
=
babel
.
translate
(
defn
)
if
obj
is
None
:
continue
if
type
(
obj
)
is
Class
or
obj
.
clss
:
...
...
@@ -116,7 +116,7 @@ class ParseTree(object):
class
Translator
(
object
):
"""
The Translator class does the heavy lifting of translating the nested
The Translator class does the heavy lifting of translating the nested
list representation of the hdr_parser into individual definitions that
are inserted into the ParseTree.
Translator consists of a top-level method: translate()
...
...
@@ -126,7 +126,7 @@ class Translator(object):
"""
def
translate
(
self
,
defn
):
# --- class ---
# classes have 'class' prefixed on their name
# classes have 'class' prefixed on their name
if
'class'
in
defn
[
0
]
.
split
(
' '
)
or
'struct'
in
defn
[
0
]
.
split
(
' '
):
return
self
.
translateClass
(
defn
)
# --- operators! ---
...
...
@@ -151,16 +151,16 @@ class Translator(object):
name
=
self
.
translateName
(
defn
[
0
])
clss
=
self
.
translateClassName
(
defn
[
0
])
rtp
=
defn
[
1
]
static
=
True
if
'S'
in
''
.
join
(
defn
[
2
])
else
False
static
=
True
if
'S'
in
''
.
join
(
defn
[
2
])
else
False
args
=
defn
[
3
]
req
=
[]
req
=
[]
opt
=
[]
for
arg
in
args
:
if
arg
:
a
=
self
.
translateArgument
(
arg
)
opt
.
append
(
a
)
if
a
.
default
else
req
.
append
(
a
)
return
Method
(
name
,
clss
,
static
,
''
,
rtp
,
False
,
req
,
opt
)
def
translateConstant
(
self
,
defn
):
const
=
True
if
'const'
in
defn
[
0
]
else
False
name
=
self
.
translateName
(
defn
[
0
])
...
...
@@ -199,7 +199,7 @@ class Namespace(object):
|- Constants
|- Methods
|- Constants
"""
"""
def
__init__
(
self
,
name
=
''
,
constants
=
None
,
classes
=
None
,
methods
=
None
):
self
.
name
=
name
self
.
constants
=
constants
if
constants
else
[]
...
...
@@ -254,7 +254,7 @@ class Method(object):
self
.
static
=
static
self
.
const
=
const
self
.
namespace
=
namespace
self
.
rtp
=
rtp
self
.
rtp
=
rtp
self
.
req
=
req
if
req
else
[]
self
.
opt
=
opt
if
opt
else
[]
...
...
modules/matlab/generator/templates/functional.cpp
View file @
7e5bbec8
/*
/*
* compose
* compose a function call
* This macro takes as input a Method object and composes
...
...
@@ -11,23 +11,23 @@
{
%-
if
fun
.
clss
and
not
fun
.
constructor
-%
}
inst
.{
%-
else
-%
}
cv
::
{
%-
endif
-%
}
{{
fun
.
name
}}(
{
#
-
-----------
Required
-------------
-
#
}
{
%-
for
arg
in
fun
.
req
-%
}
{
%-
for
arg
in
fun
.
req
-%
}
{
%-
if
arg
.
ref
==
'*'
-%
}
&
{
%-
endif
-%
}
{{
arg
.
name
}}
{{
arg
.
name
}}
{
%-
if
not
loop
.
last
%
},
{
%
endif
%
}
{
%
endfor
%
}
{
#
-
-----------
Optional
-------------
-
#
}
{
%
if
fun
.
req
and
fun
.
opt
%
},
{
%
endif
%
}
{
%-
for
opt
in
fun
.
opt
-%
}
{
%-
for
opt
in
fun
.
opt
-%
}
{
%-
if
opt
.
ref
==
'*'
-%
}
&
{
%-
endif
-%
}
{{
opt
.
name
}}
{{
opt
.
name
}}
{
%-
if
not
loop
.
last
-%
},
{
%
endif
%
}
{
%-
endfor
-%
}
);
{
%-
endmacro
%
}
/*
/*
* composeMatlab
* compose a Matlab function call
* This macro takes as input a Method object and composes
...
...
modules/matlab/generator/templates/template_build_info.m
View file @
7e5bbec8
...
...
@@ -3,7 +3,7 @@ function buildInformation()
%
% Call CV.BUILDINFORMATION() to get a printout of diagonstic information
% pertaining to your particular build of the OpenCV Toolbox. If you ever
% run into issues with the Toolbox, it is useful to submit this
% run into issues with the Toolbox, it is useful to submit this
% information alongside a bug report to the OpenCV team.
%
% Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation
...
...
@@ -23,7 +23,7 @@ info = {
[
' Version: '
version
()]
[
' Mex extension: '
mexext
()]
' Architecture: {{ build.mex_arch }}'
' Mex path: {{ build.mex_script }}'
' Mex path: {{ build.mex_script }}'
' Mex flags: {{ build.mex_opts | csv('
') }}'
' CXX flags: {{ build.cxx_flags | csv('
') | stripExtraSpaces | wordwrap(60, True, '
\
'\n\'
') }}'
''
...
...
modules/matlab/generator/templates/template_class_base.cpp
View file @
7e5bbec8
...
...
@@ -3,7 +3,7 @@
* file: {{clss.name}}Bridge.cpp
* author: A trusty code generator
* date: {{time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())}}
*
*
* This file was autogenerated, do not modify.
* See LICENSE for full modification and redistribution details.
* Copyright {{time.strftime("%Y", time.localtime())}} The OpenCV Foundation
...
...
@@ -56,7 +56,7 @@ static const Map<std::string, MethodSignature> methods = createMethodMap();
// map of created {{clss.name}} instances. Don't trust the user to keep them safe...
static
Map
<
void
*
,
{{
clss
.
name
}}
>
instances
;
/*
/*
* {{ clss.name }}
* Gateway routine
* nlhs - number of return arguments
...
...
modules/matlab/generator/templates/template_class_base.m
View file @
7e5bbec8
...
...
@@ -8,7 +8,7 @@ classdef {{clss.name}} < handle
properties
(
SetAccess
=
private
,
Hidden
=
true
)
ptr_
=
0
;
% handle to the underlying c++ clss instance
end
methods
% constructor
function
this
=
{{
clss
.
name
}}(
varargin
)
...
...
modules/matlab/generator/templates/template_cvmex_base.m
View file @
7e5bbec8
...
...
@@ -5,16 +5,16 @@ function mex(varargin)
% CV.MEX [options ...] file [file file ...]
%
% Description:
% CV.MEX compiles one or more C/C++ source files into a shared-library
% CV.MEX compiles one or more C/C++ source files into a shared-library
% called a mex-file. This function is equivalent to the builtin MEX
% routine, with the notable exception that it automatically resolves
% OpenCV includes, and links in the OpenCV libraries where appropriate.
% OpenCV includes, and links in the OpenCV libraries where appropriate.
% It also forwards the flags used to build OpenCV, so architecture-
% specific optimizations can be used.
%
% CV.MEX is designed to be used in situations where the source(s) you
% are compiling contain OpenCV definitions. In such cases, it streamlines
% the finding and including of appropriate OpenCV libraries.
% the finding and including of appropriate OpenCV libraries.
%
% See also: mex
%
...
...
modules/matlab/generator/templates/template_function_base.cpp
View file @
7e5bbec8
...
...
@@ -3,7 +3,7 @@
* file: {{fun.name}}.cpp
* author: A trusty code generator
* date: {{time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())}}
*
*
* This file was autogenerated, do not modify.
* See LICENSE for full modification and redistribution details.
* Copyright {{time.strftime("%Y", time.localtime())}} The OpenCV Foundation
...
...
@@ -18,7 +18,7 @@ using namespace cv;
using
namespace
matlab
;
using
namespace
bridge
;
/*
/*
* {{ fun.name }}
* {{ fun }}
* Gateway routine
...
...
@@ -58,4 +58,3 @@ void mexFunction(int nlhs, mxArray*{% if fun|noutputs %} plhs[]{% else %}*{% end
}
{
%
endif
%
}
}
modules/matlab/generator/templates/template_map_base.m
View file @
7e5bbec8
...
...
@@ -4,11 +4,11 @@
% ------------------------------------------------------------------------
%
% The OpenCV Toolbox allows you to make calls to native OpenCV methods
% and classes directly from within Matlab.
% and classes directly from within Matlab.
%
% <strong>PATHS</strong>
% To call OpenCV methods from anywhere in your workspace, add the
% directory containing this file to the path:
% directory containing this file to the path:
%
% addpath(fileparts(which('cv')));
%
...
...
@@ -37,18 +37,18 @@
%
% <strong>HELP</strong>
% Each method has its own help file containing information about the
% arguments, return values, and what operation the method performs.
% arguments, return values, and what operation the method performs.
% You can access this help information by typing:
%
%
% help cv.methodName
%
% The full list of methods can be found by inspecting the +cv/
% The full list of methods can be found by inspecting the +cv/
% directory. Note that the methods available to you will depend
% on which modules you configured OpenCV to build.
%
% <strong>DIAGNOSTICS</strong>
% If you are having problems with the OpenCV Toolbox and need to send a
% bug report to the OpenCV team, you can get a printout of diagnostic
% If you are having problems with the OpenCV Toolbox and need to send a
% bug report to the OpenCV team, you can get a printout of diagnostic
% information to submit along with your report by typing:
%
% <a href="matlab: cv.buildInformation()">cv.buildInformation();</a>
...
...
modules/matlab/include/opencv2/matlab/bridge.hpp
View file @
7e5bbec8
...
...
@@ -53,7 +53,7 @@
namespace
cv
{
namespace
bridge
{
/*
/*
* Custom typedefs
* Parsed names from the hdr_parser
*/
...
...
@@ -92,7 +92,7 @@ void deepCopyAndTranspose(const matlab::MxArray& src, cv::Mat& dst);
// BRIDGE
// ----------------------------------------------------------------------------
/*!
/*!
* @class Bridge
* @brief Type conversion class for converting OpenCV and native C++ types
*
...
...
@@ -108,7 +108,7 @@ void deepCopyAndTranspose(const matlab::MxArray& src, cv::Mat& dst);
* ObjectType toObjectType();
*
* The bridging class provides common conversions between OpenCV types,
* std and stl types to Matlab's mxArray format. By inheriting Bridge,
* std and stl types to Matlab's mxArray format. By inheriting Bridge,
* you can add your own custom type conversions.
*
* Because Matlab uses a homogeneous storage type, all operations are provided
...
...
@@ -123,7 +123,7 @@ void deepCopyAndTranspose(const matlab::MxArray& src, cv::Mat& dst);
* myObject --> MyObject
* this is because the binding generator standardises the calling syntax.
*
* Bridge attempts to make as few assumptions as possible, however in
* Bridge attempts to make as few assumptions as possible, however in
* some cases where 1-to-1 mappings don't exist, some assumptions are necessary.
* In particular:
* - conversion from of a 2-channel Mat to an mxArray will result in a complex
...
...
@@ -180,7 +180,7 @@ public:
matlab
::
conditionalError
(
obj
,
std
::
string
(
"Object "
).
append
(
std
::
string
(
name
)).
append
(
std
::
string
(
" is NULL"
)));
return
obj
;
}
// --------------------------------------------------------------------------
// MATLAB TYPES
...
...
@@ -190,8 +190,8 @@ public:
Bridge
(
const
matlab
::
MxArray
&
obj
)
:
ptr_
(
obj
)
{}
Bridge
(
const
mxArray
*
obj
)
:
ptr_
(
obj
)
{}
matlab
::
MxArray
toMxArray
()
{
return
ptr_
;
}
// --------------------------------------------------------------------------
// MATRIX CONVERSIONS
// --------------------------------------------------------------------------
...
...
@@ -216,7 +216,7 @@ public:
}
template
<
typename
Scalar
>
cv
::
Mat
toMat
()
const
{
cv
::
Mat
toMat
()
const
{
cv
::
Mat
mat
(
ptr_
.
rows
(),
ptr_
.
cols
(),
CV_MAKETYPE
(
cv
::
DataType
<
Scalar
>::
type
,
ptr_
.
channels
()));
switch
(
ptr_
.
ID
())
{
case
mxINT8_CLASS
:
deepCopyAndTranspose
<
int8_t
,
Scalar
>
(
ptr_
,
mat
);
break
;
...
...
@@ -236,15 +236,15 @@ public:
return
mat
;
}
// --------------------------------------------------------------------------
// INTEGRAL TYPES
// --------------------------------------------------------------------------
// --------------------------- string --------------------------------------
Bridge
&
operator
=
(
const
std
::
string
&
)
{
return
*
this
;
}
std
::
string
toString
()
{
std
::
string
toString
()
{
return
ptr_
.
toString
();
}
operator
std
::
string
()
{
return
toString
();
}
...
...
@@ -268,11 +268,11 @@ public:
Bridge
&
operator
=
(
const
int
&
)
{
return
*
this
;
}
int
toInt
()
{
return
ptr_
.
scalar
<
int
>
();
}
operator
int
()
{
return
toInt
();
}
// --------------------------------------------------------------------------
// CORE OPENCV TYPES
// --------------------------------------------------------------------------
...
...
@@ -281,47 +281,47 @@ public:
Bridge
&
operator
=
(
const
cv
::
Point
&
)
{
return
*
this
;
}
cv
::
Point
toPoint
()
const
{
return
cv
::
Point
();
}
operator
cv
::
Point
()
const
{
return
toPoint
();
}
// -------------------------- Point2f ------------------------------------
Bridge
&
operator
=
(
const
cv
::
Point2f
&
)
{
return
*
this
;
}
cv
::
Point2f
toPoint2f
()
const
{
return
cv
::
Point2f
();
}
operator
cv
::
Point2f
()
const
{
return
toPoint2f
();
}
// -------------------------- Point2d ------------------------------------
Bridge
&
operator
=
(
const
cv
::
Point2d
&
)
{
return
*
this
;
}
cv
::
Point2d
toPoint2d
()
const
{
return
cv
::
Point2d
();
}
operator
cv
::
Point2d
()
const
{
return
toPoint2d
();
}
// -------------------------- Size ---------------------------------------
Bridge
&
operator
=
(
const
cv
::
Size
&
)
{
return
*
this
;
}
cv
::
Size
toSize
()
const
{
return
cv
::
Size
();
}
operator
cv
::
Size
()
const
{
return
toSize
();
}
// -------------------------- Moments --------------------------------------
Bridge
&
operator
=
(
const
cv
::
Moments
&
)
{
return
*
this
;
}
cv
::
Moments
toMoments
()
const
{
return
cv
::
Moments
();
}
operator
cv
::
Moments
()
const
{
return
toMoments
();
}
// -------------------------- Scalar --------------------------------------
Bridge
&
operator
=
(
const
cv
::
Scalar
&
)
{
return
*
this
;
}
cv
::
Scalar
toScalar
()
{
return
cv
::
Scalar
();
}
operator
cv
::
Scalar
()
{
return
toScalar
();
}
// -------------------------- Rect -----------------------------------------
Bridge
&
operator
=
(
const
cv
::
Rect
&
)
{
return
*
this
;
}
cv
::
Rect
toRect
()
{
return
cv
::
Rect
();
}
operator
cv
::
Rect
()
{
return
toRect
();
}
// ---------------------- RotatedRect ---------------------------------------
Bridge
&
operator
=
(
const
cv
::
RotatedRect
&
)
{
return
*
this
;
}
cv
::
RotatedRect
toRotatedRect
()
{
return
cv
::
RotatedRect
();
}
operator
cv
::
RotatedRect
()
{
return
toRotatedRect
();
}
// ---------------------- TermCriteria --------------------------------------
Bridge
&
operator
=
(
const
cv
::
TermCriteria
&
)
{
return
*
this
;
}
cv
::
TermCriteria
toTermCriteria
()
{
return
cv
::
TermCriteria
();
}
operator
cv
::
TermCriteria
()
{
return
toTermCriteria
();
}
// ---------------------- RNG --------------------------------------
Bridge
&
operator
=
(
const
cv
::
RNG
&
)
{
return
*
this
;
}
/*! @brief explicit conversion to cv::RNG()
...
...
@@ -335,14 +335,14 @@ public:
}
operator
cv
::
RNG
()
{
return
toRNG
();
}
// --------------------------------------------------------------------------
// OPENCV VECTOR TYPES
// --------------------------------------------------------------------------
// -------------------- vector_Mat ------------------------------------------
Bridge
&
operator
=
(
const
vector_Mat
&
)
{
return
*
this
;
}
vector_Mat
toVectorMat
()
{
return
vector_Mat
();
}
...
...
@@ -352,37 +352,37 @@ public:
Bridge
&
operator
=
(
const
vector_int
&
)
{
return
*
this
;
}
vector_int
toVectorInt
()
{
return
vector_int
();
}
operator
vector_int
()
{
return
toVectorInt
();
}
// --------------------------- vector_float --------------------------------
Bridge
&
operator
=
(
const
vector_float
&
)
{
return
*
this
;
}
vector_float
toVectorFloat
()
{
return
vector_float
();
}
operator
vector_float
()
{
return
toVectorFloat
();
}
// --------------------------- vector_Rect ---------------------------------
Bridge
&
operator
=
(
const
vector_Rect
&
)
{
return
*
this
;
}
vector_Rect
toVectorRect
()
{
return
vector_Rect
();
}
operator
vector_Rect
()
{
return
toVectorRect
();
}
// --------------------------- vector_KeyPoint -----------------------------
Bridge
&
operator
=
(
const
vector_KeyPoint
&
)
{
return
*
this
;
}
vector_KeyPoint
toVectorKeyPoint
()
{
return
vector_KeyPoint
();
}
operator
vector_KeyPoint
()
{
return
toVectorKeyPoint
();
}
// --------------------------- vector_String -------------------------------
Bridge
&
operator
=
(
const
vector_String
&
)
{
return
*
this
;
}
vector_String
toVectorString
()
{
return
vector_String
();
}
operator
vector_String
()
{
return
toVectorString
();
}
// ------------------------ vector_Point ------------------------------------
Bridge
&
operator
=
(
const
vector_Point
&
)
{
return
*
this
;
}
vector_Point
toVectorPoint
()
{
return
vector_Point
();
}
operator
vector_Point
()
{
return
toVectorPoint
();
}
// ------------------------ vector_uchar ------------------------------------
Bridge
&
operator
=
(
const
vector_uchar
&
)
{
return
*
this
;
}
vector_uchar
toVectorUchar
()
{
return
vector_uchar
();
}
operator
vector_uchar
()
{
return
toVectorUchar
();
}
// ------------------------ vector_vector_char ------------------------------
Bridge
&
operator
=
(
const
vector_vector_char
&
)
{
return
*
this
;
}
vector_vector_char
toVectorVectorChar
()
{
return
vector_vector_char
();
}
...
...
@@ -393,9 +393,9 @@ public:
vector_vector_DMatch
toVectorVectorDMatch
()
{
return
vector_vector_DMatch
();
}
operator
vector_vector_DMatch
()
{
return
toVectorVectorDMatch
();
}
// --------------------------------------------------------------------------
// OPENCV COMPOUND TYPES
// --------------------------------------------------------------------------
...
...
@@ -453,7 +453,7 @@ matlab::MxArray Bridge::FromMat<matlab::InheritType>(const cv::Mat& mat) {
/*!
* @brief template specialization for inheriting types
*
*
* This template specialization attempts to preserve the best mapping
* between Matlab and OpenCV types. OpenCV has poor support for double precision
* types, so all floating point types are cast to float. Logicals get cast
...
...
@@ -497,7 +497,7 @@ void deepCopyAndTranspose(const cv::Mat& in, matlab::MxArray& out) {
cv
::
split
(
in
,
channels
);
for
(
size_t
c
=
0
;
c
<
out
.
channels
();
++
c
)
{
cv
::
transpose
(
channels
[
c
],
channels
[
c
]);
cv
::
Mat
outmat
(
out
.
cols
(),
out
.
rows
(),
cv
::
DataType
<
OutputScalar
>::
type
,
cv
::
Mat
outmat
(
out
.
cols
(),
out
.
rows
(),
cv
::
DataType
<
OutputScalar
>::
type
,
static_cast
<
void
*>
(
out
.
real
<
OutputScalar
>
()
+
out
.
cols
()
*
out
.
rows
()
*
c
));
channels
[
c
].
convertTo
(
outmat
,
cv
::
DataType
<
OutputScalar
>::
type
);
}
...
...
@@ -525,7 +525,7 @@ void deepCopyAndTranspose(const matlab::MxArray& in, cv::Mat& out) {
//const InputScalar* inp = in.real<InputScalar>();
//OutputScalar* outp = out.ptr<OutputScalar>(0);
//gemt('C', in.rows(), in.cols(), inp, in.rows(), outp, out.step1());
//gemt('C', in.rows(), in.cols(), inp, in.rows(), outp, out.step1());
}
...
...
modules/matlab/include/opencv2/matlab/map.hpp
View file @
7e5bbec8
...
...
@@ -46,7 +46,7 @@
namespace
matlab
{
#if __cplusplus >= 201103L
// If we have C++11 support, we just want to use unordered_map
// If we have C++11 support, we just want to use unordered_map
#include <unordered_map>
template
<
typename
KeyType
,
typename
ValueType
>
using
Map
=
std
::
unordered_map
<
KeyType
,
ValueType
>
;
...
...
modules/matlab/include/opencv2/matlab/mxarray.hpp
View file @
7e5bbec8
...
...
@@ -59,7 +59,7 @@ typedef std::set<std::string> StringSet;
/*
* All recent versions of Matlab ship with the MKL library which contains
* a blas extension called mkl_?omatcopy(). This defines an out-of-place
* a blas extension called mkl_?omatcopy(). This defines an out-of-place
* copy and transpose operation.
*
* The mkl library is in ${MATLAB_ROOT}/bin/${MATLAB_MEXEXT}/libmkl...
...
...
@@ -225,7 +225,7 @@ private:
/*!
* @brief swap all members of this and other
*
* the swap method is used by the assignment and move constructors
* the swap method is used by the assignment and move constructors
* to swap the members of two MxArrays, leaving both in destructible states
*/
friend
void
swap
(
MxArray
&
first
,
MxArray
&
second
)
{
...
...
@@ -234,7 +234,7 @@ private:
swap
(
first
.
owns_
,
second
.
owns_
);
}
void
dealloc
()
{
void
dealloc
()
{
if
(
owns_
&&
ptr_
)
{
mxDestroyArray
(
ptr_
);
ptr_
=
NULL
;
owns_
=
false
;
}
}
public
:
...
...
@@ -255,7 +255,7 @@ public:
* just encapsulate it
*/
MxArray
(
const
mxArray
*
ptr
)
:
ptr_
(
const_cast
<
mxArray
*>
(
ptr
)),
owns_
(
false
)
{}
MxArray
&
operator
=
(
const
mxArray
*
ptr
)
{
MxArray
&
operator
=
(
const
mxArray
*
ptr
)
{
dealloc
();
ptr_
=
const_cast
<
mxArray
*>
(
ptr
);
owns_
=
false
;
...
...
@@ -318,9 +318,9 @@ public:
return
s
;
}
/*!
/*!
* @brief destructor
*
*
* The destructor deallocates any data allocated by mxCreate* methods only
* if the object is owned
*/
...
...
@@ -328,7 +328,7 @@ public:
dealloc
();
}
/*!
/*!
* @brief copy constructor
*
* All copies are deep copies. If you have a C++11 compatible compiler, prefer
...
...
@@ -340,7 +340,7 @@ public:
* @brief copy-and-swap assignment
*
* This assignment operator uses the copy and swap idiom to provide a strong
* exception guarantee when swapping two objects.
* exception guarantee when swapping two objects.
*
* Note in particular that the other MxArray is passed by value, thus invoking
* the copy constructor which performs a deep copy of the input. The members of
...
...
@@ -370,9 +370,9 @@ public:
* MxArray is not directly convertible back to mxArray types through assignment
* because the MxArray may have been allocated on the free store, making it impossible
* to know whether the returned pointer will be released by someone else or not.
*
*
* Since Matlab requires mxArrays be passed back into the workspace, the only way
* to achieve that is through this function, which explicitly releases ownership
* to achieve that is through this function, which explicitly releases ownership
* of the object, assuming the Matlab interpreter receving the object will delete
* it at a later time
*
...
...
@@ -394,13 +394,13 @@ public:
template
<
typename
Scalar
>
Scalar
*
real
()
{
return
static_cast
<
Scalar
*>
(
mxGetData
(
ptr_
));
}
template
<
typename
Scalar
>
Scalar
*
imag
()
{
return
static_cast
<
Scalar
*>
(
mxGetImagData
(
ptr_
));
}
template
<
typename
Scalar
>
const
Scalar
*
real
()
const
{
return
static_cast
<
const
Scalar
*>
(
mxGetData
(
ptr_
));
}
template
<
typename
Scalar
>
const
Scalar
*
imag
()
const
{
return
static_cast
<
const
Scalar
*>
(
mxGetData
(
ptr_
));
}
...
...
@@ -457,8 +457,8 @@ public:
* Mat sum(Mat& A, Mat& B); % add two matrices
* \endcode
*
* by adding two variants to ArgumentParser, the correct underlying sum
* method can be called. If the function call is ambiguous, the
* by adding two variants to ArgumentParser, the correct underlying sum
* method can be called. If the function call is ambiguous, the
* ArgumentParser will fail with an error message.
*
* The previous example could be parsed as:
...
...
@@ -491,7 +491,7 @@ private:
*
* When addVariant() is called on an instance to ArgumentParser, this class
* holds the the information that decribes that variant. The parse() method
* of ArgumentParser then attempts to match a Variant, given a set of
* of ArgumentParser then attempts to match a Variant, given a set of
* inputs for a method invocation.
*/
class
Variant
{
...
...
@@ -568,7 +568,7 @@ private:
s
<<
");"
;
if
(
Nreq_
+
Nopt_
==
0
)
return
s
.
str
();
// underscores
String
under
=
String
(
req_begin
,
' '
)
+
String
(
req_end
-
req_begin
,
'-'
)
String
under
=
String
(
req_begin
,
' '
)
+
String
(
req_end
-
req_begin
,
'-'
)
+
String
(
std
::
max
(
opt_begin
-
req_end
,
0
),
' '
)
+
String
(
opt_end
-
opt_begin
,
'-'
);
s
<<
"
\n
"
<<
under
;
// required and optional sets
...
...
@@ -601,7 +601,7 @@ public:
/*! @brief add a function call variant to the parser
*
* Adds a function-call signature to the parser. The function call *must* be
* Adds a function-call signature to the parser. The function call *must* be
* unique either in its number of arguments, or in the named-syntax.
* Currently this function does not check whether that invariant stands true.
*
...
...
@@ -625,9 +625,9 @@ public:
}
/*! @brief parse a vector of input arguments
*
* This method parses a vector of input arguments, attempting to match them
* to a Variant spec. For each input, the method attempts to cull any
*
* This method parses a vector of input arguments, attempting to match them
* to a Variant spec. For each input, the method attempts to cull any
* Variants which don't match the given inputs so far.
*
* Once all inputs have been parsed, if there is one unique spec remaining,
...
...
@@ -635,7 +635,7 @@ public:
* arguments removed. Any optional arguments that have not been encountered
* are set to an empty array.
*
* If multiple variants or no variants match the given call, an error
* If multiple variants or no variants match the given call, an error
* message is emitted
*/
MxArrayVector
parse
(
const
MxArrayVector
&
inputs
)
{
...
...
modules/matlab/include/opencv2/matlab/transpose.hpp
View file @
7e5bbec8
...
...
@@ -52,7 +52,7 @@ void transposeBlock(const size_t M, const size_t N, const InputScalar* src, size
cache
[
m
+
n
*
4
]
=
src
[
m
+
n
*
lda
];
// copy the destination out of the cache contiguously
for
(
size_t
m
=
0
;
m
<
M
;
++
m
)
for
(
size_t
n
=
0
;
n
<
N
;
++
n
)
for
(
size_t
n
=
0
;
n
<
N
;
++
n
)
dst
[
n
+
m
*
ldb
]
=
cache
[
m
+
n
*
4
];
}
...
...
modules/matlab/test/OpenCVTest.m
View file @
7e5bbec8
...
...
@@ -3,7 +3,7 @@
classdef
OpenCVTest
<
matlab
.
unittest
.
TestCase
methods
(
Test
)
% -------------------------------------------------------------------------
% EXCEPTIONS
% Check that errors and exceptions are thrown correctly
...
...
modules/matlab/test/cv_exception.cpp
View file @
7e5bbec8
...
...
@@ -2,7 +2,7 @@
* file: exception.cpp
* author: Hilton Bristow
* date: Wed, 19 Jun 2013 11:15:15
*
*
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
*/
...
...
@@ -10,7 +10,7 @@
#include <opencv2/core.hpp>
#include "mex.h"
/*
/*
* exception
* Gateway routine
* nlhs - number of return arguments
...
...
modules/matlab/test/exception.cpp
View file @
7e5bbec8
...
...
@@ -2,13 +2,13 @@
* file: exception.cpp
* author: Hilton Bristow
* date: Wed, 19 Jun 2013 11:15:15
*
*
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
*/
#include "mex.h"
/*
/*
* exception
* Gateway routine
* nlhs - number of return arguments
...
...
modules/matlab/test/std_exception.cpp
View file @
7e5bbec8
...
...
@@ -2,14 +2,14 @@
* file: exception.cpp
* author: Hilton Bristow
* date: Wed, 19 Jun 2013 11:15:15
*
*
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
*/
#include <exception>
#include "mex.h"
/*
/*
* exception
* Gateway routine
* nlhs - number of return arguments
...
...
modules/matlab/test/test_compiler.cpp
View file @
7e5bbec8
...
...
@@ -2,7 +2,7 @@
* file: rand.cpp
* author: A trusty code generator
* date: Wed, 19 Jun 2013 11:15:15
*
*
* This file was autogenerated, do not modify.
* See LICENCE for full modification and redistribution details.
* Copyright 2013 The OpenCV Foundation
...
...
@@ -10,7 +10,7 @@
#include "mex.h"
#include <vector>
/*
/*
* rand
* Gateway routine
* nlhs - number of return arguments
...
...
modules/matlab/test/test_generator.hpp
View file @
7e5bbec8
/*
/*
* a rather innocuous-looking function which is actually
* part of <cstdlib>, so we can be reasonably sure its
* definition will be found
...
...
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