Fixed Android build warnings
authorAndrey Kamaev <no@email>
Tue, 27 Mar 2012 06:16:13 +0000 (06:16 +0000)
committerAndrey Kamaev <no@email>
Tue, 27 Mar 2012 06:16:13 +0000 (06:16 +0000)
modules/contrib/src/colormap.cpp
modules/contrib/src/facerec.cpp
modules/contrib/src/lda.cpp

index a5c84ed..eca78dc 100644 (file)
@@ -45,7 +45,7 @@ static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, Output
     vector<int> indices = _indices.getMat();
     _dst.create(src.rows, src.cols, src.type());
     Mat dst = _dst.getMat();
-    for(int idx = 0; idx < indices.size(); idx++) {
+    for(size_t idx = 0; idx < indices.size(); idx++) {
         Mat originalRow = src.row(indices[idx]);
         Mat sortedRow = dst.row(idx);
         originalRow.copyTo(sortedRow);
index e614064..d7a529d 100644 (file)
@@ -310,7 +310,7 @@ void Eigenfaces::train(InputArray src, InputArray _lbls) {
     // dimensionality of data
     //int d = data.cols;
     // assert there are as much samples as labels
-    if(n != labels.size())
+    if((size_t)n != labels.size())
         CV_Error(CV_StsBadArg, "The number of samples must equal the number of labels!");
     // clip number of components to be valid
     if((_num_components <= 0) || (_num_components > n))
@@ -336,7 +336,7 @@ int Eigenfaces::predict(InputArray _src) const {
     Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1));
     double minDist = DBL_MAX;
     int minClass = -1;
-    for(int sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
+    for(size_t sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
         double dist = norm(_projections[sampleIdx], q, NORM_L2);
         if(dist < minDist) {
             minDist = dist;
@@ -381,7 +381,7 @@ void Fisherfaces::train(InputArray src, InputArray _lbls) {
     int N = data.rows; // number of samples
     //int D = data.cols; // dimension of samples
     // assert correct data alignment
-    if(labels.size() != N)
+    if(labels.size() != (size_t)N)
         CV_Error(CV_StsUnsupportedFormat, "Labels must be given as integer (CV_32SC1).");
     // compute the Fisherfaces
     int C = remove_dups(labels).size(); // number of unique classes
@@ -415,7 +415,7 @@ int Fisherfaces::predict(InputArray _src) const {
     // find 1-nearest neighbor
     double minDist = DBL_MAX;
     int minClass = -1;
-    for(int sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
+    for(size_t sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
         double dist = norm(_projections[sampleIdx], q, NORM_L2);
         if(dist < minDist) {
             minDist = dist;
@@ -657,7 +657,7 @@ void LBPH::train(InputArray _src, InputArray _lbls) {
     // store given labels
     _labels = labels;
     // 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
@@ -686,7 +686,7 @@ int LBPH::predict(InputArray _src) const {
     // find 1-nearest neighbor
     double minDist = DBL_MAX;
     int 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) {
             minDist = dist;
index 591fa75..44eb493 100644 (file)
@@ -80,7 +80,7 @@ void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArra
     vector<int> indices = _indices.getMat();
     _dst.create(src.rows, src.cols, src.type());
     Mat dst = _dst.getMat();
-    for(int idx = 0; idx < indices.size(); idx++) {
+    for(size_t idx = 0; idx < indices.size(); idx++) {
         Mat originalCol = src.col(indices[idx]);
         Mat sortedCol = dst.col(idx);
         originalCol.copyTo(sortedCol);
@@ -169,7 +169,7 @@ Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src)
     int n = X.rows;
     int d = X.cols;
     // center the data if correct aligned sample mean is given
-    if(mean.total() == d)
+    if(mean.total() == (size_t)d)
         subtract(X, repeat(mean.reshape(1,1), n, 1), X);
     // finally calculate projection as Y = (X-mean)*W
     gemm(X, W, 1.0, Mat(), 0.0, Y);
@@ -196,8 +196,8 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
     gemm(Y,
             W,
             1.0,
-            (d == mean.total()) ? repeat(mean.reshape(1,1), n, 1) : Mat(),
-            (d == mean.total()) ? 1.0 : 0.0,
+            ((size_t)d == mean.total()) ? repeat(mean.reshape(1,1), n, 1) : Mat(),
+            ((size_t)d == mean.total()) ? 1.0 : 0.0,
             X,
             GEMM_2_T);
     return X;
@@ -296,7 +296,7 @@ private:
         
         double norm = 0.0;
         for (int i = 0; i < nn; i++) {
-            if (i < low | i > high) {
+            if (i < low || i > high) {
                 d[i] = H[i][i];
                 e[i] = 0.0;
             }
@@ -658,7 +658,7 @@ private:
                             y = H[i + 1][i];
                             vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;
                             vi = (d[i] - p) * 2.0 * q;
-                            if (vr == 0.0 & vi == 0.0) {
+                            if (vr == 0.0 && vi == 0.0) {
                                 vr = eps * norm * (std::abs(w) + std::abs(q) + std::abs(x)
                                                    + std::abs(y) + std::abs(z));
                             }
@@ -696,7 +696,7 @@ private:
         // Vectors of isolated roots
         
         for (int i = 0; i < nn; i++) {
-            if (i < low | i > high) {
+            if (i < low || i > high) {
                 for (int j = i; j < nn; j++) {
                     V[i][j] = H[i][j];
                 }
@@ -946,9 +946,9 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
     vector<int> mapped_labels(labels.size());
     vector<int> num2label = remove_dups(labels);
     map<int, int> label2num;
-    for (int i = 0; i < num2label.size(); i++)
+    for (size_t i = 0; i < num2label.size(); i++)
         label2num[num2label[i]] = i;
-    for (int i = 0; i < labels.size(); i++)
+    for (size_t i = 0; i < labels.size(); i++)
         mapped_labels[i] = label2num[labels[i]];
     // get sample size, dimension
     int N = data.rows;
@@ -956,7 +956,7 @@ void LDA::lda(InputArray _src, InputArray _lbls) {
     // number of unique labels
     int C = num2label.size();
     // throw error if less labels, than samples
-    if (labels.size() != N)
+    if (labels.size() != (size_t)N)
         CV_Error(CV_StsBadArg, "Error: The number of samples must equal the number of labels.");
     // warn if within-classes scatter matrix becomes singular
     if (N < D)