9 #include "opencv2/photo.hpp" 16 (
"NormalClone", cv::NORMAL_CLONE)
17 (
"MixedClone", cv::MIXED_CLONE)
18 (
"MonochromeTransfer", cv::MONOCHROME_TRANSFER);
28 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
31 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
34 vector<MxArray> rhs(prhs, prhs+nrhs);
37 int flags = cv::NORMAL_CLONE;
39 for (
int i=4; i<nrhs; i+=2) {
40 string key(rhs[i].toString());
42 flags = CloningMethodMap[rhs[i+1].toString()];
43 else if (key ==
"FlipChannels")
44 flip = rhs[i+1].toBool();
46 mexErrMsgIdAndTxt(
"mexopencv:error",
47 "Unrecognized option %s", key.c_str());
51 Mat src(rhs[0].toMat(CV_8U)),
52 dst(rhs[1].toMat(CV_8U)),
53 mask(rhs[2].toMat(CV_8U)),
55 Point p(rhs[3].toPoint());
57 if (flip && src.channels() == 3)
58 cvtColor(src, src, cv::COLOR_RGB2BGR);
59 if (flip && dst.channels() == 3)
60 cvtColor(dst, dst, cv::COLOR_RGB2BGR);
61 if (flip && mask.channels() == 3)
62 cvtColor(mask, mask, cv::COLOR_RGB2BGR);
63 seamlessClone(src, dst, mask, p, blend, flags);
65 if (flip && blend.channels() == 3)
66 cvtColor(blend, blend, cv::COLOR_BGR2RGB);
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
std::map wrapper with one-line initialization and lookup method.