Merge branch 'add_prob_result_bayes_classifier', remote-tracking branch 'upstream/master' into add_prob_result_bayes_classifier
This commit is contained in:
commit
e6f86ea39d
@ -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* 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
|
.. ocv:pyfunction:: cv2.SVM.predict(sample[, returnDFVal]) -> retval
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ public:
|
|||||||
bool balanced=false );
|
bool balanced=false );
|
||||||
|
|
||||||
virtual float predict( const CvMat* sample, bool returnDFVal=false ) const;
|
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,
|
CV_WRAP CvSVM( const cv::Mat& trainData, const cv::Mat& responses,
|
||||||
const cv::Mat& varIdx=cv::Mat(), const cv::Mat& sampleIdx=cv::Mat(),
|
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 {
|
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;
|
pointer = _pointer;
|
||||||
result = _result;
|
result = _result;
|
||||||
samples = _samples;
|
samples = _samples;
|
||||||
results = _results;
|
results = _results;
|
||||||
|
returnDFVal = _returnDFVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CvSVM* pointer;
|
const CvSVM* pointer;
|
||||||
float* result;
|
float* result;
|
||||||
const CvMat* samples;
|
const CvMat* samples;
|
||||||
CvMat* results;
|
CvMat* results;
|
||||||
|
bool returnDFVal;
|
||||||
|
|
||||||
void operator()( const cv::Range& range ) const
|
void operator()( const cv::Range& range ) const
|
||||||
{
|
{
|
||||||
@ -2213,7 +2215,7 @@ struct predict_body_svm : ParallelLoopBody {
|
|||||||
{
|
{
|
||||||
CvMat sample;
|
CvMat sample;
|
||||||
cvGetRow( samples, &sample, i );
|
cvGetRow( samples, &sample, i );
|
||||||
int r = (int)pointer->predict(&sample);
|
int r = (int)pointer->predict(&sample, returnDFVal);
|
||||||
if (results)
|
if (results)
|
||||||
results->data.fl[i] = (float)r;
|
results->data.fl[i] = (float)r;
|
||||||
if (i == 0)
|
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;
|
float result = 0;
|
||||||
cv::parallel_for_(cv::Range(0, samples->rows),
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void get_svm_detector(const SVM& svm, vector< float > & hog_detector );
|
|||||||
void convert_to_ml(const std::vector< cv::Mat > & train_samples, cv::Mat& trainData );
|
void convert_to_ml(const std::vector< cv::Mat > & train_samples, cv::Mat& trainData );
|
||||||
void load_images( const string & prefix, const string & filename, vector< Mat > & img_lst );
|
void load_images( const string & prefix, const string & filename, vector< Mat > & img_lst );
|
||||||
void sample_neg( const vector< Mat > & full_neg_lst, vector< Mat > & neg_lst, const Size & size );
|
void sample_neg( const vector< Mat > & full_neg_lst, vector< Mat > & neg_lst, const Size & size );
|
||||||
Mat get_hogdescriptor_visu(Mat& color_origImg, vector<float>& descriptorValues, const Size & size );
|
Mat get_hogdescriptor_visu(const Mat& color_origImg, vector<float>& descriptorValues, const Size & size );
|
||||||
void compute_hog( const vector< Mat > & img_lst, vector< Mat > & gradient_lst, const Size & size );
|
void compute_hog( const vector< Mat > & img_lst, vector< Mat > & gradient_lst, const Size & size );
|
||||||
void train_svm( const vector< Mat > & gradient_lst, const vector< int > & labels );
|
void train_svm( const vector< Mat > & gradient_lst, const vector< int > & labels );
|
||||||
void draw_locations( Mat & img, const vector< Rect > & locations, const Scalar & color );
|
void draw_locations( Mat & img, const vector< Rect > & locations, const Scalar & color );
|
||||||
@ -155,7 +155,7 @@ void sample_neg( const vector< Mat > & full_neg_lst, vector< Mat > & neg_lst, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// From http://www.juergenwiki.de/work/wiki/doku.php?id=public:hog_descriptor_computation_and_visualization
|
// From http://www.juergenwiki.de/work/wiki/doku.php?id=public:hog_descriptor_computation_and_visualization
|
||||||
Mat get_hogdescriptor_visu(Mat& color_origImg, vector<float>& descriptorValues, const Size & size )
|
Mat get_hogdescriptor_visu(const Mat& color_origImg, vector<float>& descriptorValues, const Size & size )
|
||||||
{
|
{
|
||||||
const int DIMX = size.width;
|
const int DIMX = size.width;
|
||||||
const int DIMY = size.height;
|
const int DIMY = size.height;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user