From a57cd29c1209df97fa5954be4167e637b8f57ebc Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Mon, 1 Apr 2013 17:03:20 -0400 Subject: [PATCH] descriptor tweaks --- openbr/plugins/integral.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/openbr/plugins/integral.cpp b/openbr/plugins/integral.cpp index d6a54b1..adb8e55 100644 --- a/openbr/plugins/integral.cpp +++ b/openbr/plugins/integral.cpp @@ -167,22 +167,26 @@ class RecursiveIntegralSamplerTransform : public Transform void computeDescriptor(const Mat &src, Mat &dst) const { const int channels = src.channels(); - dst = Mat(7, channels, CV_32FC1); const int rows = src.rows-1; // Integral images have an extra row and column const int columns = src.cols-1; - integralHistogram(src, 0, 0, rows, columns, dst, 0); - Mat tmp(4, channels, CV_32FC1); + Mat tmp(5, channels, CV_32FC1); integralHistogram(src, 0, 0, rows/2, columns/2, tmp, 0); integralHistogram(src, 0, columns/2, rows/2, columns/2, tmp, 1); integralHistogram(src, rows/2, 0, rows/2, columns/2, tmp, 2); integralHistogram(src, rows/2, columns/2, rows/2, columns/2, tmp, 3); - OutputDescriptor(dst.ptr(1), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr(0), channels, 1) - SecondOrderInputDescriptor(tmp.ptr(1), channels, 1))/4.f; - OutputDescriptor(dst.ptr(2), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr(1), channels, 1) - SecondOrderInputDescriptor(tmp.ptr(3), channels, 1))/4.f; - OutputDescriptor(dst.ptr(3), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr(3), channels, 1) - SecondOrderInputDescriptor(tmp.ptr(2), channels, 1))/4.f; - OutputDescriptor(dst.ptr(4), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr(2), channels, 1) - SecondOrderInputDescriptor(tmp.ptr(0), channels, 1))/4.f; - OutputDescriptor(dst.ptr(5), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr(0), channels, 1) - SecondOrderInputDescriptor(tmp.ptr(3), channels, 1))/4.f; - OutputDescriptor(dst.ptr(6), channels, 1) = (SecondOrderInputDescriptor(tmp.ptr(1), channels, 1) - SecondOrderInputDescriptor(tmp.ptr(2), channels, 1))/4.f; + integralHistogram(src, rows/4, columns/4, rows/2, columns/2, tmp, 4); + const SecondOrderInputDescriptor a(tmp.ptr(0), channels, 1); + const SecondOrderInputDescriptor b(tmp.ptr(1), channels, 1); + const SecondOrderInputDescriptor c(tmp.ptr(2), channels, 1); + const SecondOrderInputDescriptor d(tmp.ptr(3), channels, 1); + const SecondOrderInputDescriptor e(tmp.ptr(4), channels, 1); + + dst = Mat(3, channels, CV_32FC1); + OutputDescriptor(dst.ptr(0), channels, 1) = (a+b+c+d)/4.f; + OutputDescriptor(dst.ptr(1), channels, 1) = ((a+b+c+d)/4.f-e); + OutputDescriptor(dst.ptr(2), channels, 1) = ((a+b)-(c+d))/2.f; + OutputDescriptor(dst.ptr(0), channels, 1) = ((a+c)-(b+d))/2.f; } Template subdivide(const Template &src) const -- libgit2 0.21.4