Commit a51a8ad5 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed tickets #1301, #1303, #1305

parent 4c74b28e
......@@ -616,7 +616,7 @@ void FlannBasedMatcher::read( const FileNode& fn)
indexParams->setBool(name, (int) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,3):
indexParams->setAlgorithm(name, (int) ip[i]["value"]);
indexParams->setAlgorithm((int) ip[i]["value"]);
break;
};
}
......@@ -655,7 +655,7 @@ void FlannBasedMatcher::read( const FileNode& fn)
searchParams->setBool(name, (int) ip[i]["value"]);
break;
case CV_MAKETYPE(CV_USRTYPE1,3):
searchParams->setAlgorithm(name, (int) ip[i]["value"]);
searchParams->setAlgorithm((int) ip[i]["value"]);
break;
};
}
......
......@@ -53,8 +53,8 @@ namespace cv
namespace flann
{
using namespace cvflann;
using namespace cvflann;
struct CV_EXPORTS IndexParams
{
......@@ -70,7 +70,7 @@ struct CV_EXPORTS IndexParams
void setDouble(const std::string& key, double value);
void setFloat(const std::string& key, float value);
void setBool(const std::string& key, bool value);
void setAlgorithm(const std::string& key, int value);
void setAlgorithm(int value);
void getAll(std::vector<std::string>& names,
std::vector<int>& types,
......
......@@ -81,9 +81,9 @@ void IndexParams::setBool(const std::string& key, bool value)
setParam(*this, key, value);
}
void IndexParams::setAlgorithm(const std::string& key, int value)
void IndexParams::setAlgorithm(int value)
{
setParam(*this, key, (cvflann::flann_algorithm_t)value);
setParam(*this, "algorithm", (cvflann::flann_algorithm_t)value);
}
void IndexParams::getAll(std::vector<std::string>& names,
......@@ -293,7 +293,10 @@ template<typename Distance, typename IndexType> void
buildIndex_(void*& index, const Mat& data, const IndexParams& params, const Distance& dist = Distance())
{
typedef typename Distance::ElementType ElementType;
CV_Assert(DataType<ElementType>::type == data.type() && data.isContinuous());
if(DataType<ElementType>::type != data.type())
CV_Error_(CV_StsUnsupportedFormat, ("type=%d\n", data.type()));
if(!data.isContinuous())
CV_Error(CV_StsBadArg, "Only continuous arrays are supported");
::cvflann::Matrix<ElementType> dataset((ElementType*)data.data, data.rows, data.cols);
IndexType* _index = new IndexType(dataset, get_params(params), dist);
......
......@@ -286,8 +286,9 @@ namespace cv
///////////////////////////// Object Detection ////////////////////////////
CV_EXPORTS_W void groupRectangles(CV_IN_OUT vector<Rect>& rectList, int groupThreshold, double eps=0.2);
CV_EXPORTS_W void groupRectangles(CV_IN_OUT vector<Rect>& rectList, CV_OUT vector<int>& weights, int groupThreshold, double eps=0.2);
CV_EXPORTS void groupRectangles(CV_OUT CV_IN_OUT vector<Rect>& rectList, int groupThreshold, double eps=0.2);
CV_EXPORTS_W void groupRectangles(CV_OUT CV_IN_OUT vector<Rect>& rectList, CV_OUT vector<int>& weights, int groupThreshold, double eps=0.2);
CV_EXPORTS void groupRectangles( vector<Rect>& rectList, int groupThreshold, double eps, vector<int>* weights, vector<double>* levelWeights );
CV_EXPORTS void groupRectangles(vector<Rect>& rectList, vector<int>& rejectLevels,
vector<double>& levelWeights, int groupThreshold, double eps=0.2);
CV_EXPORTS void groupRectangles_meanshift(vector<Rect>& rectList, vector<double>& foundWeights, vector<double>& foundScales,
......@@ -430,8 +431,7 @@ protected:
Ptr<CvHaarClassifierCascade> oldCascade;
};
void CV_EXPORTS_W groupRectangles( vector<Rect>& rectList, int groupThreshold, double eps, vector<int>* weights, vector<double>* levelWeights );
//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
struct CV_EXPORTS_W HOGDescriptor
......@@ -473,7 +473,7 @@ public:
CV_WRAP bool checkDetectorSize() const;
CV_WRAP double getWinSigma() const;
CV_WRAP virtual void setSVMDetector(const vector<float>& _svmdetector);
CV_WRAP virtual void setSVMDetector(InputArray _svmdetector);
virtual bool read(FileNode& fn);
virtual void write(FileStorage& fs, const String& objname) const;
......
......@@ -83,9 +83,9 @@ bool HOGDescriptor::checkDetectorSize() const
detectorSize == descriptorSize + 1;
}
void HOGDescriptor::setSVMDetector(const vector<float>& _svmDetector)
void HOGDescriptor::setSVMDetector(InputArray _svmDetector)
{
svmDetector = _svmDetector;
_svmDetector.getMat().convertTo(svmDetector, CV_32F);
CV_Assert( checkDetectorSize() );
}
......
......@@ -762,11 +762,25 @@ static bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name
break;
std::string k = PyString_AsString(key);
if( PyString_Check(item) )
p.setString(k, PyString_AsString(item));
{
const char* value = PyString_AsString(item);
p.setString(k, value);
}
else if( PyBool_Check(item) )
p.setBool(k, item == Py_True);
else if( PyInt_Check(item) )
p.setInt(k, PyInt_AsLong(item));
{
int value = (int)PyInt_AsLong(item);
if( strcmp(k.c_str(), "algorithm") == 0 )
p.setAlgorithm(value);
else
p.setInt(k, value);
}
else if( PyFloat_Check(item) )
p.setDouble(k, PyFloat_AsDouble(item));
{
double value = PyFloat_AsDouble(item);
p.setDouble(k, value);
}
else
break;
}
......@@ -780,7 +794,7 @@ static bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name
static bool pyopencv_to(PyObject *o, cvflann::flann_distance_t& dist, const char *name="<unknown>")
{
int d = 0;
int d = (int)dist;
bool ok = pyopencv_to(o, d, name);
dist = (cvflann::flann_distance_t)d;
return ok;
......
......@@ -357,9 +357,9 @@ class FuncVariant(object):
continue
if a.returnarg:
outlist.append((a.name, argno))
if not a.inputarg or a.returnarg:
if a.isbig():
outarr_list.append((a.name, argno))
if (not a.inputarg or a.returnarg) and a.isbig():
outarr_list.append((a.name, argno))
if not a.inputarg:
continue
if not a.defval:
arglist.append((a.name, argno))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment