react-native-nitro-zxing 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/README.md +34 -0
  2. package/VisionCameraZxing.podspec +48 -0
  3. package/android/CMakeLists.txt +43 -0
  4. package/android/build.gradle +150 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +7 -0
  9. package/android/src/main/java/com/margelo/nitro/camera/zxing/VisionCameraZxingPackage.kt +21 -0
  10. package/cpp/BarcodeValueTypeClassifier.cpp +70 -0
  11. package/cpp/BarcodeValueTypeClassifier.hpp +14 -0
  12. package/cpp/FrameImageView.cpp +75 -0
  13. package/cpp/FrameImageView.hpp +34 -0
  14. package/cpp/HybridBarcode.cpp +59 -0
  15. package/cpp/HybridBarcode.hpp +26 -0
  16. package/cpp/HybridBarcodeScanner.cpp +121 -0
  17. package/cpp/HybridBarcodeScanner.hpp +26 -0
  18. package/cpp/HybridBarcodeScannerFactory.cpp +11 -0
  19. package/cpp/HybridBarcodeScannerFactory.hpp +14 -0
  20. package/cpp/ImageDownscaler.cpp +34 -0
  21. package/cpp/ImageDownscaler.hpp +21 -0
  22. package/cpp/ZXingDecoder.cpp +189 -0
  23. package/cpp/ZXingDecoder.hpp +72 -0
  24. package/cpp/zxing-core/LICENSE +202 -0
  25. package/cpp/zxing-core/README.md +156 -0
  26. package/cpp/zxing-core/core/CMakeLists.txt +784 -0
  27. package/cpp/zxing-core/core/Version.h.in +28 -0
  28. package/cpp/zxing-core/core/ZXingConfig.cmake.in +9 -0
  29. package/cpp/zxing-core/core/src/Barcode.cpp +255 -0
  30. package/cpp/zxing-core/core/src/Barcode.h +191 -0
  31. package/cpp/zxing-core/core/src/BarcodeData.h +100 -0
  32. package/cpp/zxing-core/core/src/BarcodeFormat.cpp +286 -0
  33. package/cpp/zxing-core/core/src/BarcodeFormat.h +272 -0
  34. package/cpp/zxing-core/core/src/BinaryBitmap.cpp +111 -0
  35. package/cpp/zxing-core/core/src/BinaryBitmap.h +66 -0
  36. package/cpp/zxing-core/core/src/BitArray.cpp +38 -0
  37. package/cpp/zxing-core/core/src/BitArray.h +181 -0
  38. package/cpp/zxing-core/core/src/BitMatrix.cpp +175 -0
  39. package/cpp/zxing-core/core/src/BitMatrix.h +199 -0
  40. package/cpp/zxing-core/core/src/BitMatrixCursor.h +253 -0
  41. package/cpp/zxing-core/core/src/BitMatrixIO.cpp +101 -0
  42. package/cpp/zxing-core/core/src/BitMatrixIO.h +21 -0
  43. package/cpp/zxing-core/core/src/BitSource.cpp +77 -0
  44. package/cpp/zxing-core/core/src/BitSource.h +72 -0
  45. package/cpp/zxing-core/core/src/ByteArray.h +42 -0
  46. package/cpp/zxing-core/core/src/CharacterSet.cpp +78 -0
  47. package/cpp/zxing-core/core/src/CharacterSet.h +58 -0
  48. package/cpp/zxing-core/core/src/ConcentricFinder.cpp +312 -0
  49. package/cpp/zxing-core/core/src/ConcentricFinder.h +156 -0
  50. package/cpp/zxing-core/core/src/Content.cpp +471 -0
  51. package/cpp/zxing-core/core/src/Content.h +82 -0
  52. package/cpp/zxing-core/core/src/ContentType.h +19 -0
  53. package/cpp/zxing-core/core/src/CreateBarcode.cpp +490 -0
  54. package/cpp/zxing-core/core/src/CreateBarcode.h +132 -0
  55. package/cpp/zxing-core/core/src/DecoderResult.h +92 -0
  56. package/cpp/zxing-core/core/src/DetectorResult.h +44 -0
  57. package/cpp/zxing-core/core/src/ECI.cpp +81 -0
  58. package/cpp/zxing-core/core/src/ECI.h +78 -0
  59. package/cpp/zxing-core/core/src/Error.cpp +29 -0
  60. package/cpp/zxing-core/core/src/Error.h +79 -0
  61. package/cpp/zxing-core/core/src/Flags.h +165 -0
  62. package/cpp/zxing-core/core/src/GTIN.cpp +253 -0
  63. package/cpp/zxing-core/core/src/GTIN.h +58 -0
  64. package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.cpp +197 -0
  65. package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.h +34 -0
  66. package/cpp/zxing-core/core/src/GridSampler.cpp +124 -0
  67. package/cpp/zxing-core/core/src/GridSampler.h +59 -0
  68. package/cpp/zxing-core/core/src/HRI.cpp +343 -0
  69. package/cpp/zxing-core/core/src/HRI.h +16 -0
  70. package/cpp/zxing-core/core/src/HybridBinarizer.cpp +315 -0
  71. package/cpp/zxing-core/core/src/HybridBinarizer.h +40 -0
  72. package/cpp/zxing-core/core/src/ImageView.h +168 -0
  73. package/cpp/zxing-core/core/src/JSON.cpp +154 -0
  74. package/cpp/zxing-core/core/src/JSON.h +66 -0
  75. package/cpp/zxing-core/core/src/LocalGrid.cpp +242 -0
  76. package/cpp/zxing-core/core/src/LocalGrid.h +91 -0
  77. package/cpp/zxing-core/core/src/LogMatrix.h +105 -0
  78. package/cpp/zxing-core/core/src/Matrix.h +125 -0
  79. package/cpp/zxing-core/core/src/MultiFormatReader.cpp +107 -0
  80. package/cpp/zxing-core/core/src/MultiFormatReader.h +34 -0
  81. package/cpp/zxing-core/core/src/MultiFormatWriter.cpp +111 -0
  82. package/cpp/zxing-core/core/src/MultiFormatWriter.h +62 -0
  83. package/cpp/zxing-core/core/src/Pattern.h +472 -0
  84. package/cpp/zxing-core/core/src/PerspectiveTransform.cpp +81 -0
  85. package/cpp/zxing-core/core/src/PerspectiveTransform.h +47 -0
  86. package/cpp/zxing-core/core/src/Point.h +185 -0
  87. package/cpp/zxing-core/core/src/Quadrilateral.h +215 -0
  88. package/cpp/zxing-core/core/src/Range.h +112 -0
  89. package/cpp/zxing-core/core/src/ReadBarcode.cpp +335 -0
  90. package/cpp/zxing-core/core/src/ReadBarcode.h +33 -0
  91. package/cpp/zxing-core/core/src/Reader.h +32 -0
  92. package/cpp/zxing-core/core/src/ReaderOptions.h +210 -0
  93. package/cpp/zxing-core/core/src/ReedSolomon.cpp +100 -0
  94. package/cpp/zxing-core/core/src/ReedSolomon.h +66 -0
  95. package/cpp/zxing-core/core/src/RegressionLine.h +161 -0
  96. package/cpp/zxing-core/core/src/ResultPoint.cpp +20 -0
  97. package/cpp/zxing-core/core/src/ResultPoint.h +35 -0
  98. package/cpp/zxing-core/core/src/StdGenerator.h +121 -0
  99. package/cpp/zxing-core/core/src/StdPrint.h +38 -0
  100. package/cpp/zxing-core/core/src/StdScope.h +55 -0
  101. package/cpp/zxing-core/core/src/StructuredAppend.h +19 -0
  102. package/cpp/zxing-core/core/src/SymbologyIdentifier.h +29 -0
  103. package/cpp/zxing-core/core/src/TextDecoder.cpp +59 -0
  104. package/cpp/zxing-core/core/src/TextDecoder.h +23 -0
  105. package/cpp/zxing-core/core/src/TextEncoder.cpp +75 -0
  106. package/cpp/zxing-core/core/src/TextEncoder.h +31 -0
  107. package/cpp/zxing-core/core/src/ThresholdBinarizer.h +58 -0
  108. package/cpp/zxing-core/core/src/TritMatrix.h +29 -0
  109. package/cpp/zxing-core/core/src/Utf.cpp +276 -0
  110. package/cpp/zxing-core/core/src/Utf.h +26 -0
  111. package/cpp/zxing-core/core/src/WhiteRectDetector.cpp +276 -0
  112. package/cpp/zxing-core/core/src/WhiteRectDetector.h +36 -0
  113. package/cpp/zxing-core/core/src/WriteBarcode.cpp +213 -0
  114. package/cpp/zxing-core/core/src/WriteBarcode.h +72 -0
  115. package/cpp/zxing-core/core/src/ZXAlgorithms.h +353 -0
  116. package/cpp/zxing-core/core/src/ZXConfig.h +17 -0
  117. package/cpp/zxing-core/core/src/ZXTestSupport.h +9 -0
  118. package/cpp/zxing-core/core/src/ZXVersion.h +14 -0
  119. package/cpp/zxing-core/core/src/ZXingC.cpp +460 -0
  120. package/cpp/zxing-core/core/src/ZXingC.h +296 -0
  121. package/cpp/zxing-core/core/src/ZXingCpp.cpp +18 -0
  122. package/cpp/zxing-core/core/src/ZXingCpp.h +76 -0
  123. package/cpp/zxing-core/core/src/ZXingQt.h +606 -0
  124. package/cpp/zxing-core/core/src/aztec/AZDecoder.cpp +376 -0
  125. package/cpp/zxing-core/core/src/aztec/AZDecoder.h +20 -0
  126. package/cpp/zxing-core/core/src/aztec/AZDetector.cpp +508 -0
  127. package/cpp/zxing-core/core/src/aztec/AZDetector.h +25 -0
  128. package/cpp/zxing-core/core/src/aztec/AZDetectorResult.h +51 -0
  129. package/cpp/zxing-core/core/src/aztec/AZEncoder.cpp +318 -0
  130. package/cpp/zxing-core/core/src/aztec/AZEncoder.h +44 -0
  131. package/cpp/zxing-core/core/src/aztec/AZEncodingState.h +40 -0
  132. package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.cpp +377 -0
  133. package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.h +36 -0
  134. package/cpp/zxing-core/core/src/aztec/AZReader.cpp +45 -0
  135. package/cpp/zxing-core/core/src/aztec/AZReader.h +21 -0
  136. package/cpp/zxing-core/core/src/aztec/AZToken.cpp +44 -0
  137. package/cpp/zxing-core/core/src/aztec/AZToken.h +39 -0
  138. package/cpp/zxing-core/core/src/aztec/AZWriter.cpp +38 -0
  139. package/cpp/zxing-core/core/src/aztec/AZWriter.h +55 -0
  140. package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.cpp +194 -0
  141. package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.h +21 -0
  142. package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.cpp +63 -0
  143. package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.h +41 -0
  144. package/cpp/zxing-core/core/src/datamatrix/DMDecoder.cpp +457 -0
  145. package/cpp/zxing-core/core/src/datamatrix/DMDecoder.h +19 -0
  146. package/cpp/zxing-core/core/src/datamatrix/DMDetector.cpp +1230 -0
  147. package/cpp/zxing-core/core/src/datamatrix/DMDetector.h +23 -0
  148. package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.cpp +137 -0
  149. package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.h +26 -0
  150. package/cpp/zxing-core/core/src/datamatrix/DMEncoderContext.h +128 -0
  151. package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.cpp +919 -0
  152. package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.h +29 -0
  153. package/cpp/zxing-core/core/src/datamatrix/DMReader.cpp +40 -0
  154. package/cpp/zxing-core/core/src/datamatrix/DMReader.h +21 -0
  155. package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.cpp +141 -0
  156. package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.h +78 -0
  157. package/cpp/zxing-core/core/src/datamatrix/DMSymbolShape.h +17 -0
  158. package/cpp/zxing-core/core/src/datamatrix/DMVersion.cpp +82 -0
  159. package/cpp/zxing-core/core/src/datamatrix/DMVersion.h +76 -0
  160. package/cpp/zxing-core/core/src/datamatrix/DMWriter.cpp +114 -0
  161. package/cpp/zxing-core/core/src/datamatrix/DMWriter.h +62 -0
  162. package/cpp/zxing-core/core/src/librscpp/README.md +65 -0
  163. package/cpp/zxing-core/core/src/librscpp/decode.h +258 -0
  164. package/cpp/zxing-core/core/src/librscpp/encode.h +124 -0
  165. package/cpp/zxing-core/core/src/librscpp/field.h +158 -0
  166. package/cpp/zxing-core/core/src/librscpp/poly.h +194 -0
  167. package/cpp/zxing-core/core/src/libzint/2of5inter.c +1 -0
  168. package/cpp/zxing-core/core/src/libzint/2of5inter_based.c +1 -0
  169. package/cpp/zxing-core/core/src/libzint/aztec.c +1 -0
  170. package/cpp/zxing-core/core/src/libzint/aztec.h +1 -0
  171. package/cpp/zxing-core/core/src/libzint/big5.h +1 -0
  172. package/cpp/zxing-core/core/src/libzint/codabar.c +1 -0
  173. package/cpp/zxing-core/core/src/libzint/code.c +1 -0
  174. package/cpp/zxing-core/core/src/libzint/code128.c +1 -0
  175. package/cpp/zxing-core/core/src/libzint/code128.h +1 -0
  176. package/cpp/zxing-core/core/src/libzint/common.c +1 -0
  177. package/cpp/zxing-core/core/src/libzint/common.h +1 -0
  178. package/cpp/zxing-core/core/src/libzint/dmatrix.c +1 -0
  179. package/cpp/zxing-core/core/src/libzint/dmatrix.h +1 -0
  180. package/cpp/zxing-core/core/src/libzint/dxfilmedge.c +1 -0
  181. package/cpp/zxing-core/core/src/libzint/eci.c +1 -0
  182. package/cpp/zxing-core/core/src/libzint/eci.h +1 -0
  183. package/cpp/zxing-core/core/src/libzint/eci_sb.h +1 -0
  184. package/cpp/zxing-core/core/src/libzint/filemem.c +1 -0
  185. package/cpp/zxing-core/core/src/libzint/filemem.h +1 -0
  186. package/cpp/zxing-core/core/src/libzint/fonts/normal_woff2.h +1 -0
  187. package/cpp/zxing-core/core/src/libzint/fonts/upcean_woff2.h +1 -0
  188. package/cpp/zxing-core/core/src/libzint/gb18030.h +1 -0
  189. package/cpp/zxing-core/core/src/libzint/gb2312.h +1 -0
  190. package/cpp/zxing-core/core/src/libzint/gbk.h +1 -0
  191. package/cpp/zxing-core/core/src/libzint/general_field.c +1 -0
  192. package/cpp/zxing-core/core/src/libzint/general_field.h +1 -0
  193. package/cpp/zxing-core/core/src/libzint/gs1.c +1 -0
  194. package/cpp/zxing-core/core/src/libzint/gs1.h +1 -0
  195. package/cpp/zxing-core/core/src/libzint/gs1_lint.h +1 -0
  196. package/cpp/zxing-core/core/src/libzint/iso3166.h +1 -0
  197. package/cpp/zxing-core/core/src/libzint/iso4217.h +1 -0
  198. package/cpp/zxing-core/core/src/libzint/ksx1001.h +1 -0
  199. package/cpp/zxing-core/core/src/libzint/large.c +1 -0
  200. package/cpp/zxing-core/core/src/libzint/large.h +1 -0
  201. package/cpp/zxing-core/core/src/libzint/library.c +1 -0
  202. package/cpp/zxing-core/core/src/libzint/maxicode.c +1 -0
  203. package/cpp/zxing-core/core/src/libzint/maxicode.h +1 -0
  204. package/cpp/zxing-core/core/src/libzint/medical.c +1 -0
  205. package/cpp/zxing-core/core/src/libzint/output.c +1 -0
  206. package/cpp/zxing-core/core/src/libzint/output.h +1 -0
  207. package/cpp/zxing-core/core/src/libzint/pdf417.c +1 -0
  208. package/cpp/zxing-core/core/src/libzint/pdf417.h +1 -0
  209. package/cpp/zxing-core/core/src/libzint/pdf417_tabs.h +1 -0
  210. package/cpp/zxing-core/core/src/libzint/qr.c +1 -0
  211. package/cpp/zxing-core/core/src/libzint/qr.h +1 -0
  212. package/cpp/zxing-core/core/src/libzint/raster.c +1 -0
  213. package/cpp/zxing-core/core/src/libzint/raster_font.h +1 -0
  214. package/cpp/zxing-core/core/src/libzint/reedsol.c +1 -0
  215. package/cpp/zxing-core/core/src/libzint/reedsol.h +1 -0
  216. package/cpp/zxing-core/core/src/libzint/reedsol_logs.h +1 -0
  217. package/cpp/zxing-core/core/src/libzint/rss.c +1 -0
  218. package/cpp/zxing-core/core/src/libzint/rss.h +1 -0
  219. package/cpp/zxing-core/core/src/libzint/sjis.h +1 -0
  220. package/cpp/zxing-core/core/src/libzint/stubs.c +137 -0
  221. package/cpp/zxing-core/core/src/libzint/svg.c +1 -0
  222. package/cpp/zxing-core/core/src/libzint/telepen.c +1 -0
  223. package/cpp/zxing-core/core/src/libzint/upcean.c +1 -0
  224. package/cpp/zxing-core/core/src/libzint/vector.c +1 -0
  225. package/cpp/zxing-core/core/src/libzint/zfiletypes.h +1 -0
  226. package/cpp/zxing-core/core/src/libzint/zint.h +1 -0
  227. package/cpp/zxing-core/core/src/libzint/zintconfig.h +1 -0
  228. package/cpp/zxing-core/core/src/libzueci/README.md +11 -0
  229. package/cpp/zxing-core/core/src/libzueci/zueci.c +1718 -0
  230. package/cpp/zxing-core/core/src/libzueci/zueci.h +179 -0
  231. package/cpp/zxing-core/core/src/libzueci/zueci_big5.h +3884 -0
  232. package/cpp/zxing-core/core/src/libzueci/zueci_common.h +31 -0
  233. package/cpp/zxing-core/core/src/libzueci/zueci_gb18030.h +264 -0
  234. package/cpp/zxing-core/core/src/libzueci/zueci_gb2312.h +2381 -0
  235. package/cpp/zxing-core/core/src/libzueci/zueci_gbk.h +4047 -0
  236. package/cpp/zxing-core/core/src/libzueci/zueci_ksx1001.h +2932 -0
  237. package/cpp/zxing-core/core/src/libzueci/zueci_sb.h +1112 -0
  238. package/cpp/zxing-core/core/src/libzueci/zueci_sjis.h +2286 -0
  239. package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.cpp +68 -0
  240. package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.h +30 -0
  241. package/cpp/zxing-core/core/src/maxicode/MCDecoder.cpp +329 -0
  242. package/cpp/zxing-core/core/src/maxicode/MCDecoder.h +19 -0
  243. package/cpp/zxing-core/core/src/maxicode/MCReader.cpp +65 -0
  244. package/cpp/zxing-core/core/src/maxicode/MCReader.h +21 -0
  245. package/cpp/zxing-core/core/src/oned/ODCodabarReader.cpp +102 -0
  246. package/cpp/zxing-core/core/src/oned/ODCodabarReader.h +21 -0
  247. package/cpp/zxing-core/core/src/oned/ODCodabarWriter.cpp +136 -0
  248. package/cpp/zxing-core/core/src/oned/ODCodabarWriter.h +34 -0
  249. package/cpp/zxing-core/core/src/oned/ODCode128Patterns.h +130 -0
  250. package/cpp/zxing-core/core/src/oned/ODCode128Reader.cpp +236 -0
  251. package/cpp/zxing-core/core/src/oned/ODCode128Reader.h +21 -0
  252. package/cpp/zxing-core/core/src/oned/ODCode128Writer.cpp +261 -0
  253. package/cpp/zxing-core/core/src/oned/ODCode128Writer.h +34 -0
  254. package/cpp/zxing-core/core/src/oned/ODCode39Reader.cpp +213 -0
  255. package/cpp/zxing-core/core/src/oned/ODCode39Reader.h +26 -0
  256. package/cpp/zxing-core/core/src/oned/ODCode39Writer.cpp +176 -0
  257. package/cpp/zxing-core/core/src/oned/ODCode39Writer.h +34 -0
  258. package/cpp/zxing-core/core/src/oned/ODCode93Patterns.h +80 -0
  259. package/cpp/zxing-core/core/src/oned/ODCode93Reader.cpp +112 -0
  260. package/cpp/zxing-core/core/src/oned/ODCode93Reader.h +21 -0
  261. package/cpp/zxing-core/core/src/oned/ODCode93Writer.cpp +192 -0
  262. package/cpp/zxing-core/core/src/oned/ODCode93Writer.h +32 -0
  263. package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.cpp +246 -0
  264. package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.h +26 -0
  265. package/cpp/zxing-core/core/src/oned/ODDataBarCommon.cpp +172 -0
  266. package/cpp/zxing-core/core/src/oned/ODDataBarCommon.h +204 -0
  267. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.cpp +253 -0
  268. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.h +19 -0
  269. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.cpp +383 -0
  270. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.h +25 -0
  271. package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.cpp +163 -0
  272. package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.h +23 -0
  273. package/cpp/zxing-core/core/src/oned/ODDataBarReader.cpp +240 -0
  274. package/cpp/zxing-core/core/src/oned/ODDataBarReader.h +25 -0
  275. package/cpp/zxing-core/core/src/oned/ODEAN13Writer.cpp +62 -0
  276. package/cpp/zxing-core/core/src/oned/ODEAN13Writer.h +34 -0
  277. package/cpp/zxing-core/core/src/oned/ODEAN8Writer.cpp +51 -0
  278. package/cpp/zxing-core/core/src/oned/ODEAN8Writer.h +34 -0
  279. package/cpp/zxing-core/core/src/oned/ODITFReader.cpp +97 -0
  280. package/cpp/zxing-core/core/src/oned/ODITFReader.h +33 -0
  281. package/cpp/zxing-core/core/src/oned/ODITFWriter.cpp +78 -0
  282. package/cpp/zxing-core/core/src/oned/ODITFWriter.h +34 -0
  283. package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.cpp +323 -0
  284. package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.h +32 -0
  285. package/cpp/zxing-core/core/src/oned/ODReader.cpp +259 -0
  286. package/cpp/zxing-core/core/src/oned/ODReader.h +35 -0
  287. package/cpp/zxing-core/core/src/oned/ODRowReader.h +222 -0
  288. package/cpp/zxing-core/core/src/oned/ODTelepenReader.cpp +199 -0
  289. package/cpp/zxing-core/core/src/oned/ODTelepenReader.h +25 -0
  290. package/cpp/zxing-core/core/src/oned/ODUPCAWriter.cpp +33 -0
  291. package/cpp/zxing-core/core/src/oned/ODUPCAWriter.h +34 -0
  292. package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.cpp +80 -0
  293. package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.h +129 -0
  294. package/cpp/zxing-core/core/src/oned/ODUPCEWriter.cpp +56 -0
  295. package/cpp/zxing-core/core/src/oned/ODUPCEWriter.h +34 -0
  296. package/cpp/zxing-core/core/src/oned/ODWriterHelper.cpp +39 -0
  297. package/cpp/zxing-core/core/src/oned/ODWriterHelper.h +48 -0
  298. package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.cpp +796 -0
  299. package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.h +23 -0
  300. package/cpp/zxing-core/core/src/pdf417/PDF417.cpp +85 -0
  301. package/cpp/zxing-core/core/src/pdf417/PDF417.h +81 -0
  302. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeMetadata.h +53 -0
  303. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.cpp +48 -0
  304. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.h +38 -0
  305. package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.cpp +116 -0
  306. package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.h +75 -0
  307. package/cpp/zxing-core/core/src/pdf417/PDFCodeword.h +71 -0
  308. package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.cpp +588 -0
  309. package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.h +41 -0
  310. package/cpp/zxing-core/core/src/pdf417/PDFCompaction.h +20 -0
  311. package/cpp/zxing-core/core/src/pdf417/PDFCustomData.h +32 -0
  312. package/cpp/zxing-core/core/src/pdf417/PDFDecoder.cpp +725 -0
  313. package/cpp/zxing-core/core/src/pdf417/PDFDecoder.h +20 -0
  314. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.cpp +247 -0
  315. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.h +74 -0
  316. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.cpp +321 -0
  317. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.h +83 -0
  318. package/cpp/zxing-core/core/src/pdf417/PDFDetector.cpp +371 -0
  319. package/cpp/zxing-core/core/src/pdf417/PDFDetector.h +45 -0
  320. package/cpp/zxing-core/core/src/pdf417/PDFEncoder.cpp +570 -0
  321. package/cpp/zxing-core/core/src/pdf417/PDFEncoder.h +182 -0
  322. package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.cpp +570 -0
  323. package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.h +32 -0
  324. package/cpp/zxing-core/core/src/pdf417/PDFReader.cpp +333 -0
  325. package/cpp/zxing-core/core/src/pdf417/PDFReader.h +28 -0
  326. package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.cpp +559 -0
  327. package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.h +41 -0
  328. package/cpp/zxing-core/core/src/pdf417/PDFWriter.cpp +170 -0
  329. package/cpp/zxing-core/core/src/pdf417/PDFWriter.h +74 -0
  330. package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.cpp +623 -0
  331. package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.h +81 -0
  332. package/cpp/zxing-core/core/src/pdf417/ZXNullable.h +105 -0
  333. package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.cpp +294 -0
  334. package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.h +41 -0
  335. package/cpp/zxing-core/core/src/qrcode/QRCodecMode.cpp +95 -0
  336. package/cpp/zxing-core/core/src/qrcode/QRCodecMode.h +59 -0
  337. package/cpp/zxing-core/core/src/qrcode/QRDataBlock.cpp +93 -0
  338. package/cpp/zxing-core/core/src/qrcode/QRDataBlock.h +52 -0
  339. package/cpp/zxing-core/core/src/qrcode/QRDataMask.h +50 -0
  340. package/cpp/zxing-core/core/src/qrcode/QRDecoder.cpp +359 -0
  341. package/cpp/zxing-core/core/src/qrcode/QRDecoder.h +19 -0
  342. package/cpp/zxing-core/core/src/qrcode/QRDetector.cpp +920 -0
  343. package/cpp/zxing-core/core/src/qrcode/QRDetector.h +45 -0
  344. package/cpp/zxing-core/core/src/qrcode/QRECB.h +52 -0
  345. package/cpp/zxing-core/core/src/qrcode/QREncodeResult.h +33 -0
  346. package/cpp/zxing-core/core/src/qrcode/QREncoder.cpp +568 -0
  347. package/cpp/zxing-core/core/src/qrcode/QREncoder.h +21 -0
  348. package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.cpp +51 -0
  349. package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.h +39 -0
  350. package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.cpp +160 -0
  351. package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.h +61 -0
  352. package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.cpp +156 -0
  353. package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.h +15 -0
  354. package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.cpp +318 -0
  355. package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.h +25 -0
  356. package/cpp/zxing-core/core/src/qrcode/QRReader.cpp +149 -0
  357. package/cpp/zxing-core/core/src/qrcode/QRReader.h +21 -0
  358. package/cpp/zxing-core/core/src/qrcode/QRVersion.cpp +754 -0
  359. package/cpp/zxing-core/core/src/qrcode/QRVersion.h +127 -0
  360. package/cpp/zxing-core/core/src/qrcode/QRWriter.cpp +51 -0
  361. package/cpp/zxing-core/core/src/qrcode/QRWriter.h +74 -0
  362. package/cpp/zxing-core/core/version.rc.in +34 -0
  363. package/cpp/zxing-core/core/zxing.pc.in +8 -0
  364. package/cpp/zxing-core/wrappers/ios/README.md +25 -0
  365. package/cpp/zxing-core/wrappers/ios/Sources/Wrapper/Version.h +29 -0
  366. package/cpp/zxing-core/zxing-cpp.podspec +45 -0
  367. package/lib/factory.d.ts +10 -0
  368. package/lib/factory.js +12 -0
  369. package/lib/index.d.ts +9 -0
  370. package/lib/index.js +9 -0
  371. package/lib/specs/Barcode.nitro.d.ts +63 -0
  372. package/lib/specs/Barcode.nitro.js +1 -0
  373. package/lib/specs/BarcodeFormat.d.ts +11 -0
  374. package/lib/specs/BarcodeFormat.js +1 -0
  375. package/lib/specs/BarcodeScanner.nitro.d.ts +89 -0
  376. package/lib/specs/BarcodeScanner.nitro.js +1 -0
  377. package/lib/specs/BarcodeScannerFactory.nitro.d.ts +26 -0
  378. package/lib/specs/BarcodeScannerFactory.nitro.js +1 -0
  379. package/lib/specs/BarcodeValueType.d.ts +9 -0
  380. package/lib/specs/BarcodeValueType.js +1 -0
  381. package/lib/specs/Point.d.ts +14 -0
  382. package/lib/specs/Point.js +1 -0
  383. package/lib/specs/Rect.d.ts +22 -0
  384. package/lib/specs/Rect.js +1 -0
  385. package/lib/useBarcodeScanner.d.ts +23 -0
  386. package/lib/useBarcodeScanner.js +25 -0
  387. package/nitro.json +20 -0
  388. package/nitrogen/generated/.gitattributes +1 -0
  389. package/nitrogen/generated/android/VisionCameraZxing+autolinking.cmake +83 -0
  390. package/nitrogen/generated/android/VisionCameraZxing+autolinking.gradle +27 -0
  391. package/nitrogen/generated/android/VisionCameraZxingOnLoad.cpp +49 -0
  392. package/nitrogen/generated/android/VisionCameraZxingOnLoad.hpp +34 -0
  393. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/zxing/VisionCameraZxingOnLoad.kt +35 -0
  394. package/nitrogen/generated/ios/VisionCameraZxing+autolinking.rb +62 -0
  395. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.cpp +17 -0
  396. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.hpp +27 -0
  397. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Umbrella.hpp +38 -0
  398. package/nitrogen/generated/ios/VisionCameraZxingAutolinking.mm +35 -0
  399. package/nitrogen/generated/ios/VisionCameraZxingAutolinking.swift +16 -0
  400. package/nitrogen/generated/shared/c++/BarcodeFormat.hpp +124 -0
  401. package/nitrogen/generated/shared/c++/BarcodeScannerOptions.hpp +85 -0
  402. package/nitrogen/generated/shared/c++/BarcodeValueType.hpp +120 -0
  403. package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.cpp +23 -0
  404. package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.hpp +74 -0
  405. package/nitrogen/generated/shared/c++/HybridBarcodeSpec.cpp +27 -0
  406. package/nitrogen/generated/shared/c++/HybridBarcodeSpec.hpp +82 -0
  407. package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.cpp +21 -0
  408. package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.hpp +67 -0
  409. package/nitrogen/generated/shared/c++/Point.hpp +87 -0
  410. package/nitrogen/generated/shared/c++/Rect.hpp +95 -0
  411. package/nitrogen/generated/shared/c++/TargetBarcodeFormat.hpp +124 -0
  412. package/package.json +108 -0
  413. package/react-native.config.js +16 -0
  414. package/src/factory.ts +26 -0
  415. package/src/index.ts +9 -0
  416. package/src/specs/Barcode.nitro.ts +70 -0
  417. package/src/specs/BarcodeFormat.ts +31 -0
  418. package/src/specs/BarcodeScanner.nitro.ts +91 -0
  419. package/src/specs/BarcodeScannerFactory.nitro.ts +27 -0
  420. package/src/specs/BarcodeValueType.ts +25 -0
  421. package/src/specs/Point.ts +14 -0
  422. package/src/specs/Rect.ts +22 -0
  423. package/src/useBarcodeScanner.ts +36 -0
@@ -0,0 +1,315 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "HybridBinarizer.h"
8
+
9
+ #include "BitMatrix.h"
10
+ #include "Matrix.h"
11
+
12
+ #include <algorithm>
13
+ #include <cstdint>
14
+ #include <fstream>
15
+ #include <memory>
16
+
17
+ #define USE_NEW_ALGORITHM
18
+
19
+ namespace ZXing {
20
+
21
+ // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels.
22
+ // So this is the smallest dimension in each axis we can accept.
23
+ static constexpr int BLOCK_SIZE = 8;
24
+ static constexpr int WINDOW_SIZE = BLOCK_SIZE * (1 + 2 * 2);
25
+ static constexpr int MIN_DYNAMIC_RANGE = 24;
26
+
27
+ HybridBinarizer::HybridBinarizer(const ImageView& iv) : GlobalHistogramBinarizer(iv) {}
28
+
29
+ HybridBinarizer::~HybridBinarizer() = default;
30
+
31
+ bool HybridBinarizer::getPatternRow(int row, int rotation, PatternRow& res) const
32
+ {
33
+ #if 1
34
+ // This is the original "hybrid" behavior: use GlobalHistogram for the 1D case
35
+ return GlobalHistogramBinarizer::getPatternRow(row, rotation, res);
36
+ #else
37
+ // This is an alternative that can be faster in general and perform better in unevenly lit situations like
38
+ // https://github.com/zxing-cpp/zxing-cpp/blob/master/test/samples/ean13-2/21.png. That said, it fairs
39
+ // worse in borderline low resolution situations. With the current black box sample set we'd loose 94
40
+ // test cases while gaining 53 others.
41
+ auto bits = getBitMatrix();
42
+ if (bits)
43
+ GetPatternRow(*bits, row, res, rotation % 180 != 0);
44
+ return bits != nullptr;
45
+ #endif
46
+ }
47
+
48
+ using T_t = uint8_t;
49
+
50
+ /**
51
+ * Applies a single threshold to a block of pixels.
52
+ */
53
+ static void ThresholdBlock(const uint8_t* __restrict luminances, int xoffset, int yoffset, T_t threshold, int rowStride,
54
+ BitMatrix& matrix)
55
+ {
56
+ for (int y = yoffset; y < yoffset + BLOCK_SIZE; ++y) {
57
+ auto* src = luminances + y * rowStride + xoffset;
58
+ auto* const dstBegin = matrix.row(y).begin() + xoffset;
59
+ // TODO: fix pixelStride > 1 case
60
+ for (auto* dst = dstBegin; dst < dstBegin + BLOCK_SIZE; ++dst, ++src)
61
+ *dst = (*src <= threshold) * BitMatrix::SET_V;
62
+ }
63
+ }
64
+
65
+ #ifndef USE_NEW_ALGORITHM
66
+
67
+ /**
68
+ * Calculates a single black point for each block of pixels and saves it away.
69
+ * See the following thread for a discussion of this algorithm:
70
+ * http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0
71
+ */
72
+ static Matrix<T_t> CalculateBlackPoints(const uint8_t* __restrict luminances, int subWidth, int subHeight, int width, int height,
73
+ int rowStride)
74
+ {
75
+ Matrix<T_t> blackPoints(subWidth, subHeight);
76
+
77
+ for (int y = 0; y < subHeight; y++) {
78
+ int yoffset = std::min(y * BLOCK_SIZE, height - BLOCK_SIZE);
79
+ for (int x = 0; x < subWidth; x++) {
80
+ int xoffset = std::min(x * BLOCK_SIZE, width - BLOCK_SIZE);
81
+ int sum = 0;
82
+ uint8_t min = luminances[yoffset * rowStride + xoffset];
83
+ uint8_t max = min;
84
+ for (int yy = 0, offset = yoffset * rowStride + xoffset; yy < BLOCK_SIZE; yy++, offset += rowStride) {
85
+ for (int xx = 0; xx < BLOCK_SIZE; xx++) {
86
+ auto pixel = luminances[offset + xx];
87
+ sum += pixel;
88
+ if (pixel < min)
89
+ min = pixel;
90
+ if (pixel > max)
91
+ max = pixel;
92
+ }
93
+ // short-circuit min/max tests once dynamic range is met
94
+ if (max - min > MIN_DYNAMIC_RANGE) {
95
+ // finish the rest of the rows quickly
96
+ for (yy++, offset += rowStride; yy < BLOCK_SIZE; yy++, offset += rowStride) {
97
+ for (int xx = 0; xx < BLOCK_SIZE; xx++) {
98
+ sum += luminances[offset + xx];
99
+ }
100
+ }
101
+ }
102
+ }
103
+
104
+ // The default estimate is the average of the values in the block.
105
+ int average = sum / (BLOCK_SIZE * BLOCK_SIZE);
106
+ if (max - min <= MIN_DYNAMIC_RANGE) {
107
+ // If variation within the block is low, assume this is a block with only light or only
108
+ // dark pixels. In that case we do not want to use the average, as it would divide this
109
+ // low contrast area into black and white pixels, essentially creating data out of noise.
110
+ //
111
+ // The default assumption is that the block is light/background. Since no estimate for
112
+ // the level of dark pixels exists locally, use half the min for the block.
113
+ average = min / 2;
114
+
115
+ if (y > 0 && x > 0) {
116
+ // Correct the "white background" assumption for blocks that have neighbors by comparing
117
+ // the pixels in this block to the previously calculated black points. This is based on
118
+ // the fact that dark barcode symbology is always surrounded by some amount of light
119
+ // background for which reasonable black point estimates were made. The bp estimated at
120
+ // the boundaries is used for the interior.
121
+
122
+ // The (min < bp) is arbitrary but works better than other heuristics that were tried.
123
+ int averageNeighborBlackPoint =
124
+ (blackPoints(x, y - 1) + (2 * blackPoints(x - 1, y)) + blackPoints(x - 1, y - 1)) / 4;
125
+ if (min < averageNeighborBlackPoint) {
126
+ average = averageNeighborBlackPoint;
127
+ }
128
+ }
129
+ }
130
+ blackPoints(x, y) = average;
131
+ }
132
+ }
133
+ return blackPoints;
134
+ }
135
+
136
+ /**
137
+ * For each block in the image, calculate the average black point using a 5x5 grid
138
+ * of the blocks around it. Also handles the corner cases (fractional blocks are computed based
139
+ * on the last pixels in the row/column which are also used in the previous block).
140
+ */
141
+ static std::shared_ptr<BitMatrix> CalculateMatrix(const uint8_t* __restrict luminances, int subWidth, int subHeight, int width,
142
+ int height, int rowStride, const Matrix<T_t>& blackPoints)
143
+ {
144
+ auto matrix = std::make_shared<BitMatrix>(width, height);
145
+
146
+ #ifdef PRINT_DEBUG
147
+ Matrix<uint8_t> out(width, height);
148
+ Matrix<uint8_t> out2(width, height);
149
+ #endif
150
+
151
+ for (int y = 0; y < subHeight; y++) {
152
+ int yoffset = std::min(y * BLOCK_SIZE, height - BLOCK_SIZE);
153
+ for (int x = 0; x < subWidth; x++) {
154
+ int xoffset = std::min(x * BLOCK_SIZE, width - BLOCK_SIZE);
155
+ int left = std::clamp(x, 2, subWidth - 3);
156
+ int top = std::clamp(y, 2, subHeight - 3);
157
+ int sum = 0;
158
+ for (int dy = -2; dy <= 2; ++dy) {
159
+ for (int dx = -2; dx <= 2; ++dx) {
160
+ sum += blackPoints(left + dx, top + dy);
161
+ }
162
+ }
163
+ int average = sum / 25;
164
+ ThresholdBlock(luminances, xoffset, yoffset, average, rowStride, *matrix);
165
+
166
+ #ifdef PRINT_DEBUG
167
+ for (int yy = 0; yy < 8; ++yy)
168
+ for (int xx = 0; xx < 8; ++xx) {
169
+ out.set(xoffset + xx, yoffset + yy, blackPoints(x, y));
170
+ out2.set(xoffset + xx, yoffset + yy, average);
171
+ }
172
+ #endif
173
+ }
174
+ }
175
+
176
+ #ifdef PRINT_DEBUG
177
+ std::ofstream file("thresholds.pnm");
178
+ file << "P5\n" << out.width() << ' ' << out.height() << "\n255\n";
179
+ file.write(reinterpret_cast<const char*>(out.data()), out.size());
180
+ std::ofstream file2("thresholds_avg.pnm");
181
+ file2 << "P5\n" << out.width() << ' ' << out.height() << "\n255\n";
182
+ file2.write(reinterpret_cast<const char*>(out2.data()), out2.size());
183
+ #endif
184
+
185
+ return matrix;
186
+ }
187
+
188
+ #else
189
+
190
+ // Subdivide the image in blocks of BLOCK_SIZE and calculate one threshold value per block as
191
+ // (max - min > MIN_DYNAMIC_RANGE) ? (max + min) / 2 : 0
192
+ static Matrix<T_t> BlockThresholds(const ImageView iv)
193
+ {
194
+ int subWidth = (iv.width() + BLOCK_SIZE - 1) / BLOCK_SIZE; // ceil(width/BS)
195
+ int subHeight = (iv.height() + BLOCK_SIZE - 1) / BLOCK_SIZE; // ceil(height/BS)
196
+
197
+ Matrix<T_t> thresholds(subWidth, subHeight);
198
+
199
+ for (int y = 0; y < subHeight; y++) {
200
+ int y0 = std::min(y * BLOCK_SIZE, iv.height() - BLOCK_SIZE);
201
+ for (int x = 0; x < subWidth; x++) {
202
+ int x0 = std::min(x * BLOCK_SIZE, iv.width() - BLOCK_SIZE);
203
+ uint8_t min = 255;
204
+ uint8_t max = 0;
205
+ for (int yy = 0; yy < BLOCK_SIZE; yy++) {
206
+ auto line = iv.data(x0, y0 + yy);
207
+ for (int xx = 0; xx < BLOCK_SIZE; xx++)
208
+ UpdateMinMax(min, max, line[xx]);
209
+ }
210
+
211
+ thresholds(x, y) = (max - min > MIN_DYNAMIC_RANGE) ? (int(max) + min) / 2 : 0;
212
+ }
213
+ }
214
+
215
+ return thresholds;
216
+ }
217
+
218
+ // Apply gaussian-like smoothing filter over all non-zero thresholds and fill any remaining gaps with nearest neighbor
219
+ static Matrix<T_t> SmoothThresholds(Matrix<T_t>&& in)
220
+ {
221
+ Matrix<T_t> out(in.width(), in.height());
222
+
223
+ constexpr int R = WINDOW_SIZE / BLOCK_SIZE / 2;
224
+ for (int y = 0; y < in.height(); y++) {
225
+ for (int x = 0; x < in.width(); x++) {
226
+ int left = std::clamp(x, R, in.width() - R - 1);
227
+ int top = std::clamp(y, R, in.height() - R - 1);
228
+
229
+ int sum = in(x, y) * 2;
230
+ int n = (sum > 0) * 2;
231
+ auto add = [&](int x, int y) {
232
+ int t = in(x, y);
233
+ sum += t;
234
+ n += t > 0;
235
+ };
236
+
237
+ for (int dy = -R; dy <= R; ++dy)
238
+ for (int dx = -R; dx <= R; ++dx)
239
+ add(left + dx, top + dy);
240
+
241
+ out(x, y) = n > 0 ? sum / n : 0;
242
+ }
243
+ }
244
+
245
+ // flood fill any remaining gaps of (very large) no-contrast regions
246
+ auto last = out.begin() - 1;
247
+ for (auto* i = out.begin(); i != out.end(); ++i) {
248
+ if (*i) {
249
+ if (last != i - 1)
250
+ std::fill(last + 1, i, *i);
251
+ last = i;
252
+ }
253
+ }
254
+ std::fill(last + 1, out.end(), *(std::max(last, out.begin())));
255
+
256
+ return out;
257
+ }
258
+
259
+ static std::shared_ptr<BitMatrix> ThresholdImage(const ImageView iv, const Matrix<T_t>& thresholds)
260
+ {
261
+ auto matrix = std::make_shared<BitMatrix>(iv.width(), iv.height());
262
+
263
+ #ifdef PRINT_DEBUG
264
+ Matrix<uint8_t> out(iv.width(), iv.height());
265
+ #endif
266
+
267
+ for (int y = 0; y < thresholds.height(); y++) {
268
+ int yoffset = std::min(y * BLOCK_SIZE, iv.height() - BLOCK_SIZE);
269
+ for (int x = 0; x < thresholds.width(); x++) {
270
+ int xoffset = std::min(x * BLOCK_SIZE, iv.width() - BLOCK_SIZE);
271
+ ThresholdBlock(iv.data(), xoffset, yoffset, thresholds(x, y), iv.rowStride(), *matrix);
272
+
273
+ #ifdef PRINT_DEBUG
274
+ for (int yy = 0; yy < 8; ++yy)
275
+ for (int xx = 0; xx < 8; ++xx)
276
+ out.set(xoffset + xx, yoffset + yy, thresholds(x, y));
277
+ #endif
278
+ }
279
+ }
280
+
281
+ #ifdef PRINT_DEBUG
282
+ std::ofstream file("thresholds_new.pnm");
283
+ file << "P5\n" << out.width() << ' ' << out.height() << "\n255\n";
284
+ file.write(reinterpret_cast<const char*>(out.data()), out.size());
285
+ #endif
286
+
287
+ return matrix;
288
+ }
289
+
290
+ #endif
291
+
292
+ std::shared_ptr<const BitMatrix> HybridBinarizer::getBlackMatrix() const
293
+ {
294
+ if (width() >= WINDOW_SIZE && height() >= WINDOW_SIZE) {
295
+ #ifdef USE_NEW_ALGORITHM
296
+ auto thrs = SmoothThresholds(BlockThresholds(_buffer));
297
+ if (std::ranges::max(thrs) == 0)
298
+ return GlobalHistogramBinarizer::getBlackMatrix();
299
+ return ThresholdImage(_buffer, thrs);
300
+ #else
301
+ const uint8_t* luminances = _buffer.data();
302
+ int subWidth = (width() + BLOCK_SIZE - 1) / BLOCK_SIZE; // ceil(width/BS)
303
+ int subHeight = (height() + BLOCK_SIZE - 1) / BLOCK_SIZE; // ceil(height/BS)
304
+ auto blackPoints =
305
+ CalculateBlackPoints(luminances, subWidth, subHeight, width(), height(), _buffer.rowStride());
306
+
307
+ return CalculateMatrix(luminances, subWidth, subHeight, width(), height(), _buffer.rowStride(), blackPoints);
308
+ #endif
309
+ } else {
310
+ // If the image is too small, fall back to the global histogram approach.
311
+ return GlobalHistogramBinarizer::getBlackMatrix();
312
+ }
313
+ }
314
+
315
+ } // ZXing
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #pragma once
8
+
9
+ #include "GlobalHistogramBinarizer.h"
10
+
11
+ namespace ZXing {
12
+
13
+ /**
14
+ * This class implements a local thresholding algorithm, which while slower than the
15
+ * GlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for
16
+ * high frequency images of barcodes with black data on white backgrounds. For this application,
17
+ * it does a much better job than a global blackpoint with severe shadows and gradients.
18
+ * However it tends to produce artifacts on lower frequency images and is therefore not
19
+ * a good general purpose binarizer for uses outside ZXing.
20
+ *
21
+ * This class extends GlobalHistogramBinarizer, using the older histogram approach for 1D readers,
22
+ * and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already
23
+ * inherently local, and only fails for horizontal gradients. We can revisit that problem later,
24
+ * but for now it was not a win to use local blocks for 1D.
25
+ *
26
+ * This Binarizer is the default for the unit tests and the recommended class for library users.
27
+ *
28
+ * @author dswitkin@google.com (Daniel Switkin)
29
+ */
30
+ class HybridBinarizer : public GlobalHistogramBinarizer
31
+ {
32
+ public:
33
+ explicit HybridBinarizer(const ImageView& iv);
34
+ ~HybridBinarizer() override;
35
+
36
+ bool getPatternRow(int row, int rotation, PatternRow &res) const override;
37
+ std::shared_ptr<const BitMatrix> getBlackMatrix() const override;
38
+ };
39
+
40
+ } // ZXing
@@ -0,0 +1,168 @@
1
+ /*
2
+ * Copyright 2019 Axel Waggershauser
3
+ */
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ #pragma once
7
+
8
+ #include <algorithm>
9
+ #include <cstdint>
10
+ #include <cstdio>
11
+ #include <memory>
12
+ #include <stdexcept>
13
+
14
+ namespace ZXing {
15
+
16
+ /// @brief Supported image formats for ImageView. The format encodes the pixel format and layout information.
17
+ enum class ImageFormat : uint32_t
18
+ {
19
+ None = 0,
20
+ Lum = 0x01000000,
21
+ LumA = 0x02000000,
22
+ RGB = 0x03000102,
23
+ BGR = 0x03020100,
24
+ RGBA = 0x04000102,
25
+ ARGB = 0x04010203,
26
+ BGRA = 0x04020100,
27
+ ABGR = 0x04030201,
28
+ RGBX [[deprecated("use RGBA")]] = RGBA,
29
+ XRGB [[deprecated("use ARGB")]] = ARGB,
30
+ BGRX [[deprecated("use BGRA")]] = BGRA,
31
+ XBGR [[deprecated("use ABGR")]] = ABGR,
32
+ };
33
+
34
+ /// @cond INTERNAL
35
+ constexpr inline int PixStride(ImageFormat format) { return (static_cast<uint32_t>(format) >> 3*8) & 0xFF; }
36
+ constexpr inline int RedIndex(ImageFormat format) { return (static_cast<uint32_t>(format) >> 2*8) & 0xFF; }
37
+ constexpr inline int GreenIndex(ImageFormat format) { return (static_cast<uint32_t>(format) >> 1*8) & 0xFF; }
38
+ constexpr inline int BlueIndex(ImageFormat format) { return (static_cast<uint32_t>(format) >> 0*8) & 0xFF; }
39
+
40
+ constexpr inline uint8_t RGBToLum(unsigned r, unsigned g, unsigned b)
41
+ {
42
+ // .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
43
+ // (306*R) >> 10 is approximately equal to R*0.299, and so on.
44
+ // 0x200 >> 10 is 0.5, it implements rounding.
45
+ return static_cast<uint8_t>((306 * r + 601 * g + 117 * b + 0x200) >> 10);
46
+ }
47
+ /// @endcond
48
+
49
+ /**
50
+ * @brief Simple class that stores a non-owning const pointer to image data plus layout and format information.
51
+ */
52
+ class ImageView
53
+ {
54
+ /// @cond INTERNAL
55
+ protected:
56
+ const uint8_t* _data = nullptr;
57
+ ImageFormat _format = ImageFormat::None;
58
+ int _width = 0, _height = 0, _pixStride = 0, _rowStride = 0;
59
+ /// @endcond
60
+
61
+ public:
62
+ /**
63
+ * ImageView default constructor creates a 'null' image view
64
+ */
65
+ ImageView() = default;
66
+
67
+ /**
68
+ * ImageView constructor
69
+ *
70
+ * @param data pointer to image buffer
71
+ * @param width image width in pixels
72
+ * @param height image height in pixels
73
+ * @param format image/pixel format
74
+ * @param rowStride optional row stride in bytes, default is width * pixStride
75
+ * @param pixStride optional pixel stride in bytes, default is calculated from format
76
+ */
77
+ ImageView(const uint8_t* data, int width, int height, ImageFormat format, int rowStride = 0, int pixStride = 0)
78
+ : _data(data),
79
+ _format(format),
80
+ _width(width),
81
+ _height(height),
82
+ _pixStride(pixStride ? pixStride : PixStride(format)),
83
+ _rowStride(rowStride ? rowStride : width * _pixStride)
84
+ {
85
+ if (_data == nullptr)
86
+ throw std::invalid_argument("Can not construct an ImageView from a NULL pointer");
87
+
88
+ if (_width <= 0 || _height <= 0)
89
+ throw std::invalid_argument("Neither width nor height of ImageView can be less or equal to 0");
90
+ }
91
+
92
+ /**
93
+ * ImageView constructor with bounds checking.
94
+ *
95
+ * This constructor checks if the provided size is consistent with the width, height, row stride and pixel stride
96
+ * parameters to prevent out of bounds access when using the ImageView.
97
+ *
98
+ * @param data pointer to image buffer
99
+ * @param size size of the image buffer in bytes
100
+ * @param width image width in pixels
101
+ * @param height image height in pixels
102
+ * @param format image/pixel format
103
+ * @param rowStride optional row stride in bytes, default is width * pixStride
104
+ * @param pixStride optional pixel stride in bytes, default is calculated from format
105
+ */
106
+ ImageView(const uint8_t* data, int size, int width, int height, ImageFormat format, int rowStride = 0, int pixStride = 0)
107
+ : ImageView(data, width, height, format, rowStride, pixStride)
108
+ {
109
+ if (_rowStride < 0 || _pixStride < 0 || size < _height * _rowStride)
110
+ throw std::invalid_argument("ImageView parameters are inconsistent (out of bounds)");
111
+ }
112
+
113
+ int width() const { return _width; }
114
+ int height() const { return _height; }
115
+ int pixStride() const { return _pixStride; }
116
+ int rowStride() const { return _rowStride; }
117
+ ImageFormat format() const { return _format; }
118
+
119
+ const uint8_t* data() const { return _data; }
120
+ const uint8_t* data(int x, int y) const { return _data + y * _rowStride + x * _pixStride; }
121
+
122
+ /// Create a new ImageView that is a cropped version of this one.
123
+ /// Negative width/height will be interpreted as "until the end of the line/image".
124
+ ImageView cropped(int left, int top, int width, int height) const
125
+ {
126
+ left = std::clamp(left, 0, _width - 1);
127
+ top = std::clamp(top, 0, _height - 1);
128
+ width = width <= 0 ? (_width - left) : std::min(_width - left, width);
129
+ height = height <= 0 ? (_height - top) : std::min(_height - top, height);
130
+ return {data(left, top), width, height, _format, _rowStride, _pixStride};
131
+ }
132
+
133
+ /// Create a new ImageView that is a rotated version of this one.
134
+ /// Rotation is clockwise and only supports 90 degree steps.
135
+ ImageView rotated(int degree) const
136
+ {
137
+ switch ((degree + 360) % 360) {
138
+ case 90: return {data(0, _height - 1), _height, _width, _format, _pixStride, -_rowStride};
139
+ case 180: return {data(_width - 1, _height - 1), _width, _height, _format, -_rowStride, -_pixStride};
140
+ case 270: return {data(_width - 1, 0), _height, _width, _format, -_pixStride, _rowStride};
141
+ default: return *this;
142
+ }
143
+ }
144
+
145
+ /// Create a new ImageView that is a subsampled version of this one.
146
+ /// The subsampled image will have width/height of original divided by scale.
147
+ ImageView subsampled(int scale) const
148
+ {
149
+ return {_data, _width / scale, _height / scale, _format, _rowStride * scale, _pixStride * scale};
150
+ }
151
+
152
+ };
153
+
154
+ /**
155
+ * @brief Simple class that inherits ImageView but owns the image data and frees it on destruction.
156
+ */
157
+ class Image : public ImageView
158
+ {
159
+ std::unique_ptr<uint8_t[]> _memory;
160
+ Image(std::unique_ptr<uint8_t[]>&& data, int w, int h, ImageFormat f) : ImageView(data.get(), w, h, f), _memory(std::move(data)) {}
161
+
162
+ public:
163
+ Image() = default;
164
+ Image(int w, int h, ImageFormat f = ImageFormat::Lum) : Image(std::make_unique<uint8_t[]>(w * h * PixStride(f)), w, h, f) {}
165
+ };
166
+
167
+ } // ZXing
168
+
@@ -0,0 +1,154 @@
1
+ /*
2
+ * Copyright 2025 Axel Waggershauser
3
+ */
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ #include "JSON.h"
7
+
8
+ #include "ZXAlgorithms.h"
9
+
10
+ #include <string_view>
11
+
12
+ // This code is trying to find the value of a key-value pair in a string of those.
13
+ // The input could be valid JSON, like '{"key": "val"}' or a stripped down version like
14
+ // 'key:val'. This is also compatible with the string serialization of a python dictionary.
15
+ // For convenience, also 'key=val' is supported, key is checked case insensitive and '_' is ignored.
16
+ // This could easily be done with the following regex (see below).
17
+ // But using std::regex adds 140k+ to the binary size. ctre is _very_ nice to use and has
18
+ // the same binary footprint as the hand-roled code below! But I don't want to add
19
+ // 5k lines of c++ code for that.
20
+
21
+ // #define ZXING_USE_CTRE
22
+ #ifdef ZXING_USE_CTRE
23
+ #pragma GCC diagnostic ignored "-Wundef" // see https://github.com/hanickadot/compile-time-regular-expressions/issues/340
24
+ #include "ctre.hpp"
25
+ #pragma GCC diagnostic error "-Wundef"
26
+
27
+ static constexpr auto PATTERN =
28
+ ctll::fixed_string{R"(["']?([[:alpha:]][[:alnum:]]*)["']?\s*(?:[:]\s*["']?([[:alnum:]]+)["']?)?(?:,|\}|$))"};
29
+ #endif
30
+
31
+ namespace ZXing {
32
+
33
+ // Trim whitespace and quotes/braces from both ends
34
+ inline std::string_view Trim(std::string_view sv)
35
+ {
36
+ return TrimWS(sv, " \t\n\r\"'{}");
37
+ }
38
+
39
+ inline bool IsEqualIgnoreCaseAndUnderscore(std::string_view a, std::string_view b)
40
+ {
41
+ return IsEqualIgnoreCaseAnd(a, b, "_");
42
+ }
43
+
44
+ std::string_view JsonFind(std::string_view json, std::string_view key)
45
+ {
46
+ #ifdef ZXING_USE_CTRE
47
+ for (auto [ma, mk, mv] : ctre::search_all<PATTERN>(json))
48
+ if (IsEqualCaseInsensitive(key, mk))
49
+ return mv.size() ? mv.to_view() : std::string_view(mk.data(), 0);
50
+
51
+ return {};
52
+ #else
53
+ json = Trim(json);
54
+
55
+ // TODO: use something like ForEachToken here?
56
+ while (!json.empty()) {
57
+ auto posComma = json.find(',');
58
+ auto pair = Trim(json.substr(0, posComma));
59
+
60
+ if (IsEqualIgnoreCaseAndUnderscore(pair, key))
61
+ return {pair.data(), 0}; // return non-null data to signal that we found the key
62
+
63
+ auto posSep = pair.find_first_of(":=");
64
+
65
+ if (posSep != std::string_view::npos && IsEqualIgnoreCaseAndUnderscore(Trim(pair.substr(0, posSep)), key))
66
+ return Trim(pair.substr(posSep + 1));
67
+
68
+ json = (posComma == std::string_view::npos) ? std::string_view{} : json.substr(posComma + 1);
69
+ }
70
+
71
+ return {};
72
+ #endif
73
+ }
74
+
75
+ std::string JsonEscapeStr(std::string_view str)
76
+ {
77
+ std::string res;
78
+ res.reserve(str.size() + 10);
79
+
80
+ for (unsigned char c : str) {
81
+ switch (c) {
82
+ case '\"': res += "\\\""; break;
83
+ case '\\': res += "\\\\"; break;
84
+ case '\b': res += "\\b"; break;
85
+ case '\f': res += "\\f"; break;
86
+ case '\n': res += "\\n"; break;
87
+ case '\r': res += "\\r"; break;
88
+ case '\t': res += "\\t"; break;
89
+ default:
90
+ if (c <= 0x1F) {
91
+ char buf[7];
92
+ std::snprintf(buf, sizeof(buf), "\\u%04X", c);
93
+ res += buf;
94
+ } else {
95
+ res += c;
96
+ }
97
+ break;
98
+ }
99
+ }
100
+
101
+ return res;
102
+ }
103
+
104
+ std::string JsonUnEscapeStr(std::string_view str)
105
+ {
106
+ std::string res;
107
+ res.reserve(str.size());
108
+
109
+ for (size_t i = 0; i < str.size(); ++i) {
110
+ char c = str[i];
111
+ if (c == '\\') {
112
+ if (++i >= str.size())
113
+ throw std::runtime_error("Invalid escape sequence");
114
+
115
+ char esc = str[i];
116
+ switch (esc) {
117
+ case '"': res += '\"'; break;
118
+ case '\\': res += '\\'; break;
119
+ case '/': res += '/'; break;
120
+ case 'b': res += '\b'; break;
121
+ case 'f': res += '\f'; break;
122
+ case 'n': res += '\n'; break;
123
+ case 'r': res += '\r'; break;
124
+ case 't': res += '\t'; break;
125
+ case 'u': {
126
+ if (i + 4 >= str.size())
127
+ throw std::runtime_error("Incomplete \\u escape");
128
+
129
+ uint32_t code = 0;
130
+ auto first = str.data() + i + 1;
131
+ auto last = first + 4;
132
+
133
+ auto [ptr, ec] = std::from_chars(first, last, code, 16);
134
+ if (ec != std::errc() || ptr != last)
135
+ throw std::runtime_error("Failed to parse hex code");
136
+
137
+ if (code > 0x1F)
138
+ throw std::runtime_error("Unexpected code point in \\u escape");
139
+
140
+ res += static_cast<char>(code);
141
+ i += 4;
142
+ break;
143
+ }
144
+ default: throw std::runtime_error("Unknown escape sequence");
145
+ }
146
+ } else {
147
+ res += c;
148
+ }
149
+ }
150
+
151
+ return res;
152
+ }
153
+
154
+ } // ZXing