2013-06-22 02:33:24 +02:00
{ % import ' functional . cpp ' as functional % }
2013-03-13 12:52:13 +01:00
/*
* file : { { fun . name } } . cpp
* author : A trusty code generator
2013-03-18 03:37:42 +01:00
* date : { { time . strftime ( " %a, %d %b %Y %H:%M:%S " , time . localtime ( ) ) } }
2013-03-13 12:52:13 +01:00
*
* This file was autogenerated , do not modify .
* See LICENCE for full modification and redistribution details .
2013-03-18 03:37:42 +01:00
* Copyright { { time . strftime ( " %Y " , time . localtime ( ) ) } } The OpenCV Foundation
2013-03-13 12:52:13 +01:00
*/
# include "mex.h"
# include "bridge.hpp"
2013-06-19 03:54:14 +02:00
# include <string>
2013-03-13 12:52:13 +01:00
# include <vector>
2013-06-24 21:42:28 +02:00
# include <cassert>
2013-06-19 08:37:57 +02:00
# include <exception>
2013-06-22 07:55:48 +02:00
# include <opencv2/{{includes}}.hpp>
2013-06-22 21:38:40 +02:00
using namespace cv ;
2013-03-13 12:52:13 +01:00
/*
* { { fun . name } }
2013-06-22 07:55:48 +02:00
* { { fun } }
2013-03-18 01:35:43 +01:00
* Gateway routine
2013-03-13 12:52:13 +01:00
* nlhs - number of return arguments
* plhs - pointers to return arguments
* nrhs - number of input arguments
* prhs - pointers to input arguments
*/
2013-06-29 23:24:53 +02: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 12:52:13 +01:00
2013-06-22 02:33:24 +02:00
// assertions
2013-06-24 22:11:29 +02:00
conditionalError ( nrhs > = { { fun . req | length - fun . req | only | outputs | length } } , " Too few required input arguments specified " ) ;
conditionalError ( nrhs < = { { fun . req | length + fun . opt | length - fun . req | only | outputs | length - fun . opt | only | outputs | length } } , " Too many input arguments specified " ) ;
2013-06-24 21:42:28 +02:00
conditionalError ( nlhs < = { { fun . rtp | void | not + fun . req | outputs | length + fun . opt | outputs | length } } , " Too many output arguments specified " ) ;
2013-03-13 12:52:13 +01:00
2013-06-29 23:24:53 +02:00
{ % if fun | ninputs or fun | noutputs % }
2013-06-22 02:33:24 +02:00
// setup
2013-06-29 23:24:53 +02:00
{ % if fun | ninputs % }
2013-06-29 09:19:08 +02:00
std : : vector < Bridge > inputs ( prhs , prhs + nrhs ) ;
2013-06-29 23:24:53 +02:00
{ % endif - % }
{ % - if fun | noutputs % }
std : : vector < Bridge > outputs ( { { fun | noutputs } } ) ;
{ % endif % }
2013-06-22 08:39:28 +02:00
{ % endif % }
2013-03-13 12:52:13 +01:00
2013-07-03 01:42:37 +02:00
{ { functional . handleInputs ( fun ) } }
{ { functional . composeWithExceptionHandler ( fun ) } }
{ { functional . handleOutputs ( fun ) } }
2013-03-13 12:52:13 +01:00
2013-07-03 01:42:37 +02:00
{ % if fun | noutputs % }
2013-06-22 08:39:28 +02:00
// push the outputs back to matlab
2013-08-06 16:14:13 +02:00
for ( size_t n = 0 ; n < static_cast < size_t > ( std : : max ( nlhs , 1 ) ) ; + + n ) {
2013-06-29 04:48:42 +02:00
plhs [ n ] = outputs [ n ] . toMxArray ( ) . releaseOwnership ( ) ;
2013-06-22 08:39:28 +02:00
}
2013-06-23 08:26:27 +02:00
{ % endif % }
2013-03-13 12:52:13 +01:00
}
2013-07-02 01:33:55 +02:00