Detector.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
  2. #ifndef __DETECTOR_H__
  3. #define __DETECTOR_H__
  4. /*
  5. * Detector.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/common/Counted.h>
  23. #include <zxing/common/DetectorResult.h>
  24. #include <zxing/common/BitMatrix.h>
  25. #include <zxing/qrcode/detector/AlignmentPattern.h>
  26. #include <zxing/common/PerspectiveTransform.h>
  27. #include <zxing/ResultPointCallback.h>
  28. #include <zxing/qrcode/detector/FinderPatternInfo.h>
  29. namespace zxing {
  30. class DecodeHints;
  31. namespace qrcode {
  32. class Detector : public Counted {
  33. private:
  34. Ref<BitMatrix> image_;
  35. Ref<ResultPointCallback> callback_;
  36. protected:
  37. Ref<BitMatrix> getImage() const;
  38. Ref<ResultPointCallback> getResultPointCallback() const;
  39. static Ref<BitMatrix> sampleGrid(Ref<BitMatrix> image, int dimension, Ref<PerspectiveTransform>);
  40. static int computeDimension(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft,
  41. float moduleSize);
  42. float calculateModuleSize(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref<ResultPoint> bottomLeft);
  43. float calculateModuleSizeOneWay(Ref<ResultPoint> pattern, Ref<ResultPoint> otherPattern);
  44. float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY);
  45. float sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY);
  46. Ref<AlignmentPattern> findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY,
  47. float allowanceFactor);
  48. Ref<DetectorResult> processFinderPatternInfo(Ref<FinderPatternInfo> info);
  49. public:
  50. virtual Ref<PerspectiveTransform> createTransform(Ref<ResultPoint> topLeft, Ref<ResultPoint> topRight, Ref <
  51. ResultPoint > bottomLeft, Ref<ResultPoint> alignmentPattern, int dimension);
  52. Detector(Ref<BitMatrix> image);
  53. Ref<DetectorResult> detect(DecodeHints const& hints);
  54. };
  55. }
  56. }
  57. #endif // __DETECTOR_H__