class_labels of SVM::trainAuto is not consistent with that of SVM::train (Bug #4464)
Description
To fix Bug #4030, in SVM.cpp Line 1672
Mat class_labels0 = class_labels;
and Line 1817
class_labels = class_labels0;
are deleted.
However, as a result, class_labels in the model trained by SVM::trainAuto are converted to int ranging from 0...class_count-1. But in SVM::train, the class_labels would be the original class_labels.
Actually, I find these two lines are necessary. The real problem is that when Mat class_labels0 = class_labels;
class_labels has no value. The value is assigned by class_labels = data->getClassLabels();
in the latter if-statement.
So after
// temporarily replace class labels with 0, 1, ..., NCLASSES-1 Mat(temp_class_labels).copyTo(class_labels);
class_labels0 does not preserve the orignial class_labels. Finally before the return statement, class_labels = class_labels0;
, now class_labels is lost.
My solution is to add class_labels.copyTo(class_labels0);
before Mat(temp_class_labels).copyTo(class_labels);
Related issues
related to Bug #4030: AutoTrain fail | Done | 2014-11-26 |
Associated revisions
History
Updated by Jie Yang over 9 years ago
Pull request: https://github.com/Itseez/opencv/pull/4174
- % Done changed from 0 to 50
- Status changed from Open to Incomplete
Updated by Jie Yang over 9 years ago
- % Done changed from 50 to 100
- Status changed from Incomplete to Done