From bb56ac4ae645de36efcd04d42672566556584317 Mon Sep 17 00:00:00 2001 From: hbristow Date: Thu, 27 Jun 2013 00:25:48 -0700 Subject: [PATCH] Added delta builds of Matlab executables. Imgproc module now compiling --- cmake/OpenCVModule.cmake | 2 +- modules/matlab/CMakeLists.txt | 1 + modules/matlab/compile.cmake | 14 +++++++------ modules/matlab/generator/gen_matlab.py | 2 ++ modules/matlab/generator/parse_tree.py | 3 ++- .../generator/templates/template_map_base.cpp | 2 +- modules/matlab/include/bridge.hpp | 21 +++++++++++++++++++ 7 files changed, 36 insertions(+), 9 deletions(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index b84512875a..bcc0072aae 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -313,7 +313,7 @@ macro(ocv_glob_modules) # TODO: Undo this change to build all modules #file(GLOB __ocvmodules RELATIVE "${__path}" "${__path}/*") - file(GLOB __ocvmodules RELATIVE "${__path}" "${__path}/core" "${__path}/matlab") + file(GLOB __ocvmodules RELATIVE "${__path}" "${__path}/core" "${__path}/imgproc" "${__path}/matlab") if(__ocvmodules) list(SORT __ocvmodules) foreach(mod ${__ocvmodules}) diff --git a/modules/matlab/CMakeLists.txt b/modules/matlab/CMakeLists.txt index f15fa983b9..3bcc80f9d4 100644 --- a/modules/matlab/CMakeLists.txt +++ b/modules/matlab/CMakeLists.txt @@ -159,6 +159,7 @@ add_custom_command( add_custom_command( OUTPUT ${COMPILE_PROXY} COMMAND ${CMAKE_COMMAND} -DMATLAB_MEX_SCRIPT=${MATLAB_MEX_SCRIPT} + -DMATLAB_MEXEXT=${MATLAB_MEXEXT} -DMEX_OPTS=${MEX_OPTS} -DMEX_INCLUDE_DIRS="${MEX_INCLUDE_DIRS}" -DMEX_LIB_DIR=${MEX_LIB_DIR} diff --git a/modules/matlab/compile.cmake b/modules/matlab/compile.cmake index 0d9139333c..95c8534808 100644 --- a/modules/matlab/compile.cmake +++ b/modules/matlab/compile.cmake @@ -8,12 +8,14 @@ foreach(SOURCE_FILE ${SOURCE_FILES}) # strip out the filename get_filename_component(FILENAME ${SOURCE_FILE} NAME_WE) # compile the source file using mex - execute_process( - COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} ${MEX_INCLUDE_DIRS_LIST} - ${MEX_LIB_DIR} ${MEX_LIBS} ${SOURCE_FILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/+cv - ERROR_VARIABLE FAILED - ) + if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/+cv/${FILENAME}.${MATLAB_MEXEXT}) + execute_process( + COMMAND ${MATLAB_MEX_SCRIPT} ${MEX_OPTS} ${MEX_INCLUDE_DIRS_LIST} + ${MEX_LIB_DIR} ${MEX_LIBS} ${SOURCE_FILE} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/+cv + ERROR_VARIABLE FAILED + ) + endif() # TODO: If a mex file fails to cmpile, should we error out? if (FAILED) message(FATAL_ERROR "Failed to compile ${FILENAME}: ${FAILED}") diff --git a/modules/matlab/generator/gen_matlab.py b/modules/matlab/generator/gen_matlab.py index b132a819db..ad7ba3b24b 100644 --- a/modules/matlab/generator/gen_matlab.py +++ b/modules/matlab/generator/gen_matlab.py @@ -12,9 +12,11 @@ class MatlabWrapperGenerator(object): name = os.path.splitext(os.path.basename(file))[0] ns[name] = parser.parse(file) + print ns['imgproc'] # 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) diff --git a/modules/matlab/generator/parse_tree.py b/modules/matlab/generator/parse_tree.py index d5f72719c3..be2d89631d 100644 --- a/modules/matlab/generator/parse_tree.py +++ b/modules/matlab/generator/parse_tree.py @@ -1,5 +1,6 @@ from string import join from textwrap import fill +from filters import * class ParseTree(object): def __init__(self, namespaces=None): @@ -52,7 +53,7 @@ class Translator(object): return self.translateClass(defn) # --- function --- # functions either need to have input arguments, or not uppercase names - elif defn[3] or not self.translateName(defn[0]).isupper(): + elif defn[3] or not self.translateName(defn[0]).split('_')[0].isupper(): return self.translateFunction(defn) # --- constant --- else: diff --git a/modules/matlab/generator/templates/template_map_base.cpp b/modules/matlab/generator/templates/template_map_base.cpp index 791b2c93a3..ca26bb2b82 100644 --- a/modules/matlab/generator/templates/template_map_base.cpp +++ b/modules/matlab/generator/templates/template_map_base.cpp @@ -12,7 +12,7 @@ typedef std::unordered_map Map; * from Matlab as, e.g. * cv.dft(x, xf, "DFT_FORWARD"); * - * Note that an alternative MAtlab class exists as well, so that functions + * Note that an alternative Matlab class exists as well, so that functions * can be called as, e.g. * cv.dft(x, xf, cv.DFT_FORWARD); * diff --git a/modules/matlab/include/bridge.hpp b/modules/matlab/include/bridge.hpp index 37f2dd6eb3..b7d32b1d4e 100644 --- a/modules/matlab/include/bridge.hpp +++ b/modules/matlab/include/bridge.hpp @@ -13,6 +13,7 @@ typedef std::vector vector_Mat; typedef std::vector vector_Point; typedef std::vector vector_int; +typedef std::vector vector_float; void conditionalError(bool expr, const std::string& str) { @@ -127,6 +128,11 @@ public: vector_int toVectorInt() { return vector_int(); } operator vector_int() { return toVectorInt(); } + // --------------------------- vector_float ---------------------------------- + Bridge& operator=(const vector_float& obj) { return *this; } + vector_float toVectorFloat() { return vector_float(); } + operator vector_float() { return toVectorFloat(); } + // --------------------------- string -------------------------------------- Bridge& operator=(const std::string& obj) { return *this; } std::string toString() { return ""; } @@ -147,11 +153,26 @@ public: cv::Point toPoint() { return cv::Point(); } operator cv::Point() { return toPoint(); } + // -------------------------- Point2f ------------------------------------ + Bridge& operator=(const cv::Point2f& obj) { return *this; } + cv::Point2f toPoint2f() { return cv::Point2f(); } + operator cv::Point2f() { return toPoint2f(); } + + // -------------------------- Point2d ------------------------------------ + Bridge& operator=(const cv::Point2d& obj) { return *this; } + cv::Point2d toPoint2d() { return cv::Point2d(); } + operator cv::Point2d() { return toPoint2d(); } + // -------------------------- Size --------------------------------------- Bridge& operator=(const cv::Size& obj) { return *this; } cv::Size toSize() { return cv::Size(); } operator cv::Size() { return toSize(); } + // -------------------------- Moments --------------------------------------- + Bridge& operator=(const cv::Moments& obj) { return *this; } + cv::Moments toMoments() { return cv::Moments(); } + operator cv::Moments() { return toMoments(); } + // ------------------------ vector_Point ------------------------------------ Bridge& operator=(const vector_Point& obj) { return *this; } vector_Point toVectorPoint() { return vector_Point(); }