saving untrained SVM model (Bug #3462)
Description
Trying to save a newly created SVM model before training it will result in a crash. Example:
#include "opencv2/opencv.hpp" #include "opencv2/ml/ml.hpp" using namespace cv; int main() { Ptr<SVM> svm = new SVM(); svm->save("svm.xml"); return 0; }
The offending code: https://github.com/Itseez/opencv/blob/2.4/modules/ml/src/svm.cpp#L2353 (df
is uninitialized but df_count
gets set to 1
on line 2347). A possible fix is to set df_count=0
in case class_count == 0
, thus not entering the loop..
This was initially reported on Stack Overflow: http://stackoverflow.com/a/20811401
History
Updated by Daniil Osokin about 11 years ago
- Target version set to 2.4.9
- Pull request set to https://github.com/Itseez/opencv/pull/2140
- Affected version changed from 2.4.7 (latest release) to branch '2.4' (2.4-dev)
- Assignee changed from Maria Dimashova to Daniil Osokin
Updated by Andrew Senin about 11 years ago
- Status changed from New to Open
Updated by Alexander Smorkalov almost 11 years ago
- Status changed from Open to Done