You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZXQRCodeFinderPatternFinder.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. extern const int ZX_FINDER_PATTERN_MIN_SKIP;
  17. extern const int ZX_FINDER_PATTERN_MAX_MODULES;
  18. @protocol ZXResultPointCallback;
  19. @class ZXBitMatrix, ZXDecodeHints, ZXQRCodeFinderPatternInfo;
  20. /**
  21. * This class attempts to find finder patterns in a QR Code. Finder patterns are the square
  22. * markers at three corners of a QR Code.
  23. *
  24. * This class is thread-safe but not reentrant. Each thread must allocate its own object.
  25. */
  26. @interface ZXQRCodeFinderPatternFinder : NSObject
  27. @property (nonatomic, strong, readonly) ZXBitMatrix *image;
  28. @property (nonatomic, strong, readonly) NSMutableArray *possibleCenters;
  29. /**
  30. * Creates a finder that will search the image for three finder patterns.
  31. *
  32. * @param image image to search
  33. */
  34. - (id)initWithImage:(ZXBitMatrix *)image;
  35. - (id)initWithImage:(ZXBitMatrix *)image resultPointCallback:(id<ZXResultPointCallback>)resultPointCallback;
  36. - (ZXQRCodeFinderPatternInfo *)find:(ZXDecodeHints *)hints error:(NSError **)error;
  37. /**
  38. * @param stateCount count of black/white/black/white/black pixels just read
  39. * @return true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios
  40. * used by finder patterns to be considered a match
  41. */
  42. + (BOOL)foundPatternCross:(const int[])stateCount;
  43. /**
  44. * This is called when a horizontal scan finds a possible alignment pattern. It will
  45. * cross check with a vertical scan, and if successful, will, ah, cross-cross-check
  46. * with another horizontal scan. This is needed primarily to locate the real horizontal
  47. * center of the pattern in cases of extreme skew.
  48. * And then we cross-cross-cross check with another diagonal scan.
  49. *
  50. * If that succeeds the finder pattern location is added to a list that tracks
  51. * the number of times each location has been nearly-matched as a finder pattern.
  52. * Each additional find is more evidence that the location is in fact a finder
  53. * pattern center
  54. *
  55. * @param stateCount reading state module counts from horizontal scan
  56. * @param i row where finder pattern may be found
  57. * @param j end of possible finder pattern in row
  58. * @return true if a finder pattern candidate was found this time
  59. */
  60. - (BOOL)handlePossibleCenter:(const int[])stateCount i:(int)i j:(int)j pureBarcode:(BOOL)pureBarcode;
  61. @end