20 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
23 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=2);
26 vector<MxArray> rhs(prhs, prhs+nrhs);
29 bool symmetricGrid =
true;
30 bool clustering =
false;
31 Ptr<FeatureDetector> blobDetector;
32 for (
int i=2; i<nrhs; i+=2) {
33 string key(rhs[i].toString());
34 if (key==
"SymmetricGrid")
35 symmetricGrid = rhs[i+1].toBool();
36 else if (key==
"Clustering")
37 clustering = rhs[i+1].toBool();
38 else if (key==
"BlobDetector") {
39 if (rhs[i+1].isChar())
41 rhs.end(), rhs.end());
42 else if (rhs[i+1].isCell() && rhs[i+1].numel() >= 2) {
43 vector<MxArray> args(rhs[i+1].toVector<MxArray>());
45 args.begin() + 1, args.end());
48 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid arguments");
51 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
53 int flags = (symmetricGrid ? cv::CALIB_CB_SYMMETRIC_GRID :
54 cv::CALIB_CB_ASYMMETRIC_GRID) |
55 (clustering ? cv::CALIB_CB_CLUSTERING : 0);
56 if (blobDetector.empty())
57 blobDetector = SimpleBlobDetector::create();
60 Mat image(rhs[0].toMat(CV_8U));
61 Size patternSize(rhs[1].toSize());
62 vector<Point2f> centers;
63 bool patternFound = findCirclesGrid(image, patternSize, centers, flags,
67 plhs[1] =
MxArray(patternFound);
cv::Ptr< cv::FeatureDetector > createFeatureDetector(const std::string &type, std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Factory function for FeatureDetector creation.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Common definitions for the features2d and xfeatures2d modules.
Global constant definitions.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.