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,253 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "GTIN.h"
8
+
9
+ #include <algorithm>
10
+ #ifdef __cpp_lib_format // not available on gcc 12
11
+ #include <format>
12
+ #endif
13
+ #include <iomanip>
14
+ #include <iterator>
15
+ #include <string>
16
+
17
+ namespace ZXing::GTIN {
18
+
19
+ struct CountryId
20
+ {
21
+ uint16_t first;
22
+ uint16_t last;
23
+ const char id[3];
24
+ };
25
+
26
+ bool operator<(const CountryId& lhs, const CountryId& rhs)
27
+ {
28
+ return lhs.last < rhs.last;
29
+ }
30
+
31
+ // https://www.gs1.org/standards/id-keys/company-prefix (as of 7 Feb 2022)
32
+ // and https://en.wikipedia.org/wiki/List_of_GS1_country_codes
33
+ static const CountryId COUNTRIES[] = {
34
+ // clang-format off
35
+ {1, 19, "US"},
36
+ {30, 39, "US"},
37
+ {60, 99, "US"}, // Note 99 coupon identification
38
+ {100, 139, "US"},
39
+ {300, 379, "FR"}, // France (and Monaco according to Wikipedia)
40
+ {380, 380, "BG"}, // Bulgaria
41
+ {383, 383, "SI"}, // Slovenia
42
+ {385, 385, "HR"}, // Croatia
43
+ {387, 387, "BA"}, // Bosnia and Herzegovina
44
+ {389, 389, "ME"}, // Montenegro
45
+ //{390, 390, "XK"}, // (Kosovo according to Wikipedia, unsourced)
46
+ {400, 440, "DE"}, // Germany
47
+ {450, 459, "JP"}, // Japan
48
+ {460, 469, "RU"}, // Russia
49
+ {470, 470, "KG"}, // Kyrgyzstan
50
+ {471, 471, "TW"}, // Taiwan
51
+ {474, 474, "EE"}, // Estonia
52
+ {475, 475, "LV"}, // Latvia
53
+ {476, 476, "AZ"}, // Azerbaijan
54
+ {477, 477, "LT"}, // Lithuania
55
+ {478, 478, "UZ"}, // Uzbekistan
56
+ {479, 479, "LK"}, // Sri Lanka
57
+ {480, 480, "PH"}, // Philippines
58
+ {481, 481, "BY"}, // Belarus
59
+ {482, 482, "UA"}, // Ukraine
60
+ {483, 483, "TM"}, // Turkmenistan
61
+ {484, 484, "MD"}, // Moldova
62
+ {485, 485, "AM"}, // Armenia
63
+ {486, 486, "GE"}, // Georgia
64
+ {487, 487, "KZ"}, // Kazakhstan
65
+ {488, 488, "TJ"}, // Tajikistan
66
+ {489, 489, "HK"}, // Hong Kong
67
+ {490, 499, "JP"}, // Japan
68
+ {500, 509, "GB"}, // UK
69
+ {520, 521, "GR"}, // Greece
70
+ {528, 528, "LB"}, // Lebanon
71
+ {529, 529, "CY"}, // Cyprus
72
+ {530, 530, "AL"}, // Albania
73
+ {531, 531, "MK"}, // North Macedonia
74
+ {535, 535, "MT"}, // Malta
75
+ {539, 539, "IE"}, // Ireland
76
+ {540, 549, "BE"}, // Belgium & Luxembourg
77
+ {560, 560, "PT"}, // Portugal
78
+ {569, 569, "IS"}, // Iceland
79
+ {570, 579, "DK"}, // Denmark (and Faroe Islands and Greenland according to Wikipedia)
80
+ {590, 590, "PL"}, // Poland
81
+ {594, 594, "RO"}, // Romania
82
+ {599, 599, "HU"}, // Hungary
83
+ {600, 601, "ZA"}, // South Africa
84
+ {603, 603, "GH"}, // Ghana
85
+ {604, 604, "SN"}, // Senegal
86
+ {608, 608, "BH"}, // Bahrain
87
+ {609, 609, "MU"}, // Mauritius
88
+ {611, 611, "MA"}, // Morocco
89
+ {613, 613, "DZ"}, // Algeria
90
+ {615, 615, "NG"}, // Nigeria
91
+ {616, 616, "KE"}, // Kenya
92
+ {617, 617, "CM"}, // Cameroon
93
+ {618, 618, "CI"}, // Côte d'Ivoire
94
+ {619, 619, "TN"}, // Tunisia
95
+ {620, 620, "TZ"}, // Tanzania
96
+ {621, 621, "SY"}, // Syria
97
+ {622, 622, "EG"}, // Egypt
98
+ {623, 623, "BN"}, // Brunei
99
+ {624, 624, "LY"}, // Libya
100
+ {625, 625, "JO"}, // Jordan
101
+ {626, 626, "IR"}, // Iran
102
+ {627, 627, "KW"}, // Kuwait
103
+ {628, 628, "SA"}, // Saudi Arabia
104
+ {629, 629, "AE"}, // United Arab Emirates
105
+ {630, 630, "QA"}, // Qatar
106
+ {631, 631, "NA"}, // Namibia
107
+ {640, 649, "FI"}, // Finland
108
+ {690, 699, "CN"}, // China
109
+ {700, 709, "NO"}, // Norway
110
+ {729, 729, "IL"}, // Israel
111
+ {730, 739, "SE"}, // Sweden
112
+ {740, 740, "GT"}, // Guatemala
113
+ {741, 741, "SV"}, // El Salvador
114
+ {742, 742, "HN"}, // Honduras
115
+ {743, 743, "NI"}, // Nicaragua
116
+ {744, 744, "CR"}, // Costa Rica
117
+ {745, 745, "PA"}, // Panama
118
+ {746, 746, "DO"}, // Dominican Republic
119
+ {750, 750, "MX"}, // Mexico
120
+ {754, 755, "CA"}, // Canada
121
+ {759, 759, "VE"}, // Venezuela
122
+ {760, 769, "CH"}, // Switzerland (and Liechtenstein according to Wikipedia)
123
+ {770, 771, "CO"}, // Colombia
124
+ {773, 773, "UY"}, // Uruguay
125
+ {775, 775, "PE"}, // Peru
126
+ {777, 777, "BO"}, // Bolivia
127
+ {778, 779, "AR"}, // Argentina
128
+ {780, 780, "CL"}, // Chile
129
+ {784, 784, "PY"}, // Paraguay
130
+ {786, 786, "EC"}, // Ecuador
131
+ {789, 790, "BR"}, // Brazil
132
+ {800, 839, "IT"}, // Italy (and San Marino and Vatican City according to Wikipedia)
133
+ {840, 849, "ES"}, // Spain (and Andorra according to Wikipedia)
134
+ {850, 850, "CU"}, // Cuba
135
+ {858, 858, "SK"}, // Slovakia
136
+ {859, 859, "CZ"}, // Czechia
137
+ {860, 860, "RS"}, // Serbia
138
+ {865, 865, "MN"}, // Mongolia
139
+ {867, 867, "KP"}, // North Korea
140
+ {868, 869, "TR"}, // Turkey
141
+ {870, 879, "NL"}, // Netherlands
142
+ {880, 880, "KR"}, // South Korea
143
+ {883, 883, "MM"}, // Myanmar
144
+ {884, 884, "KH"}, // Cambodia
145
+ {885, 885, "TH"}, // Thailand
146
+ {888, 888, "SG"}, // Singapore
147
+ {890, 890, "IN"}, // India
148
+ {893, 893, "VN"}, // Vietnam
149
+ {896, 896, "PK"}, // Pakistan
150
+ {899, 899, "ID"}, // Indonesia
151
+ {900, 919, "AT"}, // Austria
152
+ {930, 939, "AU"}, // Australia
153
+ {940, 949, "NZ"}, // New Zealand
154
+ {955, 955, "MY"}, // Malaysia
155
+ {958, 958, "MO"}, // Macao
156
+ //{960, 961, "GB"}, // Global Office - assigned to GS1 UK for GTIN-8 allocations (also 9620-9624999)
157
+ // clang-format on
158
+ };
159
+
160
+ std::string LookupCountryIdentifier(std::string_view GTIN, const BarcodeFormat format)
161
+ {
162
+ // Ignore add-on if any
163
+ const auto space = GTIN.find(' ');
164
+ const std::string::size_type size = space != std::string::npos ? space : GTIN.size();
165
+
166
+ if (size != 14 && size != 13 && size != 12 && size != 8)
167
+ return {};
168
+
169
+ // GTIN-14 leading packaging level indicator
170
+ const int first = size == 14 ? 1 : 0;
171
+ // UPC-A/E implicit leading 0
172
+ const int implicitZero = size == 12 || (size == 8 && format != BarcodeFormat::EAN8) ? 1 : 0;
173
+
174
+ if (size != 8 || format != BarcodeFormat::EAN8) { // Assuming following doesn't apply to EAN-8
175
+ // 0000000 Restricted Circulation Numbers; 0000001-0000099 unused to avoid collision with GTIN-8
176
+ int prefix = FromString<int>(GTIN.substr(first, 7 - implicitZero));
177
+ if (prefix >= 0 && prefix <= 99)
178
+ return {};
179
+
180
+ // 00001-00009 US
181
+ prefix = FromString<int>(GTIN.substr(first, 5 - implicitZero));
182
+ if (prefix >= 1 && prefix <= 9)
183
+ return "US";
184
+
185
+ // 0001-0009 US
186
+ prefix = FromString<int>(GTIN.substr(first, 4 - implicitZero));
187
+ if (prefix >= 1 && prefix <= 9)
188
+ return "US";
189
+ }
190
+
191
+ const int prefix = FromString<int>(GTIN.substr(first, 3 - implicitZero));
192
+
193
+ // Special case EAN-8 for prefix < 100 (GS1 General Specifications Figure 1.4.3-1)
194
+ if (size == 8 && format == BarcodeFormat::EAN8 && prefix <= 99) // Restricted Circulation Numbers
195
+ return {};
196
+
197
+ const auto it = std::lower_bound(std::begin(COUNTRIES), std::end(COUNTRIES), CountryId{0, narrow_cast<uint16_t>(prefix), ""});
198
+
199
+ return it != std::end(COUNTRIES) && prefix >= it->first && prefix <= it->last ? it->id : std::string();
200
+ }
201
+
202
+ std::string EanAddOn(const Barcode& barcode)
203
+ {
204
+ if (barcode.symbologyIdentifier() != "]E3")
205
+ return {};
206
+ return barcode.text().substr(barcode.format() == BarcodeFormat::EAN8 ? 8 : 13);
207
+ }
208
+
209
+ std::string IssueNr(const std::string& ean2AddOn)
210
+ {
211
+ if (ean2AddOn.size() != 2)
212
+ return {};
213
+
214
+ return std::to_string(std::stoi(ean2AddOn));
215
+ }
216
+
217
+ std::string Price(const std::string& ean5AddOn)
218
+ {
219
+ if (ean5AddOn.size() != 5)
220
+ return {};
221
+
222
+ std::string currency;
223
+ switch (ean5AddOn.front()) {
224
+ case '0': [[fallthrough]];
225
+ case '1': currency = "GBP £"; break; // UK
226
+ case '3': currency = "AUD $"; break; // AUS
227
+ case '4': currency = "NZD $"; break; // NZ
228
+ case '5': currency = "USD $"; break; // US
229
+ case '6': currency = "CAD $"; break; // CA
230
+ case '9':
231
+ // Reference: http://www.jollytech.com
232
+ if (ean5AddOn == "90000") // No suggested retail price
233
+ return {};
234
+ if (ean5AddOn == "99991") // Complementary
235
+ return "0.00";
236
+ if (ean5AddOn == "99990")
237
+ return "Used";
238
+
239
+ // Otherwise... unknown currency?
240
+ currency = "";
241
+ break;
242
+ default: currency = ""; break;
243
+ }
244
+
245
+ int rawAmount = std::stoi(ean5AddOn.substr(1));
246
+ #if !defined(__cpp_lib_to_chars) || !defined(__cpp_lib_format) // not available on older macOS / gcc 12
247
+ return currency + std::to_string(rawAmount / 100) + '.' + std::to_string(rawAmount % 100);
248
+ #else
249
+ return std::format("{}{:.2f}", currency, float(rawAmount) / 100);
250
+ #endif
251
+ }
252
+
253
+ } // namespace ZXing::GTIN
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ * Copyright 2020 Axel Waggershauser
5
+ */
6
+ // SPDX-License-Identifier: Apache-2.0
7
+
8
+ #pragma once
9
+
10
+ #include "Barcode.h"
11
+ #include "BarcodeFormat.h"
12
+
13
+ #ifdef ZXING_INTERNAL
14
+ #include "ZXAlgorithms.h"
15
+ #endif
16
+
17
+ #include <string>
18
+ #include <string_view>
19
+
20
+ namespace ZXing::GTIN {
21
+
22
+ #ifdef ZXING_INTERNAL
23
+ template <typename T>
24
+ T ComputeCheckDigit(const std::basic_string<T>& digits, bool skipTail = false)
25
+ {
26
+ int sum = 0, N = Size(digits) - skipTail;
27
+ for (int i = N - 1; i >= 0; i -= 2)
28
+ sum += digits[i] - '0';
29
+ sum *= 3;
30
+ for (int i = N - 2; i >= 0; i -= 2)
31
+ sum += digits[i] - '0';
32
+ return ToDigit<T>((10 - (sum % 10)) % 10);
33
+ }
34
+
35
+ template <typename T>
36
+ bool IsCheckDigitValid(const std::basic_string<T>& s)
37
+ {
38
+ return ComputeCheckDigit(s, true) == s.back();
39
+ }
40
+ #endif
41
+
42
+ /**
43
+ * Evaluate the prefix of the GTIN to estimate the country of origin. See
44
+ * <a href="https://www.gs1.org/standards/id-keys/company-prefix">
45
+ * https://www.gs1.org/standards/id-keys/company-prefix</a> and
46
+ * <a href="https://en.wikipedia.org/wiki/List_of_GS1_country_codes">
47
+ * https://en.wikipedia.org/wiki/List_of_GS1_country_codes</a>.
48
+ *
49
+ * `format` required for EAN-8 (UPC-E assumed if not given)
50
+ */
51
+ std::string LookupCountryIdentifier(std::string_view GTIN, BarcodeFormat format = BarcodeFormat::None);
52
+
53
+ std::string EanAddOn(const Barcode& barcode);
54
+
55
+ std::string IssueNr(const std::string& ean2AddOn);
56
+ std::string Price(const std::string& ean5AddOn);
57
+
58
+ } // namespace ZXing::GTIN
@@ -0,0 +1,197 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "GlobalHistogramBinarizer.h"
8
+
9
+ #include "BitMatrix.h"
10
+ #include "Pattern.h"
11
+ #include "ZXConfig.h"
12
+
13
+ #include <algorithm>
14
+ #include <array>
15
+ #include <utility>
16
+
17
+ namespace ZXing {
18
+
19
+ static constexpr int LUMINANCE_BITS = 5;
20
+ static constexpr int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
21
+ static constexpr int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
22
+
23
+ using Histogram = std::array<uint16_t, LUMINANCE_BUCKETS>;
24
+
25
+ GlobalHistogramBinarizer::GlobalHistogramBinarizer(const ImageView& buffer) : BinaryBitmap(buffer) {}
26
+
27
+ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() = default;
28
+
29
+ using ImageLineView = Range<StrideIter<const uint8_t*>>;
30
+
31
+ inline ImageLineView RowView(const ImageView& iv, int row)
32
+ {
33
+ return {{iv.data(0, row), iv.pixStride()}, {iv.data(iv.width(), row), iv.pixStride()}};
34
+ }
35
+
36
+ template <typename I>
37
+ static void ThresholdSharpened(Range<I> in, int threshold, std::vector<uint8_t>& out)
38
+ {
39
+ out.resize(in.size());
40
+ auto i = in.begin();
41
+ auto o = out.begin();
42
+
43
+ *o++ = (*i++ <= threshold) * BitMatrix::SET_V;
44
+ for (auto end = in.end() - 1; i != end; ++i)
45
+ *o++ = ((-i[-1] + (int(i[0]) * 4) - i[1]) / 2 <= threshold) * BitMatrix::SET_V;
46
+ *o++ = (*i++ <= threshold) * BitMatrix::SET_V;
47
+ }
48
+
49
+ template <typename I>
50
+ static auto GenHistogram(Range<I> line)
51
+ {
52
+ // This code causes about 20% of the total runtime on an AVX2 system for a EAN13 search on Lum input data.
53
+ // Trying to increase the performance by performing 2 or 4 "parallel" histograms helped nothing on the Intel
54
+ // system but was able to make the total runtime for that use case go down about 10% on an ARM M4.
55
+ #if 1
56
+ Histogram res0 = {}, res1 = {}, res2 = {}, res3 = {};
57
+
58
+ auto src = line.begin();
59
+ const auto end = line.end();
60
+
61
+ while (end - src >= 4) {
62
+ res0[*src++ >> LUMINANCE_SHIFT]++;
63
+ res1[*src++ >> LUMINANCE_SHIFT]++;
64
+ res2[*src++ >> LUMINANCE_SHIFT]++;
65
+ res3[*src++ >> LUMINANCE_SHIFT]++;
66
+ }
67
+
68
+ Histogram res = {};
69
+ for (int i = 0; i < LUMINANCE_BUCKETS; ++i)
70
+ res[i] = res0[i] + res1[i] + res2[i] + res3[i];
71
+
72
+ while (src != end)
73
+ res[*src++ >> LUMINANCE_SHIFT]++;
74
+
75
+ return res;
76
+ #else
77
+ Histogram res = {};
78
+ for (auto pix : line)
79
+ res[pix >> LUMINANCE_SHIFT]++;
80
+ return res;
81
+ #endif
82
+ }
83
+
84
+ // Return -1 on error
85
+ static int EstimateBlackPoint(const Histogram& buckets)
86
+ {
87
+ // Find the tallest peak in the histogram.
88
+ auto firstPeakPos = std::max_element(buckets.begin(), buckets.end());
89
+ int firstPeak = narrow_cast<int>(firstPeakPos - buckets.begin());
90
+ int firstPeakSize = *firstPeakPos;
91
+ int maxBucketCount = firstPeakSize;
92
+
93
+ // Find the second-tallest peak which is somewhat far from the tallest peak.
94
+ int secondPeak = 0;
95
+ int secondPeakScore = 0;
96
+ for (int x = 0; x < Size(buckets); x++) {
97
+ int distanceToBiggest = x - firstPeak;
98
+ // Encourage more distant second peaks by multiplying by square of distance.
99
+ int score = buckets[x] * distanceToBiggest * distanceToBiggest;
100
+ if (score > secondPeakScore) {
101
+ secondPeak = x;
102
+ secondPeakScore = score;
103
+ }
104
+ }
105
+
106
+ // Make sure firstPeak corresponds to the black peak.
107
+ if (firstPeak > secondPeak) {
108
+ std::swap(firstPeak, secondPeak);
109
+ }
110
+
111
+ // If there is too little contrast in the image to pick a meaningful black point, throw rather
112
+ // than waste time trying to decode the image, and risk false positives.
113
+ if (secondPeak - firstPeak <= LUMINANCE_BUCKETS / 16) {
114
+ return -1;
115
+ }
116
+
117
+ // Find a valley between them that is low and closer to the white peak.
118
+ int bestValley = secondPeak - 1;
119
+ int bestValleyScore = -1;
120
+ for (int x = secondPeak - 1; x > firstPeak; x--) {
121
+ int fromFirst = x - firstPeak;
122
+ int score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]);
123
+ if (score > bestValleyScore) {
124
+ bestValley = x;
125
+ bestValleyScore = score;
126
+ }
127
+ }
128
+
129
+ return bestValley << LUMINANCE_SHIFT;
130
+ }
131
+
132
+ bool GlobalHistogramBinarizer::getPatternRow(int row, int rotation, PatternRow& res) const
133
+ {
134
+ auto buffer = _buffer.rotated(rotation);
135
+ auto lineView = RowView(buffer, row);
136
+
137
+ if (buffer.width() < 3)
138
+ return false; // special casing the code below for a width < 3 makes no sense
139
+
140
+ #if defined(__AVX__) || defined(__ARM_NEON)
141
+ // If we are extracting a column (instead of a row), we run into cache misses on every pixel access both
142
+ // during the histogram calculation and during the sharpen+threshold operation. Additionally, if we
143
+ // perform the ThresholdSharpened function on pixStride==1 data, the auto-vectorizer makes that part
144
+ // 8x faster on an AVX2 cpu which easily recovers the extra cost that we pay for the copying.
145
+ ZX_THREAD_LOCAL std::vector<uint8_t> line;
146
+ if (std::abs(buffer.pixStride()) > 4) {
147
+ line.resize(lineView.size());
148
+ std::copy(lineView.begin(), lineView.end(), line.begin());
149
+ lineView = {{line.data(), 1}, {line.data() + line.size(), 1}};
150
+ }
151
+ #endif
152
+
153
+ auto packedLineView =
154
+ lineView.begin().stride == 1 ? Range(lineView.begin().pos, lineView.end().pos) : Range<const uint8_t*>(nullptr, nullptr);
155
+ auto histogram = packedLineView ? GenHistogram(packedLineView) : GenHistogram(lineView);
156
+ auto threshold = EstimateBlackPoint(histogram) - 1;
157
+ if (threshold <= 0)
158
+ return false;
159
+
160
+ ZX_THREAD_LOCAL std::vector<uint8_t> binarized;
161
+ // the optimizer can generate a specialized version for pixStride==1 (non-rotated input) that is about 8x faster on AVX2 hardware
162
+ if (packedLineView)
163
+ ThresholdSharpened(packedLineView, threshold, binarized);
164
+ else
165
+ ThresholdSharpened(lineView, threshold, binarized);
166
+ GetPatternRow(Range(binarized), res);
167
+
168
+ return true;
169
+ }
170
+
171
+ // Does not sharpen the data, as this call is intended to only be used by 2D Readers.
172
+ std::shared_ptr<const BitMatrix>
173
+ GlobalHistogramBinarizer::getBlackMatrix() const
174
+ {
175
+ // Quickly calculates the histogram by sampling four rows from the image. This proved to be
176
+ // more robust on the blackbox tests than sampling a diagonal as we used to do.
177
+ Histogram localBuckets = {};
178
+ {
179
+ for (int y = 1; y < 5; y++) {
180
+ int row = height() * y / 5;
181
+ const uint8_t* luminances = _buffer.data(0, row);
182
+ int right = (width() * 4) / 5;
183
+ for (int x = width() / 5; x < right; x++)
184
+ localBuckets[luminances[x] >> LUMINANCE_SHIFT]++;
185
+ }
186
+ }
187
+
188
+ int blackPoint = EstimateBlackPoint(localBuckets);
189
+ if (blackPoint <= 0)
190
+ return {};
191
+
192
+
193
+
194
+ return std::make_shared<const BitMatrix>(binarize(blackPoint));
195
+ }
196
+
197
+ } // ZXing
@@ -0,0 +1,34 @@
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 "BinaryBitmap.h"
10
+
11
+ namespace ZXing {
12
+
13
+ /**
14
+ * This Binarizer implementation uses the old ZXing global histogram approach. It is suitable
15
+ * for low-end mobile devices which don't have enough CPU or memory to use a local thresholding
16
+ * algorithm. However, because it picks a global black point, it cannot handle difficult shadows
17
+ * and gradients.
18
+ *
19
+ * Faster mobile devices and all desktop applications should probably use HybridBinarizer instead.
20
+ *
21
+ * @author dswitkin@google.com (Daniel Switkin)
22
+ * @author Sean Owen
23
+ */
24
+ class GlobalHistogramBinarizer : public BinaryBitmap
25
+ {
26
+ public:
27
+ explicit GlobalHistogramBinarizer(const ImageView& buffer);
28
+ ~GlobalHistogramBinarizer() override;
29
+
30
+ bool getPatternRow(int row, int rotation, PatternRow &res) const override;
31
+ std::shared_ptr<const BitMatrix> getBlackMatrix() const override;
32
+ };
33
+
34
+ } // ZXing
@@ -0,0 +1,124 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ * Copyright 2020 Axel Waggershauser
5
+ */
6
+ // SPDX-License-Identifier: Apache-2.0
7
+
8
+ #include "GridSampler.h"
9
+
10
+ #ifdef PRINT_DEBUG
11
+ #include "LogMatrix.h"
12
+ #include "BitMatrixIO.h"
13
+ #endif
14
+
15
+ namespace ZXing {
16
+
17
+ #ifdef PRINT_DEBUG
18
+ LogMatrix log;
19
+ #endif
20
+
21
+ DetectorResult SampleGrid(const BitMatrix& image, int width, int height, const PerspectiveTransform& mod2Pix)
22
+ {
23
+ return SampleGrid(image, width, height, {ROI{0, width, 0, height, mod2Pix}});
24
+ }
25
+
26
+ DetectorResult SampleGrid(const BitMatrix& image, int width, int height, const ROIs& rois)
27
+ {
28
+ #ifdef PRINT_DEBUG
29
+ LogMatrix log;
30
+ static int i = 0;
31
+ LogMatrixWriter lmw(log, image, 5, "grid" + std::to_string(i++) + ".pnm");
32
+ #endif
33
+ if (width <= 0 || height <= 0)
34
+ return {};
35
+
36
+ for (auto&& [x0, x1, y0, y1, mod2Pix] : rois) {
37
+ // Precheck the corners of every roi to bail out early if the grid is "obviously" not completely inside the image
38
+ auto isInside = [&mod2Pix = mod2Pix, &image](int x, int y) { return image.isIn(mod2Pix(centered(PointI(x, y)))); };
39
+ if (!mod2Pix.isValid() || !isInside(x0, y0) || !isInside(x1 - 1, y0) || !isInside(x1 - 1, y1 - 1) || !isInside(x0, y1 - 1))
40
+ return {};
41
+ }
42
+
43
+ BitMatrix res(width, height);
44
+ for (auto&& [x0, x1, y0, y1, mod2Pix] : rois) {
45
+ for (int y = y0; y < y1; ++y)
46
+ for (int x = x0; x < x1; ++x) {
47
+ auto p = mod2Pix(centered(PointI{x, y}));
48
+ // Due to a "numerical instability" in the PerspectiveTransform generation/application it has been observed
49
+ // that even though all boundary grid points get projected inside the image, it can still happen that an
50
+ // inner grid points is not. See #563. A true perspective transformation cannot have this property.
51
+ // The following check takes 100% care of the issue and turned out to be less of a performance impact than feared.
52
+ // TODO: Check some mathematical/numercial property of mod2Pix to determine if it is a perspective transformation.
53
+ if (!image.isIn(p))
54
+ return {};
55
+
56
+ #ifdef PRINT_DEBUG
57
+ log(p, 3);
58
+ #endif
59
+ #if 0
60
+ int sum = 0;
61
+ for (int dy = -1; dy <= 1; ++dy)
62
+ for (int dx = -1; dx <= 1; ++dx)
63
+ sum += image.get(p + PointF(dx, dy));
64
+ if (sum >= 5)
65
+ #else
66
+ if (image.get(p))
67
+ #endif
68
+ res.set(x, y);
69
+ }
70
+ }
71
+
72
+ #ifdef PRINT_DEBUG
73
+ printf("width: %d, height: %d\n", width, height);
74
+ // printf("%s", ToString(res).c_str());
75
+ #endif
76
+
77
+ auto projectCorner = [&](PointI p) {
78
+ for (auto&& [x0, x1, y0, y1, mod2Pix] : rois)
79
+ if (x0 <= p.x && p.x <= x1 && y0 <= p.y && p.y <= y1)
80
+ return PointI(mod2Pix(PointF(p)) + PointF(0.5, 0.5));
81
+
82
+ return PointI();
83
+ };
84
+
85
+ return {std::move(res),
86
+ {projectCorner({0, 0}), projectCorner({width, 0}), projectCorner({width, height}), projectCorner({0, height})}};
87
+ }
88
+
89
+ DetectorResult SampleGrid(const BitMatrix& image, int width, int height, const PerspectiveTransform& mod2Pix,
90
+ Matrix<std::optional<PointF>>&& apP, const std::vector<int>& apMX, const std::vector<int>& apMY)
91
+ {
92
+ const int W = Size(apMX) - 1, H = Size(apMY) - 1;
93
+
94
+ // go over the set of alignment patters and fill any remaining gaps by a projection based on the fallback
95
+ // mod2Pix projection. This works if the symbol is flat, which is a reasonable fall-back assumption.
96
+ for (int y = 0; y <= H; ++y)
97
+ for (int x = 0; x <= W; ++x) {
98
+ if (apP(x, y)) {
99
+ #ifdef PRINT_DEBUG
100
+ log(*apP(x, y), 2);
101
+ #endif
102
+ } else {
103
+ #ifdef PRINT_DEBUG
104
+ printf("locate failed at %dx%d\n", x, y);
105
+ #endif
106
+ // project the alignment pattern at module coordinates x/y to pixel coordinate based on current mod2Pix
107
+ apP.set(x, y, mod2Pix(centered(PointI(apMX[x], apMY[y]))));
108
+ }
109
+ }
110
+
111
+ // assemble a list of region-of-interests based on the found alignment pattern pixel positions
112
+ ROIs rois;
113
+ for (int y = 0; y < H; ++y)
114
+ for (int x = 0; x < W; ++x) {
115
+ int x0 = apMX[x], x1 = apMX[x + 1], y0 = apMY[y], y1 = apMY[y + 1];
116
+ rois.push_back({x == 0 ? 0 : x0, (x == W - 1) ? width : x1, (y == 0) ? 0 : y0, (y == H - 1) ? height : y1,
117
+ PerspectiveTransform{Rectangle(x0, x1, y0, y1, 0.5),
118
+ {*apP(x, y), *apP(x + 1, y), *apP(x + 1, y + 1), *apP(x, y + 1)}}});
119
+ }
120
+
121
+ return SampleGrid(image, width, height, rois);
122
+ }
123
+
124
+ } // ZXing