27 const char *fields[] = {
"angle",
"class_id",
"octave",
"pt",
"response",
28 "size",
"startPoint",
"endPoint",
"startPointInOctave",
29 "endPointInOctave",
"lineLength",
"numOfPixels"};
32 s.
set(
"angle", keylines[i].angle, i);
33 s.
set(
"class_id", keylines[i].class_id, i);
34 s.
set(
"octave", keylines[i].octave, i);
35 s.
set(
"pt", keylines[i].pt, i);
36 s.
set(
"response", keylines[i].response, i);
37 s.
set(
"size", keylines[i].
size, i);
38 s.
set(
"startPoint", keylines[i].getStartPoint(), i);
39 s.
set(
"endPoint", keylines[i].getEndPoint(), i);
40 s.
set(
"startPointInOctave", keylines[i].getStartPointInOctave(), i);
41 s.
set(
"endPointInOctave", keylines[i].getEndPointInOctave(), i);
42 s.
set(
"lineLength", keylines[i].lineLength, i);
43 s.
set(
"numOfPixels", keylines[i].numOfPixels, i);
55 for (
mwIndex i = 0; i < keylines.size(); ++i)
75 int id = rhs[0].toInt();
76 string method(rhs[1].toString());
79 if (method ==
"new") {
91 if (method ==
"delete") {
96 else if (method ==
"clear") {
100 else if (method ==
"load") {
101 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
103 bool loadFromString =
false;
104 for (
int i=3; i<nrhs; i+=2) {
105 string key(rhs[i].toString());
106 if (key ==
"ObjName")
107 objname = rhs[i+1].toString();
108 else if (key ==
"FromString")
109 loadFromString = rhs[i+1].toBool();
112 "Unrecognized option %s", key.
c_str());
121 FileStorage fs(rhs[2].toString(), FileStorage::READ +
122 (loadFromString ? FileStorage::MEMORY : 0));
131 else if (method ==
"save") {
133 obj->
save(rhs[2].toString());
135 else if (method ==
"empty") {
139 else if (method ==
"getDefaultName") {
143 else if (method ==
"detect") {
144 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
147 if (rhs[2].isNumeric()) {
149 for (
int i=3; i<nrhs; i+=2) {
150 string key(rhs[i].toString());
152 mask = rhs[i+1].toMat(
CV_8U);
153 else if (key ==
"Scale")
154 scale = rhs[i+1].toInt();
155 else if (key ==
"NumOctaves")
156 numOctaves = rhs[i+1].toInt();
159 "Unrecognized option %s", key.
c_str());
163 obj->
detect(image, keylines, scale, numOctaves, mask);
166 else if (rhs[2].isCell()) {
168 for (
int i=3; i<nrhs; i+=2) {
169 string key(rhs[i].toString());
178 else if (key ==
"Scale")
179 scale = rhs[i+1].toInt();
180 else if (key ==
"NumOctaves")
181 numOctaves = rhs[i+1].toInt();
184 "Unrecognized option %s", key.
c_str());
200 obj->
detect(images, keylines, scale, numOctaves, masks);
213 "Unrecognized operation %s",method.
c_str());
void detect(const Mat &image, std::vector< KeyLine > &keypoints, int scale, int numOctaves, const Mat &mask=Mat())
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.
MxArray toStruct(const vector< KeyLine > &keylines)
Convert keylines to struct array.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
void set(mwIndex index, const T &value)
Template for numeric array element write accessor.
map< int, Ptr< LSDDetector > > obj_
Object container.
virtual void read(const FileNode &fn)
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...
MxArray toCellOfStruct(const vector< vector< KeyLine > > &keylines)
Convert set of keylines to cell-array of struct-arrays.
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.
static MxArray Struct(const char **fields=NULL, int nfields=0, mwSize m=1, mwSize n=1)
Create a new struct array.
FileNode getFirstTopLevelNode() const
static MxArray Cell(mwSize m=1, mwSize n=1)
Create a new cell array.
virtual String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const
int last_id
Last object id to allocate.