#ifndef __DETECTOR_H__ #define __DETECTOR_H__ /* * Detector.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 #include #include #include #include namespace zxing { namespace pdf417 { namespace detector { class Detector { private: static const int INTEGER_MATH_SHIFT = 8; static const int PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT; static const int MAX_AVG_VARIANCE; static const int MAX_INDIVIDUAL_VARIANCE; static const int START_PATTERN[]; static const int START_PATTERN_LENGTH; static const int START_PATTERN_REVERSE[]; static const int START_PATTERN_REVERSE_LENGTH; static const int STOP_PATTERN[]; static const int STOP_PATTERN_LENGTH; static const int STOP_PATTERN_REVERSE[]; static const int STOP_PATTERN_REVERSE_LENGTH; Ref image_; static ArrayRef< Ref > findVertices(Ref matrix, int rowStep); static ArrayRef< Ref > findVertices180(Ref matrix, int rowStep); static ArrayRef findGuardPattern(Ref matrix, int column, int row, int width, bool whiteFirst, const int pattern[], int patternSize, ArrayRef& counters); static int patternMatchVariance(ArrayRef& counters, const int pattern[], int maxIndividualVariance); static void correctVertices(Ref matrix, ArrayRef< Ref >& vertices, bool upsideDown); static void findWideBarTopBottom(Ref matrix, ArrayRef< Ref >& vertices, int offsetVertice, int startWideBar, int lenWideBar, int lenPattern, int nIncrement); static void findCrossingPoint(ArrayRef< Ref >& vertices, int idxResult, int idxLineA1,int idxLineA2, int idxLineB1,int idxLineB2, Ref& matrix); static Point intersection(Line a, Line b); static float computeModuleWidth(ArrayRef< Ref >& vertices); static int computeDimension(Ref const& topLeft, Ref const& topRight, Ref const& bottomLeft, Ref const& bottomRight, float moduleWidth); int computeYDimension(Ref const& topLeft, Ref const& topRight, Ref const& bottomLeft, Ref const& bottomRight, float moduleWidth); Ref sampleLines(ArrayRef< Ref > const& vertices, int dimensionY, int dimension); public: Detector(Ref image); Ref getImage(); Ref detect(); Ref detect(DecodeHints const& hints); }; } } } #endif // __DETECTOR_H__