mexopencv  3.4.1
MEX interface for OpenCV library
cvtColorTwoPlane.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/imgproc.hpp"
10 using namespace std;
11 using namespace cv;
12 
13 namespace {
16  ("YUV2RGB_NV12", cv::COLOR_YUV2RGB_NV12)
17  ("YUV2BGR_NV12", cv::COLOR_YUV2BGR_NV12)
18  ("YUV2RGB_NV21", cv::COLOR_YUV2RGB_NV21)
19  ("YUV2BGR_NV21", cv::COLOR_YUV2BGR_NV21)
20  ("YUV420sp2RGB", cv::COLOR_YUV420sp2RGB)
21  ("YUV420sp2BGR", cv::COLOR_YUV420sp2BGR)
22  ("YUV2RGBA_NV12", cv::COLOR_YUV2RGBA_NV12)
23  ("YUV2BGRA_NV12", cv::COLOR_YUV2BGRA_NV12)
24  ("YUV2RGBA_NV21", cv::COLOR_YUV2RGBA_NV21)
25  ("YUV2BGRA_NV21", cv::COLOR_YUV2BGRA_NV21)
26  ("YUV420sp2RGBA", cv::COLOR_YUV420sp2RGBA)
27  ("YUV420sp2BGRA", cv::COLOR_YUV420sp2BGRA);
28 }
29 
37 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
38 {
39  // Check the number of arguments
40  nargchk(nrhs==3 && nlhs<=1);
41 
42  // Argument vector
43  vector<MxArray> rhs(prhs, prhs+nrhs);
44 
45  // Process
46  Mat ysrc(rhs[0].toMat(CV_8U)),
47  uvsrc(rhs[1].toMat(CV_8U)),
48  dst;
49  int code = ColorConv[rhs[2].toString()];
50  cvtColorTwoPlane(ysrc, uvsrc, dst, code);
51  plhs[0] = MxArray(dst);
52 }
COLOR_YUV2RGBA_NV12
COLOR_YUV2RGB_NV21
COLOR_YUV2BGRA_NV12
#define CV_8U
COLOR_YUV420sp2BGR
STL namespace.
void cvtColorTwoPlane(InputArray src1, InputArray src2, OutputArray dst, int code)
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.
COLOR_YUV420sp2BGRA
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
COLOR_YUV420sp2RGB
COLOR_YUV2BGR_NV12
COLOR_YUV2BGR_NV21
STL class.
Global constant definitions.
COLOR_YUV2BGRA_NV21
COLOR_YUV420sp2RGBA
COLOR_YUV2RGB_NV12
std::map wrapper with one-line initialization and lookup method.
Definition: MxArray.hpp:927
COLOR_YUV2RGBA_NV21
cv::Mat toMat() const
const ConstMap< string, int > ColorConv
Color conversion types for option processing.