Issue 1437 part 2, use cmath but use abs() again

git-svn-id: https://zxing.googlecode.com/svn/trunk@2557 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2013-01-17 20:45:39 +00:00
parent dc37cbadba
commit 890db6b427

View file

@ -15,7 +15,7 @@
*/
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <zxing/multi/qrcode/detector/MultiFinderPatternFinder.h>
#include <zxing/DecodeHints.h>
@ -171,7 +171,7 @@ std::vector<std::vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectB
Ref<FinderPattern> p2 = possibleCenters[i2];
// Compare the expected module sizes; if they are really off, skip
float vModSize12 = (p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize()) / std::min(p1->getEstimatedModuleSize(), p2->getEstimatedModuleSize());
float vModSize12A = fabs(p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize());
float vModSize12A = abs(p1->getEstimatedModuleSize() - p2->getEstimatedModuleSize());
if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
// break, since elements are ordered by the module size deviation there cannot be
// any more interesting elements for the given p1.
@ -181,7 +181,7 @@ std::vector<std::vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectB
Ref<FinderPattern> p3 = possibleCenters[i3];
// Compare the expected module sizes; if they are really off, skip
float vModSize23 = (p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize()) / std::min(p2->getEstimatedModuleSize(), p3->getEstimatedModuleSize());
float vModSize23A = fabs(p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize());
float vModSize23A = abs(p2->getEstimatedModuleSize() - p3->getEstimatedModuleSize());
if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
// break, since elements are ordered by the module size deviation there cannot be
// any more interesting elements for the given p1.
@ -203,14 +203,14 @@ std::vector<std::vector<Ref<FinderPattern> > > MultiFinderPatternFinder::selectB
continue;
}
// Calculate the difference of the edge lengths in percent
float vABBC = fabs((dA - dB) / std::min(dA, dB));
float vABBC = abs((dA - dB) / std::min(dA, dB));
if (vABBC >= 0.1f) {
continue;
}
// Calculate the diagonal length by assuming a 90° angle at topleft
float dCpy = (float) sqrt(dA * dA + dB * dB);
// Compare to the real distance in %
float vPyC = fabs((dC - dCpy) / std::min(dC, dCpy));
float vPyC = abs((dC - dCpy) / std::min(dC, dCpy));
if (vPyC >= 0.1f) {
continue;
}