44 int numDisparities = 16;
48 int disp12MaxDiff = 0;
50 int uniquenessRatio = 0;
51 int speckleWindowSize = 0;
54 for (; first != last; first += 2) {
55 string key(first->toString());
56 const MxArray& val = *(first + 1);
57 if (key ==
"MinDisparity")
58 minDisparity = val.
toInt();
59 else if (key ==
"NumDisparities")
60 numDisparities = val.toInt();
61 else if (key ==
"BlockSize")
62 blockSize = val.toInt();
67 else if (key ==
"Disp12MaxDiff")
68 disp12MaxDiff = val.toInt();
69 else if (key ==
"PreFilterCap")
70 preFilterCap = val.toInt();
71 else if (key ==
"UniquenessRatio")
72 uniquenessRatio = val.toInt();
73 else if (key ==
"SpeckleWindowSize")
74 speckleWindowSize = val.toInt();
75 else if (key ==
"SpeckleRange")
76 speckleRange = val.toInt();
77 else if (key ==
"Mode")
78 mode = (val.isChar() ?
82 "Unrecognized option %s", key.c_str());
85 blockSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio,
86 speckleWindowSize, speckleRange, mode);
104 int id = rhs[0].toInt();
105 string method(rhs[1].toString());
108 if (method ==
"new") {
120 if (method ==
"delete") {
125 else if (method ==
"clear") {
129 else if (method ==
"save") {
131 obj->
save(rhs[2].toString());
133 else if (method ==
"load") {
134 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
136 bool loadFromString =
false;
137 for (
int i=3; i<nrhs; i+=2) {
138 string key(rhs[i].toString());
139 if (key ==
"ObjName")
140 objname = rhs[i+1].toString();
141 else if (key ==
"FromString")
142 loadFromString = rhs[i+1].toBool();
145 "Unrecognized option %s", key.
c_str());
147 obj_[id] = (loadFromString ?
148 Algorithm::loadFromString<StereoSGBM>(rhs[2].toString(), objname) :
149 Algorithm::load<StereoSGBM>(rhs[2].toString(), objname));
151 else if (method ==
"empty") {
155 else if (method ==
"getDefaultName") {
159 else if (method ==
"compute") {
167 else if (method ==
"get") {
169 string prop(rhs[2].toString());
170 if (prop ==
"MinDisparity")
172 else if (prop ==
"NumDisparities")
174 else if (prop ==
"BlockSize")
176 else if (prop ==
"P1")
178 else if (prop ==
"P2")
180 else if (prop ==
"Disp12MaxDiff")
182 else if (prop ==
"PreFilterCap")
184 else if (prop ==
"UniquenessRatio")
186 else if (prop ==
"SpeckleWindowSize")
188 else if (prop ==
"SpeckleRange")
190 else if (prop ==
"Mode")
194 "Unrecognized property %s", prop.
c_str());
196 else if (method ==
"set") {
198 string prop(rhs[2].toString());
199 if (prop ==
"MinDisparity")
201 else if (prop ==
"NumDisparities")
203 else if (prop ==
"BlockSize")
205 else if (prop ==
"P1")
206 obj->
setP1(rhs[3].toInt());
207 else if (prop ==
"P2")
208 obj->
setP2(rhs[3].toInt());
209 else if (prop ==
"Disp12MaxDiff")
211 else if (prop ==
"PreFilterCap")
213 else if (prop ==
"UniquenessRatio")
215 else if (prop ==
"SpeckleWindowSize")
217 else if (prop ==
"SpeckleRange")
219 else if (prop ==
"Mode")
224 "Unrecognized property %s", prop.
c_str());
228 "Unrecognized operation %s", method.
c_str());
int toInt() const
Convert MxArray to int.
virtual void setP2(int P2)=0
virtual int getSpeckleRange() const=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual int getP1() const=0
virtual void setMinDisparity(int minDisparity)=0
virtual int getMode() const=0
virtual void compute(InputArray left, InputArray right, OutputArray disparity)=0
virtual void setSpeckleWindowSize(int speckleWindowSize)=0
virtual void setUniquenessRatio(int uniquenessRatio)=0
virtual void setNumDisparities(int numDisparities)=0
struct mxArray_tag mxArray
Forward declaration for mxArray.
const ConstMap< string, int > SGBMModeMap
Option values for StereoSGBM mode.
virtual int getP2() const=0
virtual int getUniquenessRatio() const=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< int, string > InvSGBMModeMap
virtual void setDisp12MaxDiff(int disp12MaxDiff)=0
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...
virtual void setBlockSize(int blockSize)=0
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
int last_id
Last object id to allocate.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
virtual int getSpeckleWindowSize() const=0
virtual int getBlockSize() const=0
virtual int getMinDisparity() const=0
virtual void setMode(int mode)=0
virtual String getDefaultName() const
Global constant definitions.
Ptr< StereoSGBM > create_StereoSGBM(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of StereoSGBM using options in arguments.
virtual void setP1(int P1)=0
virtual int getDisp12MaxDiff() const=0
virtual void setPreFilterCap(int preFilterCap)=0
virtual void save(const String &filename) const
virtual bool empty() const
virtual int getPreFilterCap() const=0
std::map wrapper with one-line initialization and lookup method.
map< int, Ptr< StereoSGBM > > obj_
Object container.
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
virtual void setSpeckleRange(int speckleRange)=0
virtual int getNumDisparities() const=0