mexopencv  0.1
mex interface for opencv library
Utils_.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
19 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
20 {
21  // Check the number of arguments
22  nargchk((nrhs==1 || nrhs==2) && nlhs<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26  string method(rhs[0].toString());
27 
28  // Operation switch
29  if (method == "checkHardwareSupport") {
30  nargchk(nrhs==1 && nlhs<=1);
32  s.set("MMX", checkHardwareSupport(CV_CPU_MMX));
33  s.set("SSE", checkHardwareSupport(CV_CPU_SSE));
34  s.set("SSE2", checkHardwareSupport(CV_CPU_SSE2));
35  s.set("SSE3", checkHardwareSupport(CV_CPU_SSE3));
36  s.set("SSSE3", checkHardwareSupport(CV_CPU_SSSE3));
37  s.set("SSE4_1", checkHardwareSupport(CV_CPU_SSE4_1));
38  s.set("SSE4_2", checkHardwareSupport(CV_CPU_SSE4_2));
39  s.set("POPCNT", checkHardwareSupport(CV_CPU_POPCNT));
40  s.set("AVX", checkHardwareSupport(CV_CPU_AVX));
41  s.set("AVX2", checkHardwareSupport(CV_CPU_AVX2));
42  s.set("FMA3", checkHardwareSupport(CV_CPU_FMA3));
43  s.set("AVX_512F", checkHardwareSupport(CV_CPU_AVX_512F));
44  s.set("AVX_512BW", checkHardwareSupport(CV_CPU_AVX_512BW));
45  s.set("AVX_512CD", checkHardwareSupport(CV_CPU_AVX_512CD));
46  s.set("AVX_512DQ", checkHardwareSupport(CV_CPU_AVX_512DQ));
47  s.set("AVX_512ER", checkHardwareSupport(CV_CPU_AVX_512ER));
48  s.set("AVX_512IFMA512", checkHardwareSupport(CV_CPU_AVX_512IFMA512));
49  s.set("AVX_512PF", checkHardwareSupport(CV_CPU_AVX_512PF));
50  s.set("AVX_512VBMI", checkHardwareSupport(CV_CPU_AVX_512VBMI));
51  s.set("AVX_512VL", checkHardwareSupport(CV_CPU_AVX_512VL));
52  s.set("NEON", checkHardwareSupport(CV_CPU_NEON));
53  plhs[0] = s;
54  }
55  else if (method == "getBuildInformation") {
56  nargchk(nrhs==1 && nlhs<=1);
57  plhs[0] = MxArray(getBuildInformation());
58  }
59  else if (method == "getNumberOfCPUs") {
60  nargchk(nrhs==1 && nlhs<=1);
61  plhs[0] = MxArray(getNumberOfCPUs());
62  }
63  else if (method == "getNumThreads") {
64  nargchk(nrhs==1 && nlhs<=1);
65  plhs[0] = MxArray(getNumThreads());
66  }
67  else if (method == "setNumThreads") {
68  nargchk(nrhs==2 && nlhs==0);
69  setNumThreads(rhs[1].toInt());
70  }
71  else if (method == "useOptimized") {
72  nargchk(nrhs==1 && nlhs<=1);
73  plhs[0] = MxArray(useOptimized());
74  }
75  else if (method == "setUseOptimized") {
76  nargchk(nrhs==2 && nlhs==0);
77  setUseOptimized(rhs[1].toBool());
78  }
79  else
80  mexErrMsgIdAndTxt("mexopencv:error",
81  "Unrecognized operation %s", method.c_str());
82 }
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
Definition: MxArray.hpp:1310
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Definition: Utils_.cpp:19
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
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
Definition: MxArray.hpp:312
Global constant definitions.