38 int id = rhs[0].toInt();
39 string method(rhs[1].toString());
42 if (method ==
"new") {
54 if (method ==
"delete") {
59 else if (method ==
"typeid") {
61 plhs[0] =
MxArray(
string(
typeid(*obj).name()));
63 else if (method ==
"clear") {
67 else if (method ==
"load") {
68 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
70 bool loadFromString =
false;
71 for (
int i=3; i<nrhs; i+=2) {
72 string key(rhs[i].toString());
74 objname = rhs[i+1].toString();
75 else if (key ==
"FromString")
76 loadFromString = rhs[i+1].toBool();
79 "Unrecognized option %s", key.
c_str());
81 obj_[id] = (loadFromString ?
82 Algorithm::loadFromString<StarDetector>(rhs[2].toString(), objname) :
83 Algorithm::load<StarDetector>(rhs[2].toString(), objname));
85 else if (method ==
"save") {
87 obj->
save(rhs[2].toString());
89 else if (method ==
"empty") {
93 else if (method ==
"getDefaultName") {
97 else if (method ==
"detect") {
98 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
99 if (rhs[2].isNumeric()) {
101 for (
int i=3; i<nrhs; i+=2) {
102 string key(rhs[i].toString());
104 mask = rhs[i+1].toMat(
CV_8U);
107 "Unrecognized option %s", key.
c_str());
111 obj->
detect(image, keypoints, mask);
114 else if (rhs[2].isCell()) {
116 for (
int i=3; i<nrhs; i+=2) {
117 string key(rhs[i].toString());
128 "Unrecognized option %s", key.
c_str());
139 obj->
detect(images, keypoints, masks);
152 "Unrecognized operation %s",method.
c_str());
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void detect(InputArray image, std::vector< KeyPoint > &keypoints, InputArray mask=noArray())
struct mxArray_tag mxArray
Forward declaration for mxArray.
map< int, Ptr< StarDetector > > obj_
Object container.
int last_id
Last object id to allocate.
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...
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
Common definitions for the features2d and xfeatures2d modules.
virtual String getDefaultName() const
cv::Ptr< cv::xfeatures2d::StarDetector > createStarDetector(std::vector< MxArray >::const_iterator first, std::vector< MxArray >::const_iterator last)
Create an instance of StarDetector using options in arguments.
Global constant definitions.
virtual bool empty() const
virtual void save(const String &filename) const