39 int numDisparities = 0;
42 int speckleWindowSize = 0;
44 int disp12MaxDiff = -1;
46 int preFilterSize = 9;
47 int preFilterCap = 31;
48 int textureThreshold = 10;
49 int uniquenessRatio = 15;
50 int smallerBlockSize = 0;
53 for (; first != last; first += 2) {
54 string key(first->toString());
55 const MxArray& val = *(first + 1);
56 if (key ==
"NumDisparities")
57 numDisparities = val.
toInt();
58 else if (key ==
"BlockSize")
59 blockSize = val.toInt();
60 else if (key ==
"MinDisparity")
61 minDisparity = val.toInt();
62 else if (key ==
"SpeckleWindowSize")
63 speckleWindowSize = val.toInt();
64 else if (key ==
"SpeckleRange")
65 speckleRange = val.toInt();
66 else if (key ==
"Disp12MaxDiff")
67 disp12MaxDiff = val.toInt();
68 else if (key ==
"PreFilterType")
69 preFilterType = (val.isChar() ?
71 else if (key ==
"PreFilterSize")
72 preFilterSize = val.toInt();
73 else if (key ==
"PreFilterCap")
74 preFilterCap = val.toInt();
75 else if (key ==
"TextureThreshold")
76 textureThreshold = val.toInt();
77 else if (key ==
"UniquenessRatio")
78 uniquenessRatio = val.toInt();
79 else if (key ==
"SmallerBlockSize")
80 smallerBlockSize = val.toInt();
81 else if (key ==
"ROI1")
83 else if (key ==
"ROI2")
87 "Unrecognized option %s", key.c_str());
122 int id = rhs[0].toInt();
123 string method(rhs[1].toString());
126 if (method ==
"new") {
138 if (method ==
"delete") {
143 else if (method ==
"clear") {
147 else if (method ==
"save") {
149 obj->
save(rhs[2].toString());
151 else if (method ==
"load") {
152 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
154 bool loadFromString =
false;
155 for (
int i=3; i<nrhs; i+=2) {
156 string key(rhs[i].toString());
157 if (key ==
"ObjName")
158 objname = rhs[i+1].toString();
159 else if (key ==
"FromString")
160 loadFromString = rhs[i+1].toBool();
163 "Unrecognized option %s", key.
c_str());
165 obj_[id] = (loadFromString ?
166 Algorithm::loadFromString<StereoBM>(rhs[2].toString(), objname) :
167 Algorithm::load<StereoBM>(rhs[2].toString(), objname));
169 else if (method ==
"empty") {
173 else if (method ==
"getDefaultName") {
177 else if (method ==
"compute") {
185 else if (method ==
"get") {
187 string prop(rhs[2].toString());
188 if (prop ==
"NumDisparities")
190 else if (prop ==
"BlockSize")
192 else if (prop ==
"MinDisparity")
194 else if (prop ==
"SpeckleWindowSize")
196 else if (prop ==
"SpeckleRange")
198 else if (prop ==
"Disp12MaxDiff")
200 else if (prop ==
"PreFilterType")
202 else if (prop ==
"PreFilterSize")
204 else if (prop ==
"PreFilterCap")
206 else if (prop ==
"TextureThreshold")
208 else if (prop ==
"UniquenessRatio")
210 else if (prop ==
"SmallerBlockSize")
212 else if (prop ==
"ROI1")
214 else if (prop ==
"ROI2")
218 "Unrecognized property %s", prop.
c_str());
220 else if (method ==
"set") {
222 string prop(rhs[2].toString());
223 if (prop ==
"NumDisparities")
225 else if (prop ==
"BlockSize")
227 else if (prop ==
"MinDisparity")
229 else if (prop ==
"SpeckleWindowSize")
231 else if (prop ==
"SpeckleRange")
233 else if (prop ==
"Disp12MaxDiff")
235 else if (prop ==
"PreFilterType")
238 else if (prop ==
"PreFilterSize")
240 else if (prop ==
"PreFilterCap")
242 else if (prop ==
"TextureThreshold")
244 else if (prop ==
"UniquenessRatio")
246 else if (prop ==
"SmallerBlockSize")
248 else if (prop ==
"ROI1")
250 else if (prop ==
"ROI2")
254 "Unrecognized property %s", prop.
c_str());
258 "Unrecognized operation %s", method.
c_str());
virtual int getTextureThreshold() const=0
int toInt() const
Convert MxArray to int.
virtual int getPreFilterSize() const=0
virtual int getSpeckleRange() const=0
int last_id
Last object id to allocate.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual int getPreFilterType() const=0
virtual void setMinDisparity(int minDisparity)=0
PREFILTER_NORMALIZED_RESPONSE
virtual void compute(InputArray left, InputArray right, OutputArray disparity)=0
virtual void setSpeckleWindowSize(int speckleWindowSize)=0
const ConstMap< int, string > InvPreFilerTypeMap
virtual void setNumDisparities(int numDisparities)=0
struct mxArray_tag mxArray
Forward declaration for mxArray.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual Rect getROI1() const=0
virtual int getUniquenessRatio() const=0
virtual void setTextureThreshold(int textureThreshold)=0
virtual void setDisp12MaxDiff(int disp12MaxDiff)=0
virtual Rect getROI2() const=0
Ptr< StereoBM > create_StereoBM(vector< MxArray >::const_iterator first, vector< MxArray >::const_iterator last)
Create an instance of StereoBM using options in arguments.
virtual void setROI1(Rect roi1)=0
virtual void setSmallerBlockSize(int blockSize)=0
const ConstMap< string, int > PreFilerTypeMap
Option values for StereoBM PreFilterType.
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
virtual void setPreFilterCap(int preFilterCap)=0
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.
virtual int getSpeckleWindowSize() const=0
virtual int getBlockSize() const=0
virtual int getMinDisparity() const=0
virtual void setUniquenessRatio(int uniquenessRatio)=0
virtual String getDefaultName() const
Global constant definitions.
virtual int getDisp12MaxDiff() const=0
virtual void save(const String &filename) const
virtual bool empty() const
virtual void setROI2(Rect roi2)=0
virtual int getSmallerBlockSize() const=0
virtual int getPreFilterCap() const=0
map< int, Ptr< StereoBM > > obj_
Object container.
std::map wrapper with one-line initialization and lookup method.
virtual void setPreFilterSize(int preFilterSize)=0
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
virtual void setPreFilterType(int preFilterType)=0