1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef _BC_DETECTOR_H_
8 #define _BC_DETECTOR_H_
9 class CBC_PDF417DetectorResult;
10 class CBC_BinaryBitmap;
11 class CBC_CommonBitMatrix;
12 class CBC_CommonBitArray;
13 class CBC_Detector {
14  public:
15   CBC_Detector();
16   virtual ~CBC_Detector();
17   static CBC_PDF417DetectorResult* detect(CBC_BinaryBitmap* image,
18                                           int32_t hints,
19                                           FX_BOOL multiple,
20                                           int32_t& e);
21   static void rotate180(CBC_CommonBitMatrix* bitMatrix);
22   static CBC_CommonBitArray* mirror(CBC_CommonBitArray* input,
23                                     CBC_CommonBitArray* result);
24 
25  private:
26   static int32_t INDEXES_START_PATTERN[];
27   static int32_t INDEXES_STOP_PATTERN[];
28   static int32_t INTEGER_MATH_SHIFT;
29   static int32_t PATTERN_MATCH_RESULT_SCALE_FACTOR;
30   static int32_t MAX_AVG_VARIANCE;
31   static int32_t MAX_INDIVIDUAL_VARIANCE;
32   static int32_t START_PATTERN[];
33   static int32_t STOP_PATTERN[];
34   static int32_t MAX_PIXEL_DRIFT;
35   static int32_t MAX_PATTERN_DRIFT;
36   static int32_t SKIPPED_ROW_COUNT_MAX;
37   static int32_t ROW_STEP;
38   static int32_t BARCODE_MIN_HEIGHT;
39   static CFX_PtrArray* detect(FX_BOOL multiple, CBC_CommonBitMatrix* bitMatrix);
40   static CFX_PtrArray* findVertices(CBC_CommonBitMatrix* matrix,
41                                     int32_t startRow,
42                                     int32_t startColumn);
43   static void copyToResult(CFX_PtrArray* result,
44                            CFX_PtrArray* tmpResult,
45                            int32_t* destinationIndexes,
46                            int32_t destinationLength);
47   static CFX_PtrArray* findRowsWithPattern(CBC_CommonBitMatrix* matrix,
48                                            int32_t height,
49                                            int32_t width,
50                                            int32_t startRow,
51                                            int32_t startColumn,
52                                            int32_t* pattern,
53                                            int32_t patternLength);
54   static CFX_Int32Array* findGuardPattern(CBC_CommonBitMatrix* matrix,
55                                           int32_t column,
56                                           int32_t row,
57                                           int32_t width,
58                                           FX_BOOL whiteFirst,
59                                           int32_t* pattern,
60                                           int32_t patternLength,
61                                           CFX_Int32Array& counters);
62   static int32_t patternMatchVariance(CFX_Int32Array& counters,
63                                       int32_t* pattern,
64                                       int32_t maxIndividualVariance);
65 };
66 #endif
67