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