return (hints & TRYHARDER_HINT);
}
+void DecodeHints::setResultPointCallback(Ref<ResultPointCallback> const& _callback) {
+ callback = _callback;
+}
+
+Ref<ResultPointCallback> DecodeHints::getResultPointCallback() const {
+ return callback;
+}
+
} /* namespace */
*/
#include <zxing/BarcodeFormat.h>
+#include <zxing/ResultPointCallback.h>
namespace zxing {
DecodeHintType hints;
+ Ref<ResultPointCallback> callback;
+
public:
static const DecodeHints PRODUCT_HINT;
void setTryHarder(bool toset);
bool getTryHarder() const;
+ void setResultPointCallback(Ref<ResultPointCallback> const&);
+ Ref<ResultPointCallback> getResultPointCallback() const;
+
};
}
#include <zxing/ResultPoint.h>
+namespace zxing {
+
+ResultPoint::~ResultPoint() {}
+
+}
protected:
ResultPoint() {}
public:
+ virtual ~ResultPoint();
+
virtual float getX() const = 0;
virtual float getY() const = 0;
};
--- /dev/null
+/*
+ * ResultPointCallback.cpp
+ * zxing
+ *
+ * Created by Christian Brunschen on 13/05/2008.
+ * Copyright 2008 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/ResultPointCallback.h>
+
+namespace zxing {
+
+ResultPointCallback::~ResultPointCallback() {}
+
+}
--- /dev/null
+#ifndef __RESULT_POINT_CALLBACK_H__
+#define __RESULT_POINT_CALLBACK_H__
+
+/*
+ * ResultPointCallback.h
+ * zxing
+ *
+ * Copyright 2010 ZXing authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zxing/common/Counted.h>
+
+namespace zxing {
+
+class ResultPoint;
+
+class ResultPointCallback : public Counted {
+protected:
+ ResultPointCallback() {}
+public:
+ virtual void foundPossibleResultPoint(ResultPoint const& point) = 0;
+ virtual ~ResultPointCallback();
+};
+
+}
+
+#endif // __RESULT_POINT_CALLBACK_H__
// Hadn't found this before; save it
tmp->retain();
possibleCenters_->push_back(tmp);
+ if (callback_ != 0) {
+ callback_->foundPossibleResultPoint(*tmp);
+ }
}
Ref<AlignmentPattern> result;
return result;
}
AlignmentPatternFinder::AlignmentPatternFinder(Ref<BitMatrix> image, size_t startX, size_t startY, size_t width,
- size_t height, float moduleSize) :
+ size_t height, float moduleSize,
+ Ref<ResultPointCallback>const& callback) :
image_(image), possibleCenters_(new vector<AlignmentPattern *> ()), startX_(startX), startY_(startY),
- width_(width), height_(height), moduleSize_(moduleSize) {
+ width_(width), height_(height), moduleSize_(moduleSize), callback_(callback) {
}
AlignmentPatternFinder::~AlignmentPatternFinder() {
#include "AlignmentPattern.h"
#include <zxing/common/Counted.h>
#include <zxing/common/BitMatrix.h>
+#include <zxing/ResultPointCallback.h>
#include <vector>
namespace zxing {
public:
AlignmentPatternFinder(Ref<BitMatrix> image, size_t startX, size_t startY, size_t width, size_t height,
- float moduleSize);
+ float moduleSize, Ref<ResultPointCallback>const& callback);
~AlignmentPatternFinder();
Ref<AlignmentPattern> find();
AlignmentPatternFinder(const AlignmentPatternFinder&);
AlignmentPatternFinder& operator =(const AlignmentPatternFinder&);
+ Ref<ResultPointCallback> callback_;
};
}
}
}\r
\r
Ref<DetectorResult> Detector::detect(DecodeHints const& hints) {\r
- FinderPatternFinder finder(image_);\r
+ callback_ = hints.getResultPointCallback();\r
+ FinderPatternFinder finder(image_, hints.getResultPointCallback());\r
Ref<FinderPatternInfo> info(finder.find(hints));\r
\r
Ref<FinderPattern> topLeft(info->getTopLeft());\r
int alignmentAreaBottomY = min((int)(image_->getHeight() - 1), estAlignmentY + allowance);\r
\r
AlignmentPatternFinder alignmentFinder(image_, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX\r
- - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize);\r
+ - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, callback_);\r
return alignmentFinder.find();\r
}\r
\r
#include <zxing/common/BitMatrix.h>\r
#include <zxing/qrcode/detector/AlignmentPattern.h>\r
#include <zxing/common/PerspectiveTransform.h>\r
+#include <zxing/ResultPointCallback.h>\r
\r
namespace zxing {\r
\r
class Detector : public Counted {\r
private:\r
Ref<BitMatrix> image_;\r
+ Ref<ResultPointCallback> callback_;\r
\r
protected:\r
Ref<BitMatrix> getImage();\r
if (!found) {
Ref<FinderPattern> newPattern(new FinderPattern(centerJ, centerI, estimatedModuleSize));
possibleCenters_.push_back(newPattern);
+ if (callback_ != 0) {
+ callback_->foundPossibleResultPoint(*newPattern);
+ }
}
return true;
}
return (float)sqrt(dx * dx + dy * dy);
}
-FinderPatternFinder::FinderPatternFinder(Ref<BitMatrix> image) :
- image_(image), possibleCenters_(), hasSkipped_(false) {
+FinderPatternFinder::FinderPatternFinder(Ref<BitMatrix> image,
+ Ref<ResultPointCallback>const& callback) :
+ image_(image), possibleCenters_(), hasSkipped_(false), callback_(callback) {
}
Ref<FinderPatternInfo> FinderPatternFinder::find(DecodeHints const& hints) {
#include <zxing/qrcode/detector/FinderPatternInfo.h>
#include <zxing/common/Counted.h>
#include <zxing/common/BitMatrix.h>
+#include <zxing/ResultPointCallback.h>
#include <vector>
namespace zxing {
std::vector<Ref<FinderPattern> > possibleCenters_;
bool hasSkipped_;
+ Ref<ResultPointCallback> callback_;
+
/** stateCount must be int[5] */
static float centerFromEnd(int* stateCount, int end);
static bool foundPatternCross(int* stateCount);
bool haveMultiplyConfirmedCenters();
std::vector<Ref<FinderPattern> > selectBestPatterns();
static std::vector<Ref<FinderPattern> > orderBestPatterns(std::vector<Ref<FinderPattern> > patterns);
-
public:
static float distance(Ref<ResultPoint> p1, Ref<ResultPoint> p2);
- FinderPatternFinder(Ref<BitMatrix> image);
+ FinderPatternFinder(Ref<BitMatrix> image, Ref<ResultPointCallback>const&);
Ref<FinderPatternInfo> find(DecodeHints const& hints);
};
}