From d6453cf051c169be18ed4e4a6121317cc1e68698 Mon Sep 17 00:00:00 2001 From: hbristow Date: Thu, 27 Jun 2013 16:25:18 -0700 Subject: [PATCH] Now builds all functions except those dependent on Features2d. Improved build detection if cmake is rerun --- modules/matlab/CMakeLists.txt | 5 +++-- modules/matlab/generator/filters.py | 5 +++-- modules/matlab/generator/gen_matlab.py | 2 -- modules/matlab/generator/parse_tree.py | 7 +++++++ modules/matlab/include/bridge.hpp | 12 ++++++++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/modules/matlab/CMakeLists.txt b/modules/matlab/CMakeLists.txt index 0b422a0af4..5c9d46da6b 100644 --- a/modules/matlab/CMakeLists.txt +++ b/modules/matlab/CMakeLists.txt @@ -44,10 +44,10 @@ set(the_description "The Matlab/Octave bindings") ocv_add_module(matlab BINDINGS #TODO: does it actually NEED to depend on core? OPTIONAL opencv_core opencv_imgproc opencv_ml opencv_highgui - #opencv_objdetect opencv_features2d + opencv_objdetect #opencv_features2d TODO: Re-enable when Flann is in a compliant state opencv_video opencv_photo #opencv_calib opencv_calib3d - #opencv_nonfree + opencv_nonfree ) # TODO: Undo this when building all modules to find python properly @@ -143,6 +143,7 @@ set(MEX_WORKS True CACHE BOOL ADVANCED) # (which do the real work) only when they're outdated set(GENERATE_PROXY ${CMAKE_CURRENT_BINARY_DIR}/generate.proxy) set(COMPILE_PROXY ${CMAKE_CURRENT_BINARY_DIR}/compile.proxy) +file(REMOVE ${GENERATE_PROXY} ${COMPILE_PROXY}) # generate # call the python executable to generate the Matlab gateways diff --git a/modules/matlab/generator/filters.py b/modules/matlab/generator/filters.py index b07b43d3a8..24053b4527 100644 --- a/modules/matlab/generator/filters.py +++ b/modules/matlab/generator/filters.py @@ -44,10 +44,11 @@ def noutputs(args): return len(outputs(args)) def convertibleToInt(string): + salt = '1+' try: - int(string) + exec(salt+string) return True - except ValueError: + except: return False def capitalizeFirst(text): diff --git a/modules/matlab/generator/gen_matlab.py b/modules/matlab/generator/gen_matlab.py index e6e764a36a..b132a819db 100644 --- a/modules/matlab/generator/gen_matlab.py +++ b/modules/matlab/generator/gen_matlab.py @@ -13,10 +13,8 @@ class MatlabWrapperGenerator(object): ns[name] = parser.parse(file) # cleanify the parser output - print ns['ml'] 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) diff --git a/modules/matlab/generator/parse_tree.py b/modules/matlab/generator/parse_tree.py index 70730059b6..18d11e5f99 100644 --- a/modules/matlab/generator/parse_tree.py +++ b/modules/matlab/generator/parse_tree.py @@ -51,6 +51,13 @@ class Translator(object): # classes have 'class' prefixed on their name if 'class' in defn[0].split(' ') or 'struct' in defn[0].split(' '): return self.translateClass(defn) + # --- operators! --- + #TODO: implement operators: http://www.mathworks.com.au/help/matlab/matlab_oop/implementing-operators-for-your-class.html + if 'operator' in defn[0]: + return self.translateFunction(defn) + # --- constant --- + elif convertibleToInt(defn[1]): + return self.translateConstant(defn) # --- function --- # functions either need to have input arguments, or not uppercase names elif defn[3] or not self.translateName(defn[0]).split('_')[0].isupper(): diff --git a/modules/matlab/include/bridge.hpp b/modules/matlab/include/bridge.hpp index 6d25da76c8..c62d3df9bc 100644 --- a/modules/matlab/include/bridge.hpp +++ b/modules/matlab/include/bridge.hpp @@ -14,7 +14,9 @@ typedef std::vector vector_Mat; typedef std::vector vector_Point; typedef std::vector vector_int; typedef std::vector vector_float; +typedef std::vector vector_String; typedef std::vector vector_uchar; +typedef std::vector vector_Rect; void conditionalError(bool expr, const std::string& str) { @@ -134,6 +136,16 @@ public: vector_float toVectorFloat() { return vector_float(); } operator vector_float() { return toVectorFloat(); } + // --------------------------- vector_Rect ---------------------------------- + Bridge& operator=(const vector_Rect& obj) { return *this; } + vector_Rect toVectorRect() { return vector_Rect(); } + operator vector_Rect() { return toVectorRect(); } + + // --------------------------- vector_String ---------------------------------- + Bridge& operator=(const vector_String& obj) { return *this; } + vector_String toVectorString() { return vector_String(); } + operator vector_String() { return toVectorString(); } + // --------------------------- string -------------------------------------- Bridge& operator=(const std::string& obj) { return *this; } std::string toString() { return ""; }