Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ZXGridSampler.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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, ZXPerspectiveTransform;
  17. /**
  18. * Implementations of this class can, given locations of finder patterns for a QR code in an
  19. * image, sample the right points in the image to reconstruct the QR code, accounting for
  20. * perspective distortion. It is abstracted since it is relatively expensive and should be allowed
  21. * to take advantage of platform-specific optimized implementations, like Sun's Java Advanced
  22. * Imaging library, but which may not be available in other environments such as J2ME, and vice
  23. * versa.
  24. *
  25. * The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)}
  26. * with an instance of a class which implements this interface.
  27. */
  28. @interface ZXGridSampler : NSObject
  29. /**
  30. * Sets the implementation of GridSampler used by the library. One global
  31. * instance is stored, which may sound problematic. But, the implementation provided
  32. * ought to be appropriate for the entire platform, and all uses of this library
  33. * in the whole lifetime of the JVM. For instance, an Android activity can swap in
  34. * an implementation that takes advantage of native platform libraries.
  35. *
  36. * @param newGridSampler The platform-specific object to install.
  37. */
  38. + (void)setGridSampler:(ZXGridSampler *)newGridSampler;
  39. /**
  40. * @return the current implementation of GridSampler
  41. */
  42. + (ZXGridSampler *)instance;
  43. /**
  44. * Samples an image for a rectangular matrix of bits of the given dimension.
  45. * @param image image to sample
  46. * @param dimensionX width of ZXBitMatrix to sample from image
  47. * @param dimensionY height of ZXBitMatrix to sample from image
  48. * @return ZXBitMatrix representing a grid of points sampled from the image within a region
  49. * defined by the "from" parameters or nil if image can't be sampled, for example, if the transformation defined
  50. * by the given points is invalid or results in sampling outside the image boundaries
  51. */
  52. - (ZXBitMatrix *)sampleGrid:(ZXBitMatrix *)image
  53. dimensionX:(int)dimensionX
  54. dimensionY:(int)dimensionY
  55. p1ToX:(float)p1ToX p1ToY:(float)p1ToY
  56. p2ToX:(float)p2ToX p2ToY:(float)p2ToY
  57. p3ToX:(float)p3ToX p3ToY:(float)p3ToY
  58. p4ToX:(float)p4ToX p4ToY:(float)p4ToY
  59. p1FromX:(float)p1FromX p1FromY:(float)p1FromY
  60. p2FromX:(float)p2FromX p2FromY:(float)p2FromY
  61. p3FromX:(float)p3FromX p3FromY:(float)p3FromY
  62. p4FromX:(float)p4FromX p4FromY:(float)p4FromY
  63. error:(NSError **)error;
  64. - (ZXBitMatrix *)sampleGrid:(ZXBitMatrix *)image
  65. dimensionX:(int)dimensionX
  66. dimensionY:(int)dimensionY
  67. transform:(ZXPerspectiveTransform *)transform
  68. error:(NSError **)error;
  69. /**
  70. * <p>Checks a set of points that have been transformed to sample points on an image against
  71. * the image's dimensions to see if the point are even within the image.</p>
  72. *
  73. * <p>This method will actually "nudge" the endpoints back onto the image if they are found to be
  74. * barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder
  75. * patterns in an image where the QR Code runs all the way to the image border.</p>
  76. *
  77. * <p>For efficiency, the method will check points from either end of the line until one is found
  78. * to be within the image. Because the set of points are assumed to be linear, this is valid.</p>
  79. *
  80. * @param image image into which the points should map
  81. * @param points actual points in x1,y1,...,xn,yn form
  82. * @returns NO if an endpoint is lies outside the image boundaries
  83. */
  84. + (BOOL)checkAndNudgePoints:(ZXBitMatrix *)image points:(float *)points pointsLen:(int)pointsLen error:(NSError **)error;
  85. @end