Python wrapper is adapted for cv::String

This commit is contained in:
Andrey Kamaev
2013-03-20 20:42:07 +04:00
parent 2ad7b97f1c
commit 707d3e0a62
4 changed files with 24 additions and 11 deletions

View File

@@ -100,8 +100,6 @@ catch (const cv::Exception &e) \
using namespace cv;
typedef cv::softcascade::ChannelFeatureBuilder softcascade_ChannelFeatureBuilder;
typedef std::string string;
typedef std::vector<uchar> vector_uchar;
typedef std::vector<int> vector_int;
typedef std::vector<float> vector_float;
@@ -117,7 +115,7 @@ typedef std::vector<Rect> vector_Rect;
typedef std::vector<KeyPoint> vector_KeyPoint;
typedef std::vector<Mat> vector_Mat;
typedef std::vector<DMatch> vector_DMatch;
typedef std::vector<std::string> vector_string;
typedef std::vector<cv::String> vector_String;
typedef std::vector<std::vector<Point> > vector_vector_Point;
typedef std::vector<std::vector<Point2f> > vector_vector_Point2f;
typedef std::vector<std::vector<Point3f> > vector_vector_Point3f;
@@ -550,12 +548,12 @@ static PyObject* pyopencv_from(int64 value)
return PyLong_FromLongLong(value);
}
static PyObject* pyopencv_from(const std::string& value)
static PyObject* pyopencv_from(const cv::String& value)
{
return PyString_FromString(value.empty() ? "" : value.c_str());
}
static bool pyopencv_to(PyObject* obj, std::string& value, const char* name = "<unknown>")
static bool pyopencv_to(PyObject* obj, cv::String& value, const char* name = "<unknown>")
{
(void)name;
if(!obj || obj == Py_None)
@@ -563,7 +561,7 @@ static bool pyopencv_to(PyObject* obj, std::string& value, const char* name = "<
char* str = PyString_AsString(obj);
if(!str)
return false;
value = std::string(str);
value = cv::String(str);
return true;
}
@@ -906,14 +904,14 @@ template<> struct pyopencvVecConverter<DMatch>
}
};
template<> struct pyopencvVecConverter<std::string>
template<> struct pyopencvVecConverter<cv::String>
{
static bool to(PyObject* obj, std::vector<std::string>& value, const ArgInfo info)
static bool to(PyObject* obj, std::vector<cv::String>& value, const ArgInfo info)
{
return pyopencv_to_generic_vec(obj, value, info);
}
static PyObject* from(const std::vector<std::string>& value)
static PyObject* from(const std::vector<cv::String>& value)
{
return pyopencv_from_generic_vec(value);
}
@@ -994,7 +992,7 @@ static bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name
PyObject* item = PyList_GET_ITEM(values, i);
if( !PyString_Check(key) )
break;
std::string k = PyString_AsString(key);
cv::String k = PyString_AsString(key);
if( PyString_Check(item) )
{
const char* value = PyString_AsString(item);