mexopencv  0.1
mex interface for opencv library
inpaint2.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/xphoto.hpp"
10 using namespace std;
11 using namespace cv;
12 using namespace cv::xphoto;
13 
14 namespace {
16 const ConstMap<string,int> InpaintTypeMap = ConstMap<string,int>
17  ("ShiftMap", cv::xphoto::INPAINT_SHIFTMAP);
18 }
19 
27 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
28 {
29  // Check the number of arguments
30  nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
31 
32  // Argument vector
33  vector<MxArray> rhs(prhs, prhs+nrhs);
34 
35  // Option processing
36  int algorithmType = cv::xphoto::INPAINT_SHIFTMAP;
37  for (int i=2; i<nrhs; i+=2) {
38  string key(rhs[i].toString());
39  if (key == "Method")
40  algorithmType = InpaintTypeMap[rhs[i+1].toString()];
41  else
42  mexErrMsgIdAndTxt("mexopencv:error",
43  "Unrecognized option %s", key.c_str());
44  }
45 
46  // Process
47  Mat src(rhs[0].toMat()),
48  mask(rhs[1].toMat(CV_8U)),
49  dst;
50  cv::xphoto::inpaint(src, mask, dst, algorithmType);
51  plhs[0] = MxArray(dst);
52 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: inpaint2.cpp:27
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927