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,97 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "ODITFReader.h"
8
+
9
+ #include "ReaderOptions.h"
10
+ #include "GTIN.h"
11
+ #include "Barcode.h"
12
+ #include "BarcodeData.h"
13
+ #include "SymbologyIdentifier.h"
14
+ #include "ZXAlgorithms.h"
15
+
16
+ namespace ZXing::OneD {
17
+
18
+ BarcodeData ITFReader::decodePattern(int rowNumber, PatternView& next, std::unique_ptr<DecodingState>&) const
19
+ {
20
+ const int minCharCount = _opts.formats().size() == 1 ? 4 : 6; // if we are only looking for ITF, we accept shorter symbols
21
+ const int minQuietZone = 6; // spec requires 10
22
+
23
+ next = FindLeftGuard(next, 4 + 10 + 3, FixedPattern<4, 4>{1, 1, 1, 1}, minQuietZone);
24
+ if (!next.isValid())
25
+ return {};
26
+
27
+ // get threshold of first character pair
28
+ auto threshold = NarrowWideThreshold(next.subView(4, 10));
29
+ if (!threshold.isValid())
30
+ return {};
31
+ // check that each bar/space in the start pattern is < threshold
32
+ for (int i = 0; i < 4; ++i)
33
+ if (next[i] > threshold[i])
34
+ return {};
35
+
36
+ constexpr int weights[] = {1, 2, 4, 7, 0};
37
+ int xStart = next.pixelsInFront();
38
+ bool startsAtFirstBar = next.isAtFirstBar();
39
+
40
+ next = next.subView(4, 10);
41
+
42
+ std::string txt;
43
+ txt.reserve(20);
44
+
45
+ while (next.isValid()) {
46
+ // look for end-of-symbol
47
+ if (next[3] > threshold.space * 3)
48
+ break;
49
+
50
+ BarAndSpace<int> digits, numWide;
51
+ bool bad = false;
52
+ for (int i = 0; i < 10; ++i) {
53
+ bad |= next[i] > threshold[i] * 3 || next[i] < threshold[i] / 3;
54
+ numWide[i] += next[i] > threshold[i];
55
+ digits[i] += weights[i/2] * (next[i] > threshold[i]);
56
+ }
57
+
58
+ if (bad || numWide.bar != 2 || numWide.space != 2)
59
+ break;
60
+
61
+ for (int i = 0; i < 2; ++i)
62
+ txt.push_back(ToDigit(digits[i] == 11 ? 0 : digits[i]));
63
+
64
+ // update threshold to support scanning slanted symbols (scanned non-perpendicular)
65
+ threshold = NarrowWideThreshold(next);
66
+
67
+ next.skipSymbol();
68
+ }
69
+
70
+ next = next.subView(0, 3);
71
+
72
+ // Check stop pattern
73
+ if (!next.isValid() || !threshold.isValid()
74
+ || next[0] < threshold[0] || next[1] > threshold[1] || next[2] > threshold[2])
75
+ return {};
76
+
77
+ // Check quiet zone size (full quiet zone on both ends or cropped on both ends)
78
+ if (!(std::min((int)next[3], xStart) > minQuietZone * (threshold.bar + threshold.space) / 3
79
+ || (next.isAtLastBar() && startsAtFirstBar && std::max(xStart, (int)next[3]) < 2 * std::min(xStart, (int)next[3]) + 2)))
80
+ return {};
81
+
82
+ // Check min length depending on whether the code covers the complete image or not
83
+ if (Size(txt) < (startsAtFirstBar && next.isAtLastBar() ? (minCharCount / 2) : minCharCount))
84
+ return {};
85
+
86
+ Error error = _opts.validateOptionalChecksum() && !GTIN::IsCheckDigitValid(txt) ? ChecksumError() : Error();
87
+
88
+ // Symbology identifier ISO/IEC 16390:2007 Annex C Table C.1
89
+ // See also GS1 General Specifications 5.1.2 Figure 5.1.2-2
90
+ SymbologyIdentifier symbologyIdentifier = {'I', GTIN::IsCheckDigitValid(txt) ? '1' : '0'};
91
+
92
+ int xStop = next.pixelsTillEnd();
93
+
94
+ return LinearBarcode(BarcodeFormat::ITF, txt, rowNumber, xStart, xStop, symbologyIdentifier, error);
95
+ }
96
+
97
+ } // namespace ZXing::OneD
@@ -0,0 +1,33 @@
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 "ODRowReader.h"
10
+
11
+ namespace ZXing::OneD {
12
+
13
+ /**
14
+ * <p>Implements decoding of the ITF format, or Interleaved Two of Five.</p>
15
+ *
16
+ * <p>This Reader will scan ITF barcodes of certain lengths only.
17
+ * At the moment it reads length >= 6. Not all lengths are scanned, especially shorter ones, to avoid false positives.
18
+ * This in turn is due to a lack of required checksum function.</p>
19
+ *
20
+ * <p>According to the specification, the modifier (3rd char) of the symbologyIdentifier is '1' iff the symbol has a valid checksum</p>
21
+ *
22
+ * <p><a href="http://en.wikipedia.org/wiki/Interleaved_2_of_5">http://en.wikipedia.org/wiki/Interleaved_2_of_5</a>
23
+ * is a great reference for Interleaved 2 of 5 information.</p>
24
+ */
25
+ class ITFReader : public RowReader
26
+ {
27
+ public:
28
+ using RowReader::RowReader;
29
+
30
+ BarcodeData decodePattern(int rowNumber, PatternView& next, std::unique_ptr<DecodingState>&) const override;
31
+ };
32
+
33
+ } // namespace ZXing::OneD
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "ODITFWriter.h"
8
+
9
+ #include "ODWriterHelper.h"
10
+ #include "Utf.h"
11
+
12
+ #include <array>
13
+ #include <stdexcept>
14
+ #include <vector>
15
+
16
+ namespace ZXing::OneD {
17
+
18
+ static const std::array<int, 4> START_PATTERN = { 1, 1, 1, 1 };
19
+ static const std::array<int, 3> END_PATTERN = { 3, 1, 1 };
20
+
21
+ static const int W = 3; // Pixel width of a wide line
22
+ static const int N = 1; // Pixed width of a narrow line
23
+
24
+ /**
25
+ * Patterns of Wide / Narrow lines to indicate each digit
26
+ */
27
+ static const std::array<std::array<int, 5>, 10> PATTERNS = {
28
+ N, N, W, W, N, // 0
29
+ W, N, N, N, W, // 1
30
+ N, W, N, N, W, // 2
31
+ W, W, N, N, N, // 3
32
+ N, N, W, N, W, // 4
33
+ W, N, W, N, N, // 5
34
+ N, W, W, N, N, // 6
35
+ N, N, N, W, W, // 7
36
+ W, N, N, W, N, // 8
37
+ N, W, N, W, N, // 9
38
+ };
39
+
40
+ BitMatrix
41
+ ITFWriter::encode(const std::wstring& contents, int width, int height) const
42
+ {
43
+ size_t length = contents.length();
44
+ if (length == 0) {
45
+ throw std::invalid_argument("Found empty contents");
46
+ }
47
+ if (length % 2 != 0) {
48
+ throw std::invalid_argument("The length of the input should be even");
49
+ }
50
+ if (length > 80) {
51
+ throw std::invalid_argument("Requested contents should be less than 80 digits long");
52
+ }
53
+
54
+ std::vector<bool> result(9 + 9 * length, false);
55
+ int pos = WriterHelper::AppendPattern(result, 0, START_PATTERN, true);
56
+ for (size_t i = 0; i < length; i += 2) {
57
+ int one = contents[i] - '0';
58
+ int two = contents[i + 1] - '0';
59
+ if (one < 0 || one > 9 || two < 0 || two > 9) {
60
+ throw std::invalid_argument("Contents should contain only digits: 0-9");
61
+ }
62
+ std::array<int, 10> encoding = {};
63
+ for (int j = 0; j < 5; j++) {
64
+ encoding[2 * j] = PATTERNS[one][j];
65
+ encoding[2 * j + 1] = PATTERNS[two][j];
66
+ }
67
+ pos += WriterHelper::AppendPattern(result, pos, encoding, true);
68
+ }
69
+ WriterHelper::AppendPattern(result, pos, END_PATTERN, true);
70
+ return WriterHelper::RenderResult(result, width, height, _sidesMargin >= 0 ? _sidesMargin : 10);
71
+ }
72
+
73
+ BitMatrix ITFWriter::encode(const std::string& contents, int width, int height) const
74
+ {
75
+ return encode(FromUtf8(contents), width, height);
76
+ }
77
+
78
+ } // namespace ZXing::OneD
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Copyright 2016 Huy Cuong Nguyen
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #pragma once
8
+
9
+ #include <string>
10
+
11
+ namespace ZXing {
12
+
13
+ class BitMatrix;
14
+
15
+ namespace OneD {
16
+
17
+ /**
18
+ * This object renders a ITF code as a {@link BitMatrix}.
19
+ *
20
+ * @author erik.barbara@gmail.com (Erik Barbara)
21
+ */
22
+ class ITFWriter
23
+ {
24
+ public:
25
+ ITFWriter& setMargin(int sidesMargin) { _sidesMargin = sidesMargin; return *this; }
26
+ BitMatrix encode(const std::wstring& contents, int width, int height) const;
27
+ BitMatrix encode(const std::string& contents, int width, int height) const;
28
+
29
+ private:
30
+ int _sidesMargin = -1;
31
+ };
32
+
33
+ } // OneD
34
+ } // ZXing
@@ -0,0 +1,323 @@
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 "ODMultiUPCEANReader.h"
9
+
10
+ #include "BarcodeFormat.h"
11
+ #include "BitArray.h"
12
+ #include "ReaderOptions.h"
13
+ #include "GTIN.h"
14
+ #include "ODUPCEANCommon.h"
15
+ #include "Barcode.h"
16
+ #include "JSON.h"
17
+ #include "SymbologyIdentifier.h"
18
+
19
+ #include <cmath>
20
+
21
+ namespace ZXing::OneD {
22
+
23
+ constexpr int CHAR_LEN = 4;
24
+
25
+ constexpr auto END_PATTERN = FixedPattern<3, 3>{1, 1, 1};
26
+ constexpr auto MID_PATTERN = FixedPattern<5, 5>{1, 1, 1, 1, 1};
27
+ constexpr auto UPCE_END_PATTERN = FixedPattern<6, 6>{1, 1, 1, 1, 1, 1};
28
+ constexpr auto EXT_START_PATTERN = FixedPattern<3, 4>{1, 1, 2};
29
+ constexpr auto EXT_SEPARATOR_PATTERN = FixedPattern<2, 2>{1, 1};
30
+
31
+ static const int FIRST_DIGIT_ENCODINGS[] = {0x00, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A};
32
+
33
+ // The GS1 specification has the following to say about quiet zones
34
+ // Type: EAN-13 | EAN-8 | UPC-A | UPC-E | EAN Add-on | UPC Add-on
35
+ // QZ L: 11 | 7 | 9 | 9 | 7-12 | 9-12
36
+ // QZ R: 7 | 7 | 9 | 7 | 5 | 5
37
+
38
+ constexpr float QUIET_ZONE_LEFT = 6;
39
+ constexpr float QUIET_ZONE_RIGHT_EAN = 3; // used to be 6, see #526 and #558
40
+ constexpr float QUIET_ZONE_RIGHT_UPC = 6;
41
+ constexpr float QUIET_ZONE_ADDON = 3;
42
+
43
+ // There is a single sample (ean13-1/12.png) that fails to decode with these (new) settings because
44
+ // it has a right-side quiet zone of only about 4.5 modules, which is clearly out of spec.
45
+
46
+ static bool DecodeDigit(const PatternView& view, std::string& txt, int* lgPattern = nullptr)
47
+ {
48
+ #if 1
49
+ // These two values are critical for determining how permissive the decoding will be.
50
+ // We've arrived at these values through a lot of trial and error. Setting them any higher
51
+ // lets false positives creep in quickly.
52
+ static constexpr float MAX_AVG_VARIANCE = 0.48f;
53
+ static constexpr float MAX_INDIVIDUAL_VARIANCE = 0.7f;
54
+
55
+ int bestMatch =
56
+ lgPattern ? RowReader::DecodeDigit(view, UPCEANCommon::L_AND_G_PATTERNS, MAX_AVG_VARIANCE, MAX_INDIVIDUAL_VARIANCE, false)
57
+ : RowReader::DecodeDigit(view, UPCEANCommon::L_PATTERNS, MAX_AVG_VARIANCE, MAX_INDIVIDUAL_VARIANCE, false);
58
+ if (bestMatch == -1)
59
+ return false;
60
+
61
+ txt += ToDigit(bestMatch % 10);
62
+ if (lgPattern)
63
+ AppendBit(*lgPattern, bestMatch >= 10);
64
+
65
+ return true;
66
+ #else
67
+ constexpr int CHAR_SUM = 7;
68
+ auto pattern = RowReader::OneToFourBitPattern<CHAR_LEN, CHAR_SUM>(view);
69
+
70
+ // remove first and last bit
71
+ pattern = (~pattern >> 1) & 0b11111;
72
+
73
+ // clang-format off
74
+ /* pattern now contains the central 5 bits of the L/G/R code
75
+ * L/G-codes always start with 1 and end with 0, R-codes are simply
76
+ * inverted L-codes.
77
+
78
+ L-Code G-Code R-Code
79
+ ___________________________________
80
+ 0 00110 10011 11001
81
+ 1 01100 11001 10011
82
+ 2 01001 01101 10110
83
+ 3 11110 10000 00001
84
+ 4 10001 01110 01110
85
+ 5 11000 11100 00111
86
+ 6 10111 00010 01000
87
+ 7 11101 01000 00010
88
+ 8 11011 00100 00100
89
+ 9 00101 01011 11010
90
+ */
91
+ constexpr char I = 0xf0; // invalid pattern
92
+
93
+ const char digit[] = {I, I, 0x16, I, 0x18, 0x09, 0x00, I,
94
+ 0x17, 0x02, I, 0x19, 0x01, 0x12, 0x14, I,
95
+ 0x13, 0x04, I, 0x10, I, I, I, 0x06,
96
+ 0x05, 0x11, I, 0x08, 0x15, 0x07, 0x03, I};
97
+ // clang-format on
98
+
99
+ char d = digit[pattern];
100
+ txt += ToDigit(d & 0xf);
101
+ if (lgPattern)
102
+ AppendBit(*lgPattern, (d >> 4) & 1);
103
+
104
+ return d != I;
105
+ #endif
106
+ }
107
+
108
+ static bool DecodeDigits(int digitCount, PatternView& next, std::string& txt, int* lgPattern = nullptr)
109
+ {
110
+ for (int j = 0; j < digitCount; ++j, next.skipSymbol())
111
+ if (!DecodeDigit(next, txt, lgPattern))
112
+ return false;
113
+ return true;
114
+ }
115
+
116
+ struct PartialResult
117
+ {
118
+ std::string txt;
119
+ PatternView end;
120
+ BarcodeFormat format = BarcodeFormat::None;
121
+
122
+ PartialResult() { txt.reserve(14); }
123
+ bool isValid() const { return format != BarcodeFormat::None; }
124
+ };
125
+
126
+ bool _ret_false_debug_helper()
127
+ {
128
+ return false;
129
+ }
130
+ #define CHECK(A) if(!(A)) return _ret_false_debug_helper();
131
+
132
+ static bool EAN13(PartialResult& res, PatternView begin)
133
+ {
134
+ auto mid = begin.subView(27, MID_PATTERN.size());
135
+ auto end = begin.subView(56, END_PATTERN.size());
136
+
137
+ CHECK(IsRightGuard(end, END_PATTERN, QUIET_ZONE_RIGHT_EAN) && IsPattern(mid, MID_PATTERN));
138
+
139
+ auto next = begin.subView(END_PATTERN.size(), CHAR_LEN);
140
+ res.txt = " "; // make space for lgPattern character
141
+ int lgPattern = 0;
142
+
143
+ CHECK(DecodeDigits(6, next, res.txt, &lgPattern));
144
+
145
+ next = next.subView(MID_PATTERN.size(), CHAR_LEN);
146
+
147
+ CHECK(DecodeDigits(6, next, res.txt));
148
+
149
+ int i = IndexOf(FIRST_DIGIT_ENCODINGS, lgPattern);
150
+ CHECK(i != -1);
151
+ res.txt[0] = ToDigit(i);
152
+
153
+ res.end = end;
154
+ res.format = BarcodeFormat::EAN13;
155
+ return true;
156
+ }
157
+
158
+ static bool PlausibleDigitModuleSize(PatternView begin, int start, int i, float moduleSizeRef)
159
+ {
160
+ float moduleSizeData = begin.subView(start + i * 4, 4).sum() / 7.f;
161
+ return std::abs(moduleSizeData / moduleSizeRef - 1) < 0.2f;
162
+ }
163
+
164
+ static bool EAN8(PartialResult& res, PatternView begin)
165
+ {
166
+ auto mid = begin.subView(19, MID_PATTERN.size());
167
+ auto end = begin.subView(40, END_PATTERN.size());
168
+
169
+ CHECK(IsRightGuard(end, END_PATTERN, QUIET_ZONE_RIGHT_EAN) && IsPattern(mid, MID_PATTERN));
170
+
171
+ // additional plausibility check for the module size: it has to be about the same for both
172
+ // the guard patterns and the payload/data part.
173
+ float moduleSizeGuard = (begin.sum() + mid.sum() + end.sum()) / 11.f;
174
+ for (auto start : {3, 24})
175
+ for (int i = 0; i < 4; ++i)
176
+ CHECK(PlausibleDigitModuleSize(begin, start, i, moduleSizeGuard));
177
+
178
+ auto next = begin.subView(END_PATTERN.size(), CHAR_LEN);
179
+ res.txt.clear();
180
+
181
+ CHECK(DecodeDigits(4, next, res.txt));
182
+
183
+ next = next.subView(MID_PATTERN.size(), CHAR_LEN);
184
+
185
+ CHECK(DecodeDigits(4, next, res.txt));
186
+
187
+ res.end = end;
188
+ res.format = BarcodeFormat::EAN8;
189
+ return true;
190
+ }
191
+
192
+ static bool UPCE(PartialResult& res, PatternView begin)
193
+ {
194
+ auto end = begin.subView(27, UPCE_END_PATTERN.size());
195
+
196
+ CHECK(IsRightGuard(end, UPCE_END_PATTERN, QUIET_ZONE_RIGHT_UPC));
197
+
198
+ // additional plausibility check for the module size: it has to be about the same for both
199
+ // the guard patterns and the payload/data part. This speeds up the falsepositives use case
200
+ // about 2x and brings the misread count down to 0
201
+ float moduleSizeGuard = (begin.sum() + end.sum()) / 9.f;
202
+ for (int i = 0; i < 6; ++i)
203
+ CHECK(PlausibleDigitModuleSize(begin, 3, i, moduleSizeGuard));
204
+
205
+ auto next = begin.subView(END_PATTERN.size(), CHAR_LEN);
206
+ int lgPattern = 0;
207
+ res.txt = " "; // make space for lgPattern character
208
+
209
+ CHECK(DecodeDigits(6, next, res.txt, &lgPattern));
210
+
211
+ int i = IndexOf(UPCEANCommon::NUMSYS_AND_CHECK_DIGIT_PATTERNS, lgPattern);
212
+ CHECK(i != -1);
213
+
214
+ res.txt[0] = ToDigit(i / 10);
215
+ res.txt += ToDigit(i % 10);
216
+
217
+ res.end = end;
218
+ res.format = BarcodeFormat::UPCE;
219
+ return true;
220
+ }
221
+
222
+ static int Ean5Checksum(const std::string& s)
223
+ {
224
+ int sum = 0, N = Size(s);
225
+ for (int i = N - 2; i >= 0; i -= 2)
226
+ sum += s[i] - '0';
227
+ sum *= 3;
228
+ for (int i = N - 1; i >= 0; i -= 2)
229
+ sum += s[i] - '0';
230
+ sum *= 3;
231
+ return sum % 10;
232
+ }
233
+
234
+ static bool AddOn(PartialResult& res, PatternView begin, int digitCount)
235
+ {
236
+ auto ext = begin.subView(0, 3 + digitCount * 4 + (digitCount - 1) * 2);
237
+ CHECK(ext.isValid());
238
+ auto moduleSize = IsPattern(ext, EXT_START_PATTERN);
239
+ CHECK(moduleSize);
240
+
241
+ CHECK(ext.isAtLastBar() || *ext.end() > QUIET_ZONE_ADDON * moduleSize - 1);
242
+
243
+ res.end = ext;
244
+ ext = ext.subView(EXT_START_PATTERN.size(), CHAR_LEN);
245
+ int lgPattern = 0;
246
+ res.txt.clear();
247
+
248
+ for (int i = 0; i < digitCount; ++i) {
249
+ CHECK(DecodeDigit(ext, res.txt, &lgPattern));
250
+ ext.skipSymbol();
251
+ if (i < digitCount - 1) {
252
+ CHECK(IsPattern(ext, EXT_SEPARATOR_PATTERN, 0, 0, moduleSize));
253
+ ext.skipPair();
254
+ }
255
+ }
256
+
257
+ if (digitCount == 2) {
258
+ CHECK(std::stoi(res.txt) % 4 == lgPattern);
259
+ } else {
260
+ constexpr int CHECK_DIGIT_ENCODINGS[] = {0x18, 0x14, 0x12, 0x11, 0x0C, 0x06, 0x03, 0x0A, 0x09, 0x05};
261
+ CHECK(Ean5Checksum(res.txt) == IndexOf(CHECK_DIGIT_ENCODINGS, lgPattern));
262
+ }
263
+ res.format = BarcodeFormat::EANUPC; // make sure res.format is valid, see below
264
+ return true;
265
+ }
266
+
267
+ BarcodeData MultiUPCEANReader::decodePattern(int rowNumber, PatternView& next, std::unique_ptr<RowReader::DecodingState>&) const
268
+ {
269
+ const int minSize = 3 + 6*4 + 6; // UPC-E
270
+
271
+ next = FindLeftGuard(next, minSize, END_PATTERN, QUIET_ZONE_LEFT);
272
+ if (!next.isValid())
273
+ return {};
274
+
275
+ PartialResult res;
276
+ auto begin = next;
277
+
278
+ if (!((((readEAN13 || readUPCA) && EAN13(res, begin)) || (readEAN8 && EAN8(res, begin)) || (readUPCE && UPCE(res, begin)))))
279
+ return {};
280
+
281
+ // ISO/IEC 15420:2009 (& GS1 General Specifications 5.1.3) states that the content for "]E0" should be 13 digits,
282
+ // i.e. converted to EAN-13 if UPC-A/E
283
+ std::string upceTxt;
284
+ if (res.format == BarcodeFormat::UPCE) {
285
+ upceTxt = res.txt;
286
+ res.txt = "0" + UPCEANCommon::ConvertUPCEtoUPCA(res.txt);
287
+ }
288
+
289
+ Error error = !GTIN::IsCheckDigitValid(res.txt) ? ChecksumError() : Error();
290
+
291
+ // if we explicitly excluded EAN13, don't return an EAN13 symbol
292
+ if (res.format == BarcodeFormat::EAN13 && !readEAN13) {
293
+ if (res.txt.front() == '0')
294
+ res.format = BarcodeFormat::UPCA;
295
+ else
296
+ return {};
297
+ }
298
+
299
+ // Symbology identifier modifiers ISO/IEC 15420:2009 Annex B Table B.1
300
+ SymbologyIdentifier symbologyIdentifier = {'E', res.format == BarcodeFormat::EAN8 ? '4' : '0'};
301
+
302
+ next = res.end;
303
+
304
+ auto ext = res.end;
305
+ PartialResult addOnRes;
306
+ if (_opts.eanAddOnSymbol() != EanAddOnSymbol::Ignore && ext.skipSymbol()
307
+ && ext.skipSingle(static_cast<int>(begin.sum() * 3.5)) && (AddOn(addOnRes, ext, 5) || AddOn(addOnRes, ext, 2))) {
308
+ res.txt += addOnRes.txt;
309
+ next = addOnRes.end;
310
+ // ISO/IEC 15420:2009 states that the content for "]E3" should be 15 or 18 digits, i.e. converted to EAN-13
311
+ // and extended with no separator, and that the content for "]E4" should be 8 digits, i.e. no add-on
312
+ // @gitlost and @axxel decided to extend the spec here to simply add an EAN-8 + add-on option
313
+ symbologyIdentifier.modifier = '3'; // Combined packet, EAN-13, UPC-A, UPC-E, with add-on
314
+ }
315
+
316
+ if (_opts.eanAddOnSymbol() == EanAddOnSymbol::Require && !addOnRes.isValid())
317
+ return {};
318
+
319
+ return LinearBarcode(res.format, res.txt, rowNumber, begin.pixelsInFront(), next.pixelsTillEnd(), symbologyIdentifier, error,
320
+ JsonProp(BarcodeExtra::UPCE, upceTxt) + JsonProp(BarcodeExtra::EanAddOn, addOnRes.txt));
321
+ }
322
+
323
+ } // namespace ZXing::OneD
@@ -0,0 +1,32 @@
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 "ODRowReader.h"
10
+
11
+ namespace ZXing::OneD {
12
+
13
+ /**
14
+ * @brief A reader that can read all available UPC/EAN formats.
15
+ */
16
+ class MultiUPCEANReader : public RowReader
17
+ {
18
+ bool readEAN8, readEAN13, readUPCA, readUPCE;
19
+ public:
20
+ explicit MultiUPCEANReader(const ReaderOptions& opts)
21
+ : RowReader(opts),
22
+ readEAN8(opts.hasFormat(BarcodeFormat::EAN8)),
23
+ readEAN13(opts.hasFormat(BarcodeFormat::EAN13)),
24
+ readUPCA(opts.hasFormat(BarcodeFormat::UPCA)),
25
+ readUPCE(opts.hasFormat(BarcodeFormat::UPCE))
26
+ {}
27
+
28
+ BarcodeData decodePattern(int rowNumber, PatternView& next, std::unique_ptr<DecodingState>&) const override;
29
+ };
30
+
31
+ } // namespace ZXing::OneD
32
+