2013-06-22 08:33:24 +08:00
|
|
|
{% import 'functional.cpp' as functional %}
|
2013-03-13 19:52:13 +08:00
|
|
|
/*
|
|
|
|
* file: {{fun.name}}.cpp
|
|
|
|
* author: A trusty code generator
|
2013-03-18 10:37:42 +08:00
|
|
|
* date: {{time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())}}
|
2013-09-02 22:16:46 +08:00
|
|
|
*
|
2013-03-13 19:52:13 +08:00
|
|
|
* This file was autogenerated, do not modify.
|
2013-08-29 23:09:29 +08:00
|
|
|
* See LICENSE for full modification and redistribution details.
|
2013-03-18 10:37:42 +08:00
|
|
|
* Copyright {{time.strftime("%Y", time.localtime())}} The OpenCV Foundation
|
2013-03-13 19:52:13 +08:00
|
|
|
*/
|
2013-06-19 09:54:14 +08:00
|
|
|
#include <string>
|
2013-03-13 19:52:13 +08:00
|
|
|
#include <vector>
|
2013-06-25 03:42:28 +08:00
|
|
|
#include <cassert>
|
2013-06-19 14:37:57 +08:00
|
|
|
#include <exception>
|
2013-08-28 15:06:19 +08:00
|
|
|
#include <opencv2/matlab/bridge.hpp>
|
2013-06-22 13:55:48 +08:00
|
|
|
#include <opencv2/{{includes}}.hpp>
|
2013-06-23 03:38:40 +08:00
|
|
|
using namespace cv;
|
2013-08-30 10:39:01 +08:00
|
|
|
using namespace matlab;
|
|
|
|
using namespace bridge;
|
2013-03-13 19:52:13 +08:00
|
|
|
|
2013-09-02 22:16:46 +08:00
|
|
|
/*
|
2013-03-13 19:52:13 +08:00
|
|
|
* {{ fun.name }}
|
2013-06-22 13:55:48 +08:00
|
|
|
* {{ fun }}
|
2013-03-18 08:35:43 +08:00
|
|
|
* Gateway routine
|
2013-03-13 19:52:13 +08:00
|
|
|
* nlhs - number of return arguments
|
|
|
|
* plhs - pointers to return arguments
|
|
|
|
* nrhs - number of input arguments
|
|
|
|
* prhs - pointers to input arguments
|
|
|
|
*/
|
2013-06-30 05:24:53 +08:00
|
|
|
void mexFunction(int nlhs, mxArray*{% if fun|noutputs %} plhs[]{% else %}*{% endif %},
|
|
|
|
int nrhs, const mxArray*{% if fun|ninputs %} prhs[]{% else %}*{% endif %}) {
|
2013-03-13 19:52:13 +08:00
|
|
|
|
2013-08-30 13:06:57 +08:00
|
|
|
{% if fun|ninputs %}
|
|
|
|
// parse the inputs
|
|
|
|
ArgumentParser parser("{{fun.name}}");
|
|
|
|
parser.{{ functional.composeVariant(fun) }};
|
|
|
|
MxArrayVector sorted = parser.parse(MxArrayVector(prhs, prhs+nrhs));
|
2013-08-30 14:10:32 +08:00
|
|
|
{% endif %}
|
2013-03-13 19:52:13 +08:00
|
|
|
|
2013-06-30 05:24:53 +08:00
|
|
|
{% if fun|ninputs or fun|noutputs %}
|
2013-06-22 08:33:24 +08:00
|
|
|
// setup
|
2013-06-30 05:24:53 +08:00
|
|
|
{% if fun|ninputs %}
|
2013-08-30 13:06:57 +08:00
|
|
|
BridgeVector inputs(sorted.begin(), sorted.end());
|
2013-06-30 05:24:53 +08:00
|
|
|
{% endif -%}
|
|
|
|
{%- if fun|noutputs %}
|
2013-08-30 13:06:57 +08:00
|
|
|
BridgeVector outputs({{fun|noutputs}});
|
2013-06-30 05:24:53 +08:00
|
|
|
{% endif %}
|
2013-06-22 14:39:28 +08:00
|
|
|
{% endif %}
|
2013-03-13 19:52:13 +08:00
|
|
|
|
2013-07-03 07:42:37 +08:00
|
|
|
{{ functional.handleInputs(fun) }}
|
|
|
|
{{ functional.composeWithExceptionHandler(fun) }}
|
|
|
|
{{ functional.handleOutputs(fun) }}
|
2013-03-13 19:52:13 +08:00
|
|
|
|
2013-07-03 07:42:37 +08:00
|
|
|
{% if fun|noutputs %}
|
2013-06-22 14:39:28 +08:00
|
|
|
// push the outputs back to matlab
|
2013-08-06 22:14:13 +08:00
|
|
|
for (size_t n = 0; n < static_cast<size_t>(std::max(nlhs,1)); ++n) {
|
2013-06-29 10:48:42 +08:00
|
|
|
plhs[n] = outputs[n].toMxArray().releaseOwnership();
|
2013-06-22 14:39:28 +08:00
|
|
|
}
|
2013-06-23 14:26:27 +08:00
|
|
|
{% endif %}
|
2013-03-13 19:52:13 +08:00
|
|
|
}
|