mexopencv  3.4.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 {
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 }
const ConstMap< string, int > InpaintTypeMap
Inpainting algorithm types for option processing.
Definition: inpaint2.cpp:16
#define CV_8U
STL namespace.
void inpaint(const Mat &src, const Mat &mask, Mat &dst, const int algorithmType)
struct mxArray_tag mxArray
Forward declaration for mxArray.
Definition: matrix.h:259
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: inpaint2.cpp:27
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...
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/output arguments number check.
Definition: mexopencv.hpp:181
STL class.
Global constant definitions.
T c_str(T... args)
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
cv::Mat toMat() const