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.

ZXQRCodeDetector.h 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. @class ZXBitMatrix, ZXDecodeHints, ZXDetectorResult, ZXPerspectiveTransform, ZXQRCodeAlignmentPattern, ZXQRCodeFinderPatternInfo, ZXResultPoint;
  17. @protocol ZXResultPointCallback;
  18. /**
  19. * Encapsulates logic that can detect a QR Code in an image, even if the QR Code
  20. * is rotated or skewed, or partially obscured.
  21. */
  22. @interface ZXQRCodeDetector : NSObject
  23. @property (nonatomic, strong, readonly) ZXBitMatrix *image;
  24. @property (nonatomic, weak, readonly) id <ZXResultPointCallback> resultPointCallback;
  25. - (id)initWithImage:(ZXBitMatrix *)image;
  26. /**
  27. * Detects a QR Code in an image, simply.
  28. *
  29. * @return ZXDetectorResult encapsulating results of detecting a QR Code or nil
  30. * if no QR Code can be found
  31. */
  32. - (ZXDetectorResult *)detectWithError:(NSError **)error;
  33. /**
  34. * Detects a QR Code in an image, simply.
  35. *
  36. * @param hints optional hints to detector
  37. * @return ZXDetectorResult encapsulating results of detecting a QR Code
  38. * @return nil if QR Code cannot be found
  39. * @return nil if a QR Code cannot be decoded
  40. */
  41. - (ZXDetectorResult *)detect:(ZXDecodeHints *)hints error:(NSError **)error;
  42. - (ZXDetectorResult *)processFinderPatternInfo:(ZXQRCodeFinderPatternInfo *)info error:(NSError **)error;
  43. /**
  44. * Computes an average estimated module size based on estimated derived from the positions
  45. * of the three finder patterns.
  46. */
  47. - (float)calculateModuleSize:(ZXResultPoint *)topLeft topRight:(ZXResultPoint *)topRight bottomLeft:(ZXResultPoint *)bottomLeft;
  48. /**
  49. * Attempts to locate an alignment pattern in a limited region of the image, which is
  50. * guessed to contain it. This method uses ZXAlignmentPattern.
  51. *
  52. * @param overallEstModuleSize estimated module size so far
  53. * @param estAlignmentX x coordinate of center of area probably containing alignment pattern
  54. * @param estAlignmentY y coordinate of above
  55. * @param allowanceFactor number of pixels in all directions to search from the center
  56. * @return ZXAlignmentPattern if found, or nil if an unexpected error occurs during detection
  57. */
  58. - (ZXQRCodeAlignmentPattern *)findAlignmentInRegion:(float)overallEstModuleSize estAlignmentX:(int)estAlignmentX estAlignmentY:(int)estAlignmentY allowanceFactor:(float)allowanceFactor error:(NSError **)error;
  59. @end