Merge pull request #2214 from cosminBoaca:add_returnDFVal_parallel_predict
This commit is contained in:
commit
9b9eadc941
@ -242,7 +242,7 @@ Predicts the response for input sample(s).
|
||||
|
||||
.. ocv:function:: float CvSVM::predict( const CvMat* sample, bool returnDFVal=false ) const
|
||||
|
||||
.. ocv:function:: float CvSVM::predict( const CvMat* samples, CvMat* results ) const
|
||||
.. ocv:function:: float CvSVM::predict( const CvMat* samples, CvMat* results, bool returnDFVal=false ) const
|
||||
|
||||
.. ocv:pyfunction:: cv2.SVM.predict(sample[, returnDFVal]) -> retval
|
||||
|
||||
|
@ -490,7 +490,7 @@ public:
|
||||
bool balanced=false );
|
||||
|
||||
virtual float predict( const CvMat* sample, bool returnDFVal=false ) const;
|
||||
virtual float predict( const CvMat* samples, CV_OUT CvMat* results ) const;
|
||||
virtual float predict( const CvMat* samples, CV_OUT CvMat* results, bool returnDFVal=false ) const;
|
||||
|
||||
CV_WRAP CvSVM( const cv::Mat& trainData, const cv::Mat& responses,
|
||||
const cv::Mat& varIdx=cv::Mat(), const cv::Mat& sampleIdx=cv::Mat(),
|
||||
|
@ -2194,18 +2194,20 @@ float CvSVM::predict( const CvMat* sample, bool returnDFVal ) const
|
||||
}
|
||||
|
||||
struct predict_body_svm : ParallelLoopBody {
|
||||
predict_body_svm(const CvSVM* _pointer, float* _result, const CvMat* _samples, CvMat* _results)
|
||||
predict_body_svm(const CvSVM* _pointer, float* _result, const CvMat* _samples, CvMat* _results, bool _returnDFVal)
|
||||
{
|
||||
pointer = _pointer;
|
||||
result = _result;
|
||||
samples = _samples;
|
||||
results = _results;
|
||||
returnDFVal = _returnDFVal;
|
||||
}
|
||||
|
||||
const CvSVM* pointer;
|
||||
float* result;
|
||||
const CvMat* samples;
|
||||
CvMat* results;
|
||||
bool returnDFVal;
|
||||
|
||||
void operator()( const cv::Range& range ) const
|
||||
{
|
||||
@ -2213,7 +2215,7 @@ struct predict_body_svm : ParallelLoopBody {
|
||||
{
|
||||
CvMat sample;
|
||||
cvGetRow( samples, &sample, i );
|
||||
int r = (int)pointer->predict(&sample);
|
||||
int r = (int)pointer->predict(&sample, returnDFVal);
|
||||
if (results)
|
||||
results->data.fl[i] = (float)r;
|
||||
if (i == 0)
|
||||
@ -2222,11 +2224,11 @@ struct predict_body_svm : ParallelLoopBody {
|
||||
}
|
||||
};
|
||||
|
||||
float CvSVM::predict(const CvMat* samples, CV_OUT CvMat* results) const
|
||||
float CvSVM::predict(const CvMat* samples, CV_OUT CvMat* results, bool returnDFVal) const
|
||||
{
|
||||
float result = 0;
|
||||
cv::parallel_for_(cv::Range(0, samples->rows),
|
||||
predict_body_svm(this, &result, samples, results)
|
||||
predict_body_svm(this, &result, samples, results, returnDFVal)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user