Commit 6d41507c45ad183bdf6d573780171e7f5a333b8a

Authored by Josh Klontz
1 parent 52e35c09

EBIF bug fixes

Showing 1 changed file with 6 additions and 5 deletions
openbr/plugins/ebif.cpp
... ... @@ -47,9 +47,10 @@ class EBIFTransform : public UntrainableTransform
47 47 float scaleFactor = 1;
48 48 for (int n=0; n<N; n++) {
49 49 Mat scale;
50   - const int width = src.m().cols / scaleFactor;
51   - const int height = src.m().rows / scaleFactor;
  50 + const int width = src.m().cols * scaleFactor;
  51 + const int height = src.m().rows * scaleFactor;
52 52 resize(src, scale, Size(width, height));
  53 + scale.convertTo(scale, CV_32F);
53 54 scales.append(scale);
54 55 scaleFactor /= sqrt(2.f);
55 56 }
... ... @@ -75,9 +76,9 @@ class EBIFTransform : public UntrainableTransform
75 76 const float val = features[m][i];
76 77 squaredSum += val * val;
77 78 }
78   - const float norm = sqrt(squaredSum + 0.001 /* Avoid division by zero */);
  79 + const float norm = 1/sqrt(squaredSum + 0.001 /* Avoid division by zero */);
79 80 for (int m=0; m<M; m++)
80   - features[m][i] /= norm;
  81 + features[m][i] *= norm;
81 82 }
82 83  
83 84 dst = OpenCVUtils::toMat(features);
... ... @@ -99,7 +100,7 @@ class EBIFTransform : public UntrainableTransform
99 100  
100 101 // Bottom values
101 102 for (int k=0; k<4; k++) {
102   - const float *data = bottom.ptr<float>(i+k, j);
  103 + const float *data = bottom.ptr<float>(4*i/3+k, 4*j/3);
103 104 for (int l=0; l<4; l++)
104 105 vals.append(data[l]);
105 106 }
... ...