FinderPatternFinder.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
  2. #ifndef __FINDER_PATTERN_FINDER_H__
  3. #define __FINDER_PATTERN_FINDER_H__
  4. /*
  5. * FinderPatternFinder.h
  6. * zxing
  7. *
  8. * Copyright 2010 ZXing authors All rights reserved.
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. */
  22. #include <zxing/qrcode/detector/FinderPattern.h>
  23. #include <zxing/qrcode/detector/FinderPatternInfo.h>
  24. #include <zxing/common/Counted.h>
  25. #include <zxing/common/BitMatrix.h>
  26. #include <zxing/ResultPointCallback.h>
  27. #include <vector>
  28. namespace zxing {
  29. class DecodeHints;
  30. namespace qrcode {
  31. class FinderPatternFinder {
  32. private:
  33. static int CENTER_QUORUM;
  34. protected:
  35. static int MIN_SKIP;
  36. static int MAX_MODULES;
  37. Ref<BitMatrix> image_;
  38. std::vector<Ref<FinderPattern> > possibleCenters_;
  39. bool hasSkipped_;
  40. Ref<ResultPointCallback> callback_;
  41. /** stateCount must be int[5] */
  42. static float centerFromEnd(int* stateCount, int end);
  43. static bool foundPatternCross(int* stateCount);
  44. float crossCheckVertical(size_t startI, size_t centerJ, int maxCount, int originalStateCountTotal);
  45. float crossCheckHorizontal(size_t startJ, size_t centerI, int maxCount, int originalStateCountTotal);
  46. /** stateCount must be int[5] */
  47. bool handlePossibleCenter(int* stateCount, size_t i, size_t j);
  48. int findRowSkip();
  49. bool haveMultiplyConfirmedCenters();
  50. std::vector<Ref<FinderPattern> > selectBestPatterns();
  51. static std::vector<Ref<FinderPattern> > orderBestPatterns(std::vector<Ref<FinderPattern> > patterns);
  52. Ref<BitMatrix> getImage();
  53. std::vector<Ref<FinderPattern> >& getPossibleCenters();
  54. bool confirmCenter45(float estimatedModuleSize,float centerI,float centerJ);
  55. bool confirmCenter135(float estimatedModuleSize,float centerI,float centerJ);
  56. public:
  57. static float distance(Ref<ResultPoint> p1, Ref<ResultPoint> p2);
  58. FinderPatternFinder(Ref<BitMatrix> image, Ref<ResultPointCallback>const&);
  59. Ref<FinderPatternInfo> find(DecodeHints const& hints);
  60. };
  61. }
  62. }
  63. #endif // __FINDER_PATTERN_FINDER_H__