diff --git a/modules/matlab/generator/gen_matlab.py b/modules/matlab/generator/gen_matlab.py index 44b46fd949..edad10ebe8 100644 --- a/modules/matlab/generator/gen_matlab.py +++ b/modules/matlab/generator/gen_matlab.py @@ -72,6 +72,9 @@ class MatlabWrapperGenerator(object): populated = tfunction.render(fun=method, time=time, includes=namespace.name) with open(output_source_dir+'/'+method.name+'.cpp', 'wb') as f: f.write(populated) + populated = tdoc.render(fun=method, time=time) + with open(output_class_dir+'/'+method.name+'.m', 'wb') as f: + f.write(populated) # classes for clss in namespace.classes: # cpp converter diff --git a/modules/matlab/generator/templates/functional.cpp b/modules/matlab/generator/templates/functional.cpp index 8e2e9d0a10..3beac2e785 100644 --- a/modules/matlab/generator/templates/functional.cpp +++ b/modules/matlab/generator/templates/functional.cpp @@ -27,6 +27,36 @@ {%- endmacro %} +/* + * composeMatlab + * compose a Matlab function call + * This macro takes as input a Method object and composes + * a Matlab function call by inspecting the types and argument names + */ +{% macro composeMatlab(fun) %} + {# ----------- Return type ------------- #} + {%- if fun|noutputs > 1 -%}[{% endif -%} + {%- if not fun.rtp|void -%}LVALUE{% endif -%} + {%- if not fun.rtp|void and fun|noutputs > 1 -%},{% endif -%} + {# ------------- Outputs ------------- -#} + {%- for arg in fun.req|outputs + fun.opt|outputs -%} + {{arg.name}} + {%- if arg.I -%}_out{%- endif -%} + {%- if not loop.last %}, {% endif %} + {% endfor %} + {%- if fun|noutputs > 1 -%}]{% endif -%} + {%- if fun|noutputs %} = {% endif -%} + cv.{{fun.name}}( + {#- ------------ Inputs -------------- -#} + {%- for arg in fun.req|inputs + fun.opt|inputs -%} + {{arg.name}} + {%- if arg.O -%}_in{%- endif -%} + {%- if not loop.last %}, {% endif -%} + {% endfor -%} + ); +{%- endmacro %} + + /* * composeWithExceptionHandler * compose a function call wrapped in exception traps diff --git a/modules/matlab/generator/templates/template_doc_base.m b/modules/matlab/generator/templates/template_doc_base.m index 72c8644176..d9e5922e95 100644 --- a/modules/matlab/generator/templates/template_doc_base.m +++ b/modules/matlab/generator/templates/template_doc_base.m @@ -1,6 +1,36 @@ -% {{ fun.name | upper }} {{ fun.doc.short_desc }} -{{ fun.doc.long_desc | comment('%',80) }} +{% import 'functional.cpp' as functional %} +%CV.{{ fun.name | upper }} +% {{ functional.composeMatlab(fun) | upper }} % -% See also: {{ fun.doc.see_also }} +{% if fun.rtp|void|not or fun.req|outputs|length or fun.opt|outputs|length %} +% Returns: +{% endif %} +{% if fun.rtp|void|not %} +% LVALUE +{% endif %} +{% for arg in fun.req|outputs + fun.opt|outputs %} +% {{arg.name | upper}}{%- if arg.I -%}_OUT{% endif %} + +{% endfor %} +% +{% if fun.req|inputs|length %} +% Required Inputs: +{% endif %} +{% for arg in fun.req|inputs %} +% {{arg.name | upper}}{%- if arg.O -%}_OUT{% endif %} + +{% endfor %} +% +{% if fun.opt|inputs|length %} +% Optional Inputs: +{% endif %} +{% for arg in fun.opt|inputs %} +% {{arg.name | upper}}{%- if arg.O -%}_OUT{% endif %} + +{% endfor %} +% +% See also: +% +% Official documentation: http://docs.opencv.org +% Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation % -% Copyright {{ time.strftime("%Y", localtime()) }} The OpenCV Foundation