Issue 497
[zxing.git] / cpp / core / src / zxing / qrcode / detector / Detector.h
1 #ifndef __DETECTOR_H__\r
2 #define __DETECTOR_H__\r
3 \r
4 /*\r
5  *  Detector.h\r
6  *  zxing\r
7  *\r
8  *  Copyright 2010 ZXing authors All rights reserved.\r
9  *\r
10  * Licensed under the Apache License, Version 2.0 (the "License");\r
11  * you may not use this file except in compliance with the License.\r
12  * You may obtain a copy of the License at\r
13  *\r
14  *      http://www.apache.org/licenses/LICENSE-2.0\r
15  *\r
16  * Unless required by applicable law or agreed to in writing, software\r
17  * distributed under the License is distributed on an "AS IS" BASIS,\r
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
19  * See the License for the specific language governing permissions and\r
20  * limitations under the License.\r
21  */\r
22 \r
23 #include <zxing/common/Counted.h>\r
24 #include <zxing/common/DetectorResult.h>\r
25 #include <zxing/common/BitMatrix.h>\r
26 #include <zxing/qrcode/detector/AlignmentPattern.h>\r
27 #include <zxing/common/PerspectiveTransform.h>\r
28 \r
29 namespace zxing {\r
30 \r
31 class DecodeHints;\r
32 \r
33 namespace qrcode {\r
34 \r
35 class Detector : public Counted {\r
36 private:\r
37   Ref<BitMatrix> image_;\r
38 \r
39 protected:\r
40   Ref<BitMatrix> getImage();\r
41 \r
42   static Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform>);\r
43   static int computeDimension(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft,\r
44                               float moduleSize);\r
45   float calculateModuleSize(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft);\r
46   float calculateModuleSizeOneWay(Ref<ResultPoint> pattern, Ref<ResultPoint> otherPattern);\r
47   float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY);\r
48   float sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY);\r
49   Ref<AlignmentPattern> findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY,\r
50       float allowanceFactor);\r
51 public:\r
52 \r
53   virtual Ref<PerspectiveTransform> createTransform(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref <\r
54       ResultPoint > bottomLeft, Ref<ResultPoint> alignmentPattern, int dimension);\r
55 \r
56   Detector(Ref<BitMatrix> image);\r
57   Ref<DetectorResult> detect(DecodeHints const& hints);\r
58 };\r
59 }\r
60 }\r
61 \r
62 #endif // __DETECTOR_H__\r