// Another minor generalization over Haar features allowing multiple // black and white areas at the same time // (It's only actually different from combining multiple Haar features // when l(rBlack) != l(rWhite).) // // Result classification, as always: // // positive = match // 0 = non-match (indifferent/not applicable) // negative = anti-match (inverted Haar feature found) srecord MultiHaar(IIntegralImage img, L rBlack, L rWhite) { double get() { double blackArea = totalAreaOfDoubleRects(rBlack); double whiteArea = totalAreaOfDoubleRects(rWhite); double whiteSum = 0, blackSum = 0; for (DoubleRect r : rWhite) whiteSum += img.pixelSum(r); for (DoubleRect r : rBlack) blackSum += img.pixelSum(r); ret (doubleRatio(whiteSum, whiteArea) - doubleRatio(blackSum, blackArea))/255.0; } }