Issue 505
[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 #include <zxing/ResultPointCallback.h>\r
29 \r
30 namespace zxing {\r
31 \r
32 class DecodeHints;\r
33 \r
34 namespace qrcode {\r
35 \r
36 class Detector : public Counted {\r
37 private:\r
38   Ref<BitMatrix> image_;\r
39   Ref<ResultPointCallback> callback_;\r
40 \r
41 protected:\r
42   Ref<BitMatrix> getImage();\r
43 \r
44   static Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform>);\r
45   static int computeDimension(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft,\r
46                               float moduleSize);\r
47   float calculateModuleSize(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft);\r
48   float calculateModuleSizeOneWay(Ref<ResultPoint> pattern, Ref<ResultPoint> otherPattern);\r
49   float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY);\r
50   float sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY);\r
51   Ref<AlignmentPattern> findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY,\r
52       float allowanceFactor);\r
53 public:\r
54 \r
55   virtual Ref<PerspectiveTransform> createTransform(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref <\r
56       ResultPoint > bottomLeft, Ref<ResultPoint> alignmentPattern, int dimension);\r
57 \r
58   Detector(Ref<BitMatrix> image);\r
59   Ref<DetectorResult> detect(DecodeHints const& hints);\r
60 };\r
61 }\r
62 }\r
63 \r
64 #endif // __DETECTOR_H__\r