wrapped Algorithm class.

This commit is contained in:
Vadim Pisarevsky 2012-04-20 17:03:02 +00:00
parent 8b6d1f6e45
commit 9213bba48a
3 changed files with 72 additions and 13 deletions

View File

@ -4272,7 +4272,7 @@ template<typename _Tp> struct ParamType {};
/*!
Base class for high-level OpenCV algorithms
*/
class CV_EXPORTS Algorithm
class CV_EXPORTS_W Algorithm
{
public:
Algorithm();
@ -4281,13 +4281,22 @@ public:
template<typename _Tp> typename ParamType<_Tp>::member_type get(const string& name) const;
template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const;
void set(const string& name, int value);
void set(const string& name, double value);
void set(const string& name, bool value);
void set(const string& name, const string& value);
void set(const string& name, const Mat& value);
void set(const string& name, const vector<Mat>& value);
void set(const string& name, const Ptr<Algorithm>& value);
CV_WRAP int getInt(const string& name) const;
CV_WRAP double getDouble(const string& name) const;
CV_WRAP bool getBool(const string& name) const;
CV_WRAP string getString(const string& name) const;
CV_WRAP Mat getMat(const string& name) const;
CV_WRAP vector<Mat> getMatVector(const string& name) const;
CV_WRAP Ptr<Algorithm> getAlgorithm(const string& name) const;
CV_WRAP_AS(setInt) void set(const string& name, int value);
CV_WRAP_AS(setDouble) void set(const string& name, double value);
CV_WRAP_AS(setBool) void set(const string& name, bool value);
CV_WRAP_AS(setString) void set(const string& name, const string& value);
CV_WRAP_AS(setMat) void set(const string& name, const Mat& value);
CV_WRAP_AS(setMatVector) void set(const string& name, const vector<Mat>& value);
CV_WRAP_AS(setAlgorithm) void set(const string& name, const Ptr<Algorithm>& value);
void set(const char* name, int value);
void set(const char* name, double value);
@ -4297,10 +4306,10 @@ public:
void set(const char* name, const vector<Mat>& value);
void set(const char* name, const Ptr<Algorithm>& value);
string paramHelp(const string& name) const;
CV_WRAP string paramHelp(const string& name) const;
int paramType(const char* name) const;
int paramType(const string& name) const;
void getParams(vector<string>& names) const;
CV_WRAP int paramType(const string& name) const;
CV_WRAP void getParams(CV_OUT vector<string>& names) const;
virtual void write(FileStorage& fs) const;
@ -4310,8 +4319,8 @@ public:
typedef int (Algorithm::*Getter)() const;
typedef void (Algorithm::*Setter)(int);
static void getList(vector<string>& algorithms);
static Ptr<Algorithm> _create(const string& name);
CV_WRAP static void getList(CV_OUT vector<string>& algorithms);
CV_WRAP static Ptr<Algorithm> _create(const string& name);
template<typename _Tp> static Ptr<_Tp> create(const string& name);
virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; }

View File

@ -251,6 +251,41 @@ void Algorithm::set(const char* name, const Ptr<Algorithm>& value)
info()->set(this, name, ParamType<Algorithm>::type, &value);
}
int Algorithm::getInt(const string& name) const
{
return get<int>(name);
}
double Algorithm::getDouble(const string& name) const
{
return get<double>(name);
}
bool Algorithm::getBool(const string& name) const
{
return get<bool>(name);
}
string Algorithm::getString(const string& name) const
{
return get<string>(name);
}
Mat Algorithm::getMat(const string& name) const
{
return get<Mat>(name);
}
vector<Mat> Algorithm::getMatVector(const string& name) const
{
return get<vector<Mat> >(name);
}
Ptr<Algorithm> Algorithm::getAlgorithm(const string& name) const
{
return get<Algorithm>(name);
}
string Algorithm::paramHelp(const string& name) const
{
return info()->paramHelp(name.c_str());

View File

@ -86,11 +86,13 @@ typedef vector<Rect> vector_Rect;
typedef vector<KeyPoint> vector_KeyPoint;
typedef vector<Mat> vector_Mat;
typedef vector<DMatch> vector_DMatch;
typedef vector<string> vector_string;
typedef vector<vector<Point> > vector_vector_Point;
typedef vector<vector<Point2f> > vector_vector_Point2f;
typedef vector<vector<Point3f> > vector_vector_Point3f;
typedef vector<vector<DMatch> > vector_vector_DMatch;
typedef Ptr<Algorithm> Ptr_Algorithm;
typedef Ptr<FeatureDetector> Ptr_FeatureDetector;
typedef Ptr<DescriptorExtractor> Ptr_DescriptorExtractor;
typedef Ptr<DescriptorMatcher> Ptr_DescriptorMatcher;
@ -759,6 +761,19 @@ template<> struct pyopencvVecConverter<DMatch>
}
};
template<> struct pyopencvVecConverter<string>
{
static bool to(PyObject* obj, vector<string>& value, const char* name="<unknown>")
{
return pyopencv_to_generic_vec(obj, value, name);
}
static PyObject* from(const vector<string>& value)
{
return pyopencv_from_generic_vec(value);
}
};
static inline bool pyopencv_to(PyObject *obj, CvTermCriteria& dst, const char *name="<unknown>")
{