36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
43 rhs[2].toString(), rhs.
begin() + 3, rhs.
end());
53 if (method ==
"delete") {
58 else if (method ==
"clear") {
62 else if (method ==
"load") {
63 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
65 bool loadFromString =
false;
66 for (
int i=3; i<nrhs; i+=2) {
67 string key(rhs[i].toString());
69 objname = rhs[i+1].toString();
70 else if (key ==
"FromString")
71 loadFromString = rhs[i+1].toBool();
74 "Unrecognized option %s", key.
c_str());
83 FileStorage fs(rhs[2].toString(), FileStorage::READ +
84 (loadFromString ? FileStorage::MEMORY : 0));
93 else if (method ==
"save") {
95 obj->
save(rhs[2].toString());
97 else if (method ==
"empty") {
101 else if (method ==
"getDefaultName") {
105 else if (method ==
"estimateTransformation") {
108 if (rhs[2].isNumeric() && rhs[3].isNumeric()) {
114 else if (rhs[2].isCell() && rhs[3].isCell()) {
116 targetShape(rhs[3].toVector<Point2f>());
122 else if (method ==
"applyTransformation") {
124 float transformCost = 0;
125 if (rhs[2].isNumeric()) {
130 (nlhs>1 ? output :
noArray()));
135 else if (rhs[2].isCell() && rhs[3].isCell()) {
139 (nlhs>1 ? output :
noArray()));
143 plhs[0] =
MxArray(transformCost);
145 else if (method ==
"warpImage") {
146 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
150 for (
int i=3; i<nrhs; i+=2) {
151 string key(rhs[i].toString());
152 if (key ==
"Interpolation")
153 flags = (rhs[i+1].isChar()) ?
154 InterpType[rhs[i+1].toString()] : rhs[i+1].toInt();
155 else if (key ==
"BorderType")
156 borderMode = (rhs[i+1].isChar()) ?
157 BorderType[rhs[i+1].toString()] : rhs[i+1].toInt();
158 else if (key ==
"BorderValue")
159 borderValue = rhs[i+1].toScalar();
162 "Unrecognized option %s", key.
c_str());
164 Mat transformingImage(rhs[2].
toMat()),
166 obj->
warpImage(transformingImage, output,
167 flags, borderMode, borderValue);
170 else if (method ==
"get") {
172 string prop(rhs[2].toString());
173 if (prop ==
"RegularizationParameter") {
178 "Only supported for ThinPlateSplineShapeTransformer");
181 else if (prop ==
"FullAffine") {
185 "Only supported for AffineTransformer");
190 "Unrecognized property %s", prop.
c_str());
192 else if (method ==
"set") {
194 string prop(rhs[2].toString());
195 if (prop ==
"RegularizationParameter") {
200 "Only supported for ThinPlateSplineShapeTransformer");
203 else if (prop ==
"FullAffine") {
207 "Only supported for AffineTransformer");
212 "Unrecognized property %s", prop.
c_str());
216 "Unrecognized operation %s", method.
c_str());
Common definitions for the shape module.
cv::Ptr< cv::ShapeTransformer > create_ShapeTransformer(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of ShapeTransformer using options in arguments.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
const ConstMap< std::string, int > InterpType
Interpolation type map for option processing.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void read(const FileNode &fn)
Mat reshape(int cn, int rows=0) const
Ptr< Y > dynamicCast() const
InputOutputArray noArray()
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
const ConstMap< std::string, int > BorderType
Border type map for option processing.
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const