控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
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.

Binarizer.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /*
  3. * Copyright 2009 ZXing authors
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace Zxing;
  18. use Zxing\Common\BitArray;
  19. use Zxing\Common\BitMatrix;
  20. /**
  21. * This class hierarchy provides a set of methods to convert luminance data to 1 bit data.
  22. * It allows the algorithm to vary polymorphically, for example allowing a very expensive
  23. * thresholding technique for servers and a fast one for mobile. It also permits the implementation
  24. * to vary, e.g. a JNI version for Android and a Java fallback version for other platforms.
  25. *
  26. * @author dswitkin@google.com (Daniel Switkin)
  27. */
  28. abstract class Binarizer
  29. {
  30. protected function __construct(private $source)
  31. {
  32. }
  33. /**
  34. * @return LuminanceSource
  35. */
  36. final public function getLuminanceSource()
  37. {
  38. return $this->source;
  39. }
  40. /**
  41. * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
  42. * cached data. Callers should assume this method is expensive and call it as seldom as possible.
  43. * This method is intended for decoding 1D barcodes and may choose to apply sharpening.
  44. * For callers which only examine one row of pixels at a time, the same BitArray should be reused
  45. * and passed in with each call for performance. However it is legal to keep more than one row
  46. * at a time if needed.
  47. *
  48. * @param $y The row to fetch, which must be in [0, bitmap height)
  49. * @param An $row optional preallocated array. If null or too small, it will be ignored.
  50. * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
  51. *
  52. * @return array The array of bits for this row (true means black).
  53. * @throws NotFoundException if row can't be binarized
  54. */
  55. abstract public function getBlackRow($y, $row);
  56. /**
  57. * Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
  58. * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
  59. * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
  60. * fetched using getBlackRow(), so don't mix and match between them.
  61. *
  62. * @return BitMatrix The 2D array of bits for the image (true means black).
  63. * @throws NotFoundException if image can't be binarized to make a matrix
  64. */
  65. abstract public function getBlackMatrix();
  66. /**
  67. * Creates a new object with the same type as this Binarizer implementation, but with pristine
  68. * state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache
  69. * of 1 bit data. See Effective Java for why we can't use Java's clone() method.
  70. *
  71. * @param $source The LuminanceSource this Binarizer will operate on.
  72. *
  73. * @return Binarizer A new concrete Binarizer implementation object.
  74. */
  75. abstract public function createBinarizer($source);
  76. final public function getWidth()
  77. {
  78. return $this->source->getWidth();
  79. }
  80. final public function getHeight()
  81. {
  82. return $this->source->getHeight();
  83. }
  84. }