Commit a57cd29c1209df97fa5954be4167e637b8f57ebc

Authored by Josh Klontz
1 parent ae3b64a1

descriptor tweaks

Showing 1 changed file with 13 additions and 9 deletions
openbr/plugins/integral.cpp
@@ -167,22 +167,26 @@ class RecursiveIntegralSamplerTransform : public Transform @@ -167,22 +167,26 @@ class RecursiveIntegralSamplerTransform : public Transform
167 void computeDescriptor(const Mat &src, Mat &dst) const 167 void computeDescriptor(const Mat &src, Mat &dst) const
168 { 168 {
169 const int channels = src.channels(); 169 const int channels = src.channels();
170 - dst = Mat(7, channels, CV_32FC1);  
171 const int rows = src.rows-1; // Integral images have an extra row and column 170 const int rows = src.rows-1; // Integral images have an extra row and column
172 const int columns = src.cols-1; 171 const int columns = src.cols-1;
173 - integralHistogram(src, 0, 0, rows, columns, dst, 0);  
174 172
175 - Mat tmp(4, channels, CV_32FC1); 173 + Mat tmp(5, channels, CV_32FC1);
176 integralHistogram(src, 0, 0, rows/2, columns/2, tmp, 0); 174 integralHistogram(src, 0, 0, rows/2, columns/2, tmp, 0);
177 integralHistogram(src, 0, columns/2, rows/2, columns/2, tmp, 1); 175 integralHistogram(src, 0, columns/2, rows/2, columns/2, tmp, 1);
178 integralHistogram(src, rows/2, 0, rows/2, columns/2, tmp, 2); 176 integralHistogram(src, rows/2, 0, rows/2, columns/2, tmp, 2);
179 integralHistogram(src, rows/2, columns/2, rows/2, columns/2, tmp, 3); 177 integralHistogram(src, rows/2, columns/2, rows/2, columns/2, tmp, 3);
180 - OutputDescriptor(dst.ptr<float>(1), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr<float>(0), channels, 1) - SecondOrderInputDescriptor(tmp.ptr<float>(1), channels, 1))/4.f;  
181 - OutputDescriptor(dst.ptr<float>(2), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr<float>(1), channels, 1) - SecondOrderInputDescriptor(tmp.ptr<float>(3), channels, 1))/4.f;  
182 - OutputDescriptor(dst.ptr<float>(3), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr<float>(3), channels, 1) - SecondOrderInputDescriptor(tmp.ptr<float>(2), channels, 1))/4.f;  
183 - OutputDescriptor(dst.ptr<float>(4), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr<float>(2), channels, 1) - SecondOrderInputDescriptor(tmp.ptr<float>(0), channels, 1))/4.f;  
184 - OutputDescriptor(dst.ptr<float>(5), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr<float>(0), channels, 1) - SecondOrderInputDescriptor(tmp.ptr<float>(3), channels, 1))/4.f;  
185 - OutputDescriptor(dst.ptr<float>(6), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr<float>(1), channels, 1) - SecondOrderInputDescriptor(tmp.ptr<float>(2), channels, 1))/4.f; 178 + integralHistogram(src, rows/4, columns/4, rows/2, columns/2, tmp, 4);
  179 + const SecondOrderInputDescriptor a(tmp.ptr<float>(0), channels, 1);
  180 + const SecondOrderInputDescriptor b(tmp.ptr<float>(1), channels, 1);
  181 + const SecondOrderInputDescriptor c(tmp.ptr<float>(2), channels, 1);
  182 + const SecondOrderInputDescriptor d(tmp.ptr<float>(3), channels, 1);
  183 + const SecondOrderInputDescriptor e(tmp.ptr<float>(4), channels, 1);
  184 +
  185 + dst = Mat(3, channels, CV_32FC1);
  186 + OutputDescriptor(dst.ptr<float>(0), channels, 1) = (a+b+c+d)/4.f;
  187 + OutputDescriptor(dst.ptr<float>(1), channels, 1) = ((a+b+c+d)/4.f-e);
  188 + OutputDescriptor(dst.ptr<float>(2), channels, 1) = ((a+b)-(c+d))/2.f;
  189 + OutputDescriptor(dst.ptr<float>(0), channels, 1) = ((a+c)-(b+d))/2.f;
186 } 190 }
187 191
188 Template subdivide(const Template &src) const 192 Template subdivide(const Template &src) const