From 52262cb0d226c3ffb175e5a09dac9d6781e2d8bd Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Tue, 27 Sep 2016 02:08:03 +0300 Subject: [PATCH] better aligned implementation of WhiteRectangleDetector with the Java implementation --- .../detector/WhiteRectangleDetector.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/zxing/zxing/common/detector/WhiteRectangleDetector.cpp b/src/zxing/zxing/common/detector/WhiteRectangleDetector.cpp index 88e6796..19b7399 100644 --- a/src/zxing/zxing/common/detector/WhiteRectangleDetector.cpp +++ b/src/zxing/zxing/common/detector/WhiteRectangleDetector.cpp @@ -33,21 +33,23 @@ using zxing::common::detector::MathUtils; // VC++ using zxing::BitMatrix; -int WhiteRectangleDetector::INIT_SIZE = 30; +int WhiteRectangleDetector::INIT_SIZE = 30; //note, why 30, not 10 int WhiteRectangleDetector::CORR = 1; -WhiteRectangleDetector::WhiteRectangleDetector(Ref image) : image_(image) { - width_ = image->getWidth(); - height_ = image->getHeight(); +WhiteRectangleDetector::WhiteRectangleDetector(Ref image) : + WhiteRectangleDetector(image, INIT_SIZE, image->getWidth() >> 1, image->getHeight() >> 1) +{ +//// width_ = image->getWidth(); +//// height_ = image->getHeight(); - leftInit_ = (width_ - INIT_SIZE) >> 1; - rightInit_ = (width_ + INIT_SIZE) >> 1; - upInit_ = (height_ - INIT_SIZE) >> 1; - downInit_ = (height_ + INIT_SIZE) >> 1; +//// leftInit_ = (width_ - INIT_SIZE) >> 1; +//// rightInit_ = (width_ + INIT_SIZE) >> 1; +//// upInit_ = (height_ - INIT_SIZE) >> 1; +//// downInit_ = (height_ + INIT_SIZE) >> 1; - if (upInit_ < 0 || leftInit_ < 0 || downInit_ >= height_ || rightInit_ >= width_) { - throw NotFoundException("Invalid dimensions WhiteRectangleDetector"); -} +// if (upInit_ < 0 || leftInit_ < 0 || downInit_ >= height_ || rightInit_ >= width_) { +// throw NotFoundException("Invalid dimensions WhiteRectangleDetector"); +//} } WhiteRectangleDetector::WhiteRectangleDetector(Ref image, int initSize, int x, int y) : image_(image) {