Fixed facerec_eigenfaces.cpp demo sample: it contained hardcoded values, which made wrong element access possible. Fixed unsigned integer/signed integer warnings in facerec.cpp.

pull/5/head
Philipp Wagner 13 years ago
parent f160c49473
commit 5983f8008f
  1. 3
      modules/contrib/doc/facerec/src/facerec_eigenfaces.cpp
  2. 10
      modules/contrib/src/facerec.cpp

@ -169,8 +169,9 @@ int main(int argc, const char *argv[]) {
imwrite(format("%s/eigenface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
}
}
// Display or save the image reconstruction at some predefined steps:
for(int num_components = 10; num_components < 300; num_components+=15) {
for(int num_components = min(W.cols, 10); num_components < min(W.cols, 300); num_components+=15) {
// slice the eigenvectors from the model
Mat evs = Mat(W, Range::all(), Range(0, num_components));
Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));

@ -751,11 +751,11 @@ void LBPH::train(InputArray _src, InputArray _lbls) {
CV_Error(CV_StsBadArg, error_message);
}
// append labels to _labels matrix
for(int labelIdx = 0; labelIdx < labels.total(); labelIdx++) {
_labels.push_back(labels.at<int>(labelIdx));
for(size_t labelIdx = 0; labelIdx < labels.total(); labelIdx++) {
_labels.push_back(labels.at<int>((int)labelIdx));
}
// store the spatial histograms of the original data
for(int sampleIdx = 0; sampleIdx < src.size(); sampleIdx++) {
for(size_t sampleIdx = 0; sampleIdx < src.size(); sampleIdx++) {
// calculate lbp image
Mat lbp_image = elbp(src[sampleIdx], _radius, _neighbors);
// get spatial histogram from this lbp image
@ -788,11 +788,11 @@ void LBPH::predict(InputArray _src, int &minClass, double &minDist) const {
// find 1-nearest neighbor
minDist = DBL_MAX;
minClass = -1;
for(int sampleIdx = 0; sampleIdx < _histograms.size(); sampleIdx++) {
for(size_t sampleIdx = 0; sampleIdx < _histograms.size(); sampleIdx++) {
double dist = compareHist(_histograms[sampleIdx], query, CV_COMP_CHISQR);
if((dist < minDist) && (dist < _threshold)) {
minDist = dist;
minClass = _labels.at<int>(sampleIdx);
minClass = _labels.at<int>((int) sampleIdx);
}
}
}

Loading…
Cancel
Save