Issue #2231: Attempt to fix segfault, when copying labels. LDA needed to be updated to generate the Wrapper correctly.
This commit is contained in:
@@ -464,9 +464,12 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
|
||||
// clear existing model data
|
||||
_labels.release();
|
||||
_projections.clear();
|
||||
// get the number of unique classes (provide a cv::Mat overloaded version?)
|
||||
// safely copy from cv::Mat to std::vector
|
||||
vector<int> ll;
|
||||
labels.copyTo(ll);
|
||||
for(unsigned int i = 0; i < labels.total(); i++) {
|
||||
ll.push_back(labels.at<int>(i));
|
||||
}
|
||||
// get the number of unique classes
|
||||
int C = (int) remove_dups(ll).size();
|
||||
// clip number of components to be a valid number
|
||||
if((_num_components <= 0) || (_num_components > (C-1)))
|
||||
|
@@ -975,10 +975,17 @@ void LDA::load(const FileStorage& fs) {
|
||||
fs["eigenvectors"] >> _eigenvectors;
|
||||
}
|
||||
|
||||
void LDA::lda(InputArray _src, InputArray _lbls) {
|
||||
void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
|
||||
// get data
|
||||
Mat src = _src.getMat();
|
||||
vector<int> labels = _lbls.getMat();
|
||||
vector<int> labels;
|
||||
// safely copy the labels
|
||||
{
|
||||
Mat tmp = _lbls.getMat();
|
||||
for(unsigned int i = 0; i < tmp.total(); i++) {
|
||||
labels.push_back(tmp.at<int>(i));
|
||||
}
|
||||
}
|
||||
// turn into row sampled matrix
|
||||
Mat data;
|
||||
// ensure working matrix is double precision
|
||||
@@ -1078,7 +1085,7 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
|
||||
_eigenvectors = Mat(_eigenvectors, Range::all(), Range(0, _num_components));
|
||||
}
|
||||
|
||||
void LDA::compute(InputArray _src, InputArray _lbls) {
|
||||
void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
|
||||
switch(_src.kind()) {
|
||||
case _InputArray::STD_VECTOR_MAT:
|
||||
lda(asRowMatrix(_src, CV_64FC1), _lbls);
|
||||
|
Reference in New Issue
Block a user