tabs to spaces

git-svn-id: https://zxing.googlecode.com/svn/trunk@2487 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2012-10-29 22:33:14 +00:00
parent eb7b65365b
commit 036918d4c0

View file

@ -34,30 +34,30 @@
namespace math_utils = zxing::common::detector::math_utils;
namespace zxing {
namespace qrcode {
namespace qrcode {
using namespace std;
using namespace std;
Detector::Detector(Ref<BitMatrix> image) :
Detector::Detector(Ref<BitMatrix> image) :
image_(image) {
}
}
Ref<BitMatrix> Detector::getImage() const {
Ref<BitMatrix> Detector::getImage() const {
return image_;
}
}
Ref<ResultPointCallback> Detector::getResultPointCallback() const {
Ref<ResultPointCallback> Detector::getResultPointCallback() const {
return callback_;
}
}
Ref<DetectorResult> Detector::detect(DecodeHints const& hints) {
Ref<DetectorResult> Detector::detect(DecodeHints const& hints) {
callback_ = hints.getResultPointCallback();
FinderPatternFinder finder(image_, hints.getResultPointCallback());
Ref<FinderPatternInfo> info(finder.find(hints));
return processFinderPatternInfo(info);
}
}
Ref<DetectorResult> Detector::processFinderPatternInfo(Ref<FinderPatternInfo> info){
Ref<DetectorResult> Detector::processFinderPatternInfo(Ref<FinderPatternInfo> info){
Ref<FinderPattern> topLeft(info->getTopLeft());
Ref<FinderPattern> topRight(info->getTopRight());
Ref<FinderPattern> bottomLeft(info->getBottomLeft());
@ -114,9 +114,9 @@ Ref<DetectorResult> Detector::processFinderPatternInfo(Ref<FinderPatternInfo> in
Ref<DetectorResult> result(new DetectorResult(bits, points));
return result;
}
}
Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref <
Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref <
ResultPoint > bottomLeft, Ref<ResultPoint> alignmentPattern, int dimension) {
float dimMinusThree = (float)dimension - 3.5f;
@ -142,14 +142,14 @@ Ref<PerspectiveTransform> Detector::createTransform(Ref<ResultPoint> topLeft, Re
topRight->getY(), bottomRightX, bottomRightY, bottomLeft->getX(), bottomLeft->getY()));
return transform;
}
}
Ref<BitMatrix> Detector::sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform> transform) {
Ref<BitMatrix> Detector::sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform> transform) {
GridSampler &sampler = GridSampler::getInstance();
return sampler.sampleGrid(image, dimension, transform);
}
}
int Detector::computeDimension(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft,
int Detector::computeDimension(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft,
float moduleSize) {
int tltrCentersDimension =
math_utils::round(ResultPoint::distance(topLeft, topRight) / moduleSize);
@ -170,14 +170,14 @@ int Detector::computeDimension(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRig
throw zxing::ReaderException(s.str().c_str());
}
return dimension;
}
}
float Detector::calculateModuleSize(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft) {
float Detector::calculateModuleSize(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft) {
// Take the average
return (calculateModuleSizeOneWay(topLeft, topRight) + calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f;
}
}
float Detector::calculateModuleSizeOneWay(Ref<ResultPoint> pattern, Ref<ResultPoint> otherPattern) {
float Detector::calculateModuleSizeOneWay(Ref<ResultPoint> pattern, Ref<ResultPoint> otherPattern) {
float moduleSizeEst1 = sizeOfBlackWhiteBlackRunBothWays((int)pattern->getX(), (int)pattern->getY(),
(int)otherPattern->getX(), (int)otherPattern->getY());
float moduleSizeEst2 = sizeOfBlackWhiteBlackRunBothWays((int)otherPattern->getX(), (int)otherPattern->getY(),
@ -191,9 +191,9 @@ float Detector::calculateModuleSizeOneWay(Ref<ResultPoint> pattern, Ref<ResultPo
// Average them, and divide by 7 since we've counted the width of 3 black modules,
// and 1 white and 1 black module on either side. Ergo, divide sum by 14.
return (moduleSizeEst1 + moduleSizeEst2) / 14.0f;
}
}
float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) {
float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) {
float result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
@ -223,9 +223,9 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX,
// Middle pixel is double-counted this way; subtract 1
return result - 1.0f;
}
}
float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) {
float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) {
// Mild variant of Bresenham's algorithm;
// see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
bool steep = abs(toY - fromY) > abs(toX - fromX);
@ -277,9 +277,9 @@ float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY)
}
// else we didn't find even black-white-black; no estimate is really possible
return NAN;
}
}
Ref<AlignmentPattern> Detector::findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY,
Ref<AlignmentPattern> Detector::findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY,
float allowanceFactor) {
// Look for an alignment pattern (3 modules in size) around where it
// should be
@ -298,7 +298,7 @@ Ref<AlignmentPattern> Detector::findAlignmentInRegion(float overallEstModuleSize
AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX
- alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_);
return alignmentFinder.find();
}
}
}
}
}