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
+ * Copyright 2022 Axel Waggershauser
5
+ */
6
+ // SPDX-License-Identifier: Apache-2.0
7
+
8
+ #include "ODDataBarExpandedBitDecoder.h"
9
+
10
+ #include "BitArray.h"
11
+ #include "Error.h"
12
+ #include "GTIN.h"
13
+ #include <stdexcept>
14
+
15
+ namespace ZXing::OneD::DataBar {
16
+
17
+ constexpr char GS = 29; // FNC1
18
+
19
+ static std::string DecodeGeneralPurposeBits(BitArrayView& bits)
20
+ {
21
+ enum State { NUMERIC, ALPHA, ISO_IEC_646 };
22
+ State state = NUMERIC;
23
+ std::string res;
24
+
25
+ auto decode5Bits = [](State& state, std::string& res, BitArrayView& bits) {
26
+ int v = bits.readBits(5);
27
+ if (v == 4) {
28
+ state = state == ALPHA ? ISO_IEC_646 : ALPHA;
29
+ } else if (v == 15) { // FNC1 + latch to Numeric
30
+ res.push_back(GS);
31
+ state = NUMERIC;
32
+ // Allow for some generators incorrectly placing a numeric latch "000" after an FNC1
33
+ if (bits.size() >= 7 && bits.peekBits(7) < 8)
34
+ bits.skipBits(3);
35
+ } else {
36
+ res.push_back(v + 43);
37
+ }
38
+ };
39
+
40
+ auto isPadding = [](State state, BitArrayView& bits) {
41
+ bool res = (state == NUMERIC) ? bits.size() < 4
42
+ : bits.size() < 5 && (0b00100 >> (5 - bits.size()) == bits.peekBits(bits.size()));
43
+ if (res)
44
+ bits.skipBits(bits.size());
45
+ return res;
46
+ };
47
+
48
+ while(bits.size() >= 3) {
49
+ switch(state) {
50
+ case NUMERIC:
51
+ if (isPadding(state, bits))
52
+ break;
53
+ if (bits.size() < 7) {
54
+ int v = bits.readBits(4);
55
+ if (v > 0)
56
+ res.push_back(ToDigit(v - 1));
57
+ } else if (bits.peekBits(4) == 0) {
58
+ bits.skipBits(4);
59
+ state = ALPHA;
60
+ } else {
61
+ int v = bits.readBits(7);
62
+ for (int digit : {(v - 8) / 11, (v - 8) % 11})
63
+ res.push_back(digit == 10 ? GS : ToDigit(digit));
64
+ }
65
+ break;
66
+ case ALPHA:
67
+ if (isPadding(state, bits))
68
+ break;
69
+ if (bits.peekBits(1) == 1) {
70
+ constexpr char const* lut58to62 = R"(*,-./)";
71
+ int v = bits.readBits(6);
72
+ if (v < 58)
73
+ res.push_back(v + 33);
74
+ else if (v < 63)
75
+ res.push_back(lut58to62[v - 58]);
76
+ else
77
+ throw FormatError();
78
+ } else if (bits.peekBits(3) == 0) {
79
+ bits.skipBits(3);
80
+ state = NUMERIC;
81
+ } else {
82
+ decode5Bits(state, res, bits);
83
+ }
84
+ break;
85
+ case ISO_IEC_646:
86
+ if (isPadding(state, bits))
87
+ break;
88
+ if (bits.peekBits(3) == 0) {
89
+ bits.skipBits(3);
90
+ state = NUMERIC;
91
+ } else {
92
+ int v = bits.peekBits(5);
93
+ if (v < 16) {
94
+ decode5Bits(state, res, bits);
95
+ } else if (v < 29) {
96
+ v = bits.readBits(7);
97
+ res.push_back(v < 90 ? v + 1 : v + 7);
98
+ } else {
99
+ constexpr char const* lut232to252 = R"(!"%&'()*+,-./:;<=>?_ )";
100
+ v = bits.readBits(8);
101
+ if (v < 232 || 252 < v)
102
+ throw FormatError();
103
+ res.push_back(lut232to252[v - 232]);
104
+ }
105
+ }
106
+ break;
107
+ }
108
+ }
109
+
110
+ // in NUMERIC encodation there might be a trailing FNC1 that needs to be ignored
111
+ if (res.size() && res.back() == GS)
112
+ res.pop_back();
113
+
114
+ return res;
115
+ }
116
+
117
+ static std::string DecodeCompressedGTIN(std::string prefix, BitArrayView& bits)
118
+ {
119
+ for (int i = 0; i < 4; ++i)
120
+ prefix.append(ToString(bits.readBits(10), 3));
121
+
122
+ prefix.push_back(GTIN::ComputeCheckDigit(prefix.substr(2)));
123
+
124
+ return prefix;
125
+ }
126
+
127
+ static std::string DecodeAI01GTIN(BitArrayView& bits)
128
+ {
129
+ return DecodeCompressedGTIN("019", bits);
130
+ }
131
+
132
+ static std::string DecodeAI01AndOtherAIs(BitArrayView& bits)
133
+ {
134
+ bits.skipBits(2); // Variable length symbol bit field
135
+
136
+ auto header = DecodeCompressedGTIN("01" + std::to_string(bits.readBits(4)), bits);
137
+ auto trailer = DecodeGeneralPurposeBits(bits);
138
+
139
+ return header + trailer;
140
+ }
141
+
142
+ static std::string DecodeAnyAI(BitArrayView& bits)
143
+ {
144
+ bits.skipBits(2); // Variable length symbol bit field
145
+
146
+ return DecodeGeneralPurposeBits(bits);
147
+ }
148
+
149
+ static std::string DecodeAI013103(BitArrayView& bits)
150
+ {
151
+ std::string buffer = DecodeAI01GTIN(bits);
152
+ buffer.append("3103");
153
+ buffer.append(ToString(bits.readBits(15), 6));
154
+
155
+ return buffer;
156
+ }
157
+
158
+ static std::string DecodeAI01320x(BitArrayView& bits)
159
+ {
160
+ std::string buffer = DecodeAI01GTIN(bits);
161
+ int weight = bits.readBits(15);
162
+ buffer.append(weight < 10000 ? "3202" : "3203");
163
+ buffer.append(ToString(weight < 10000 ? weight : weight - 10000, 6));
164
+
165
+ return buffer;
166
+ }
167
+
168
+ static std::string DecodeAI0139yx(BitArrayView& bits, char y)
169
+ {
170
+ bits.skipBits(2); // Variable length symbol bit field
171
+
172
+ std::string buffer = DecodeAI01GTIN(bits);
173
+ buffer.append("39");
174
+ buffer.push_back(y);
175
+ buffer.append(std::to_string(bits.readBits(2)));
176
+
177
+ if (y == '3')
178
+ buffer.append(ToString(bits.readBits(10), 3));
179
+
180
+ auto trailer = DecodeGeneralPurposeBits(bits);
181
+ if (trailer.empty())
182
+ return {};
183
+
184
+ return buffer + trailer;
185
+ }
186
+
187
+ static std::string DecodeAI013x0x1x(BitArrayView& bits, const char* aiPrefix, const char* dateCode)
188
+ {
189
+ std::string buffer = DecodeAI01GTIN(bits);
190
+ buffer.append(aiPrefix);
191
+
192
+ int weight = bits.readBits(20);
193
+ buffer.append(std::to_string(weight / 100000));
194
+ buffer.append(ToString(weight % 100000, 6));
195
+
196
+ int date = bits.readBits(16);
197
+ if (date != 38400) {
198
+ buffer.append(dateCode);
199
+
200
+ int day = date % 32;
201
+ date /= 32;
202
+ int month = date % 12 + 1;
203
+ date /= 12;
204
+ int year = date;
205
+
206
+ buffer.append(ToString(year, 2));
207
+ buffer.append(ToString(month, 2));
208
+ buffer.append(ToString(day, 2));
209
+ }
210
+
211
+ return buffer;
212
+ }
213
+
214
+ std::string DecodeExpandedBits(const BitArray& _bits)
215
+ {
216
+ try {
217
+ auto bits = BitArrayView(_bits);
218
+ bits.readBits(1); // skip linkage bit
219
+
220
+ if (bits.peekBits(1) == 1)
221
+ return DecodeAI01AndOtherAIs(bits.skipBits(1));
222
+
223
+ if (bits.peekBits(2) == 0)
224
+ return DecodeAnyAI(bits.skipBits(2));
225
+
226
+ switch (bits.peekBits(4)) {
227
+ case 4: return DecodeAI013103(bits.skipBits(4));
228
+ case 5: return DecodeAI01320x(bits.skipBits(4));
229
+ }
230
+
231
+ switch (bits.peekBits(5)) {
232
+ case 12: return DecodeAI0139yx(bits.skipBits(5), '2');
233
+ case 13: return DecodeAI0139yx(bits.skipBits(5), '3');
234
+ }
235
+
236
+ switch (bits.readBits(7)) {
237
+ case 56: return DecodeAI013x0x1x(bits, "310", "11");
238
+ case 57: return DecodeAI013x0x1x(bits, "320", "11");
239
+ case 58: return DecodeAI013x0x1x(bits, "310", "13");
240
+ case 59: return DecodeAI013x0x1x(bits, "320", "13");
241
+ case 60: return DecodeAI013x0x1x(bits, "310", "15");
242
+ case 61: return DecodeAI013x0x1x(bits, "320", "15");
243
+ case 62: return DecodeAI013x0x1x(bits, "310", "17");
244
+ case 63: return DecodeAI013x0x1x(bits, "320", "17");
245
+ }
246
+ } catch (const std::out_of_range&) {
247
+ } catch (Error) {
248
+ }
249
+
250
+ return {};
251
+ }
252
+
253
+ } // namespace ZXing::OneD::DataBar
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright 2022 Axel Waggershauser
3
+ */
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ #pragma once
7
+
8
+ #include <string>
9
+
10
+ namespace ZXing {
11
+
12
+ class BitArray;
13
+
14
+ namespace OneD::DataBar {
15
+
16
+ std::string DecodeExpandedBits(const BitArray& bits);
17
+
18
+ } // namespace OneD::DataBar
19
+ } // namespace ZXing
@@ -0,0 +1,383 @@
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 "ODDataBarExpandedReader.h"
9
+
10
+ #include "BarcodeFormat.h"
11
+ #include "DecoderResult.h"
12
+ #include "DetectorResult.h"
13
+ #include "ODDataBarCommon.h"
14
+ #include "ODDataBarExpandedBitDecoder.h"
15
+ #include "BarcodeData.h"
16
+
17
+ #include <cmath>
18
+ #include <map>
19
+ #include <vector>
20
+
21
+ namespace ZXing::OneD {
22
+
23
+ using namespace DataBar;
24
+
25
+ static bool IsFinderPattern(int a, int b, int c, int d, int e)
26
+ {
27
+ return IsFinder(a, b, c, d, e) && (c > 3 * e);
28
+ };
29
+
30
+ static bool IsCharacterPair(const PatternView& v)
31
+ {
32
+ float modSizeRef = ModSizeFinder(v);
33
+ return IsCharacter(LeftChar(v), 17, modSizeRef) &&
34
+ (v.size() == HALF_PAIR_SIZE || IsCharacter(RightChar(v), 17, modSizeRef));
35
+ }
36
+
37
+ static bool IsL2RPair(const PatternView& v)
38
+ {
39
+ return IsFinderPattern(v[8], v[9], v[10], v[11], v[12]) && IsCharacterPair(v);
40
+ }
41
+
42
+ static bool IsR2LPair(const PatternView& v)
43
+ {
44
+ return IsFinderPattern(v[12], v[11], v[10], v[9], v[8]) && IsCharacterPair(v);
45
+ }
46
+
47
+ static Character ReadDataCharacter(const PatternView& view, int finder, bool reversed)
48
+ {
49
+ constexpr int SYMBOL_WIDEST[] = {7, 5, 4, 3, 1};
50
+ constexpr int EVEN_TOTAL_SUBSET[] = {4, 20, 52, 104, 204};
51
+ constexpr int GSUM[] = {0, 348, 1388, 2948, 3988};
52
+
53
+ Array4I oddCounts = {}, evnCounts = {};
54
+ if (!ReadDataCharacterRaw(view, 17, reversed, oddCounts, evnCounts))
55
+ return {};
56
+
57
+ int weightRow = 4 * (std::abs(finder) - 1) + (finder < 0) * 2 + reversed;
58
+ auto calcChecksum = [weightRow](const Array4I& counts, bool even) {
59
+ static constexpr std::array<std::array<int, 8>, 24> WEIGHTS = {{
60
+ {0, 0, 0, 0, 0, 0, 0, 0}, // the check character itself
61
+ {1, 3, 9, 27, 81, 32, 96, 77},
62
+ {20, 60, 180, 118, 143, 7, 21, 63},
63
+ {189, 145, 13, 39, 117, 140, 209, 205},
64
+ {193, 157, 49, 147, 19, 57, 171, 91},
65
+ {62, 186, 136, 197, 169, 85, 44, 132},
66
+ {185, 133, 188, 142, 4, 12, 36, 108},
67
+ {113, 128, 173, 97, 80, 29, 87, 50},
68
+ {150, 28, 84, 41, 123, 158, 52, 156},
69
+ {46, 138, 203, 187, 139, 206, 196, 166},
70
+ {76, 17, 51, 153, 37, 111, 122, 155},
71
+ {43, 129, 176, 106, 107, 110, 119, 146},
72
+ {16, 48, 144, 10, 30, 90, 59, 177},
73
+ {109, 116, 137, 200, 178, 112, 125, 164},
74
+ {70, 210, 208, 202, 184, 130, 179, 115},
75
+ {134, 191, 151, 31, 93, 68, 204, 190},
76
+ {148, 22, 66, 198, 172, 94, 71, 2},
77
+ {6, 18, 54, 162, 64, 192, 154, 40},
78
+ {120, 149, 25, 75, 14, 42, 126, 167},
79
+ {79, 26, 78, 23, 69, 207, 199, 175},
80
+ {103, 98, 83, 38, 114, 131, 182, 124},
81
+ {161, 61, 183, 127, 170, 88, 53, 159},
82
+ {55, 165, 73, 8, 24, 72, 5, 15},
83
+ {45, 135, 194, 160, 58, 174, 100, 89},
84
+ }};
85
+
86
+ const int* weights = &WEIGHTS[weightRow][even];
87
+ return TransformReduce(counts, 0, [i = 0, weights](int c) mutable { return c * weights[2 * i++]; });
88
+ };
89
+
90
+ int checksum = calcChecksum(oddCounts, false) + calcChecksum(evnCounts, true);
91
+
92
+ int oddSum = Reduce(oddCounts);
93
+ assert ((oddSum & 1) == 0 && oddSum <= 13 && oddSum >= 4);
94
+ int group = (13 - oddSum) / 2;
95
+ int oddWidest = SYMBOL_WIDEST[group];
96
+ int evnWidest = 9 - oddWidest;
97
+ int vOdd = GetValue(oddCounts, oddWidest, true);
98
+ int vEvn = GetValue(evnCounts, evnWidest, false);
99
+ int tEvn = EVEN_TOTAL_SUBSET[group];
100
+ int gSum = GSUM[group];
101
+ int value = vOdd * tEvn + vEvn + gSum;
102
+
103
+ return {value, checksum};
104
+ }
105
+
106
+ using Pairs = std::vector<Pair>;
107
+ using Characters = std::vector<Character>;
108
+
109
+ enum Direction
110
+ {
111
+ Right = 1,
112
+ Left = -1,
113
+ };
114
+
115
+ constexpr int FINDER_A = 1;
116
+ constexpr int FINDER_B = 2;
117
+ constexpr int FINDER_C = 3;
118
+ constexpr int FINDER_D = 4;
119
+ constexpr int FINDER_E = 5;
120
+ constexpr int FINDER_F = 6;
121
+
122
+ // A negative number means the finder pattern is laid out right2left. Note: each finder may only occur once per code.
123
+ static const std::array<std::vector<int>, 10> FINDER_PATTERN_SEQUENCES = {{
124
+ {FINDER_A, -FINDER_A},
125
+ {FINDER_A, -FINDER_B, FINDER_B},
126
+ {FINDER_A, -FINDER_C, FINDER_B, -FINDER_D},
127
+ {FINDER_A, -FINDER_E, FINDER_B, -FINDER_D, FINDER_C},
128
+ {FINDER_A, -FINDER_E, FINDER_B, -FINDER_D, FINDER_D, -FINDER_F},
129
+ {FINDER_A, -FINDER_E, FINDER_B, -FINDER_D, FINDER_E, -FINDER_F, FINDER_F},
130
+ {FINDER_A, -FINDER_A, FINDER_B, -FINDER_B, FINDER_C, -FINDER_C, FINDER_D, -FINDER_D},
131
+ {FINDER_A, -FINDER_A, FINDER_B, -FINDER_B, FINDER_C, -FINDER_C, FINDER_D, -FINDER_E, FINDER_E},
132
+ {FINDER_A, -FINDER_A, FINDER_B, -FINDER_B, FINDER_C, -FINDER_C, FINDER_D, -FINDER_E, FINDER_F, -FINDER_F},
133
+ {FINDER_A, -FINDER_A, FINDER_B, -FINDER_B, FINDER_C, -FINDER_D, FINDER_D, -FINDER_E, FINDER_E, -FINDER_F, FINDER_F},
134
+ }};
135
+
136
+ static const std::array<int, 7> VALID_HALF_PAIRS = {{-FINDER_A, FINDER_B, -FINDER_D, FINDER_C, -FINDER_F, FINDER_F, FINDER_E}};
137
+
138
+ static int ParseFinderPattern(const PatternView& view, Direction dir)
139
+ {
140
+ static constexpr std::array<Pattern<3>, 6> e2ePatterns = {{
141
+ {9, 12, 5 }, // {1, 8, 4, 1, 1}, // A
142
+ {9, 10, 5 }, // {3, 6, 4, 1, 1}, // B
143
+ {7, 10, 7 }, // {3, 4, 6, 1, 1}, // C
144
+ {5, 10, 9 }, // {3, 2, 8, 1, 1}, // D
145
+ {8, 11, 6 }, // {2, 6, 5, 1, 1}, // E
146
+ {4, 11, 10}, // {2, 2, 9, 1, 1}, // F
147
+ }};
148
+
149
+ return ParseFinderPattern(view, dir == Direction::Left, e2ePatterns);
150
+ }
151
+
152
+ static bool ChecksumIsValid(const Pairs& pairs)
153
+ {
154
+ auto checksum = TransformReduce(pairs, 0, [](auto p) { return p.left.checksum + p.right.checksum; }) % 211 +
155
+ 211 * (2 * Size(pairs) - 4 - !pairs.back().right);
156
+ return pairs.front().left.value == checksum;
157
+ }
158
+
159
+ // calculate the index (length of the sequence - 2) of the only valid sequence for the given FINDER_A, based on the
160
+ // checksum value stored in the first pair's left value. see also ChecksumIsValid().
161
+ static int SequenceIndex(Character first)
162
+ {
163
+ return (first.value / 211 + 4 + 1) / 2 - 2;
164
+ }
165
+
166
+ static bool ChecksumIsValid(Character first)
167
+ {
168
+ int i = SequenceIndex(first);
169
+ return 0 <= i && i < Size(FINDER_PATTERN_SEQUENCES);
170
+ }
171
+
172
+ static Pair ReadPair(const PatternView& view, Direction dir)
173
+ {
174
+ if (int finder = ParseFinderPattern(Finder(view), dir))
175
+ if (auto charL = ReadDataCharacter(LeftChar(view), finder, false))
176
+ if (finder != FINDER_A || ChecksumIsValid(charL)) {
177
+ auto charR = RightChar(view).isValid() && IsCharacter(RightChar(view), 17, ModSizeFinder(view))
178
+ ? ReadDataCharacter(RightChar(view), finder, true)
179
+ : Character();
180
+ if (charR || Contains(VALID_HALF_PAIRS, finder))
181
+ return {charL, charR, finder, view.pixelsInFront(),
182
+ (charR ? RightChar(view) : Finder(view)).pixelsTillEnd()};
183
+ }
184
+
185
+ return {};
186
+ }
187
+
188
+ template<bool STACKED>
189
+ static Pairs ReadRowOfPairs(PatternView& next, int rowNumber)
190
+ {
191
+ Pairs pairs;
192
+ Pair pair;
193
+
194
+ if constexpr (STACKED) {
195
+ // a possible first pair is either left2right starting on a space or right2left starting on a bar.
196
+ // it might be a half-pair
197
+ next = next.subView(0, HALF_PAIR_SIZE);
198
+ while (next.shift(1)) {
199
+ if (IsL2RPair(next) && (pair = ReadPair(next, Direction::Right)) &&
200
+ (pair.finder != FINDER_A || IsGuard(next[-1], next[11])))
201
+ break;
202
+ if (next.shift(1) && IsR2LPair(next) && (pair = ReadPair(next, Direction::Left)))
203
+ break;
204
+ }
205
+ } else {
206
+ // the only possible first pair is a full, left2right FINDER_A pair starting on a space
207
+ // with a guard bar on the left
208
+ next = next.subView(-1, FULL_PAIR_SIZE);
209
+ while (next.shift(2)) {
210
+ if (IsL2RPair(next) && IsGuard(next[-1], next[11]) &&
211
+ (pair = ReadPair(next, Direction::Right)).finder == FINDER_A)
212
+ break;
213
+ }
214
+ // after the first full pair, the symbol may end anytime with a half pair
215
+ next = next.subView(0, HALF_PAIR_SIZE);
216
+ }
217
+
218
+ if (!pair) {
219
+ next = {}; // if we didn't find a single pair, consume the rest of the row
220
+ return {};
221
+ }
222
+
223
+ auto flippedDir = [](Pair p) { return p.finder < 0 ? Direction::Right : Direction::Left; };
224
+ auto isValidPair = [](Pair p, PatternView v) { return p.right || IsGuard(v[p.finder < 0 ? 9 : 11], v[13]); };
225
+
226
+ do {
227
+ pair.y = rowNumber;
228
+ pairs.push_back(pair);
229
+ } while (pair.right && next.shift(FULL_PAIR_SIZE) && (pair = ReadPair(next, flippedDir(pair))) &&
230
+ isValidPair(pair, next));
231
+
232
+ return pairs;
233
+ }
234
+
235
+ using PairMap = std::map<int, Pairs>;
236
+
237
+ // inserts all pairs inside row into the PairMap or increases their count respectively.
238
+ static bool Insert(PairMap& all, Pairs&& row)
239
+ {
240
+ bool res = false;
241
+ for (const Pair& pair : row) {
242
+ auto& pairs = all[pair.finder];
243
+ if (auto i = Find(pairs, pair); i != pairs.end()) {
244
+ i->count++;
245
+ // bubble sort the pairs with the highest view count to the front so we test them first in FindValidSequence
246
+ while (i != pairs.begin() && i[0].count > i[-1].count) {
247
+ std::swap(i[-1], i[0]);
248
+ --i;
249
+ }
250
+ } else
251
+ pairs.push_back(pair);
252
+ res = true;
253
+ }
254
+ return res;
255
+ }
256
+
257
+ template <typename ITER>
258
+ static bool FindValidSequence(const PairMap& all, ITER begin, ITER end, Pairs& stack)
259
+ {
260
+ if (begin == end)
261
+ return ChecksumIsValid(stack);
262
+
263
+ if (auto ppairs = all.find(*begin); ppairs != all.end()) {
264
+ // only try the N most common pairs, this means the absolute maximum number of ChecksumIsValid() evaluations
265
+ // is N^11 (11 is the maximum sequence length).
266
+ constexpr int N = 2;
267
+ // TODO c++20 ranges::views::take()
268
+ auto& pairs = ppairs->second;
269
+ int n = 0;
270
+ for (auto p = pairs.begin(), pend = pairs.end(); p != pend && n < N; ++p, ++n) {
271
+ // skip p if it is a half-pair but not the last one in the sequence
272
+ if (!p->right && std::next(begin) != end)
273
+ continue;
274
+ // to lower the chance of a misread, one can require each pair to have been seen at least N times.
275
+ // e.g: if (p.count < 2) break;
276
+ stack.push_back(*p);
277
+ if (FindValidSequence(all, std::next(begin), end, stack))
278
+ return true;
279
+ stack.pop_back();
280
+ }
281
+ }
282
+
283
+ return false;
284
+ }
285
+
286
+ static Pairs FindValidSequence(PairMap& all)
287
+ {
288
+ Pairs stack;
289
+ for (const auto& first : all[FINDER_A]) {
290
+ int sequenceIndex = SequenceIndex(first.left);
291
+ // if we have not seen enough pairs to possibly complete the sequence, wait for more
292
+ if (Size(all) < sequenceIndex + 2)
293
+ continue;
294
+ auto& sequence = FINDER_PATTERN_SEQUENCES[sequenceIndex];
295
+ stack.push_back(first);
296
+ // recursively fill the stack with pairs according to the valid finder sequence
297
+ if (FindValidSequence(all, std::next(std::begin(sequence)), std::end(sequence), stack))
298
+ break;
299
+ stack.pop_back();
300
+ }
301
+ return stack;
302
+ }
303
+
304
+ static void RemovePairs(PairMap& all, const Pairs& pairs)
305
+ {
306
+ for(const auto& p : pairs)
307
+ if (auto i = Find(all[p.finder], p); i != all[p.finder].end())
308
+ if (--i->count == 0)
309
+ all[p.finder].erase(i);
310
+ }
311
+
312
+ static BitArray BuildBitArray(const Pairs& pairs)
313
+ {
314
+ BitArray res;
315
+
316
+ res.appendBits(pairs.front().right.value, 12);
317
+ for (auto p = ++pairs.begin(); p != pairs.end(); ++p) {
318
+ res.appendBits(p->left.value, 12);
319
+ if (p->right)
320
+ res.appendBits(p->right.value, 12);
321
+ }
322
+
323
+ return res;
324
+ }
325
+
326
+ struct DBERState : public RowReader::DecodingState
327
+ {
328
+ PairMap allPairs;
329
+ };
330
+
331
+ BarcodeData DataBarExpandedReader::decodePattern(int rowNumber, PatternView& view, std::unique_ptr<RowReader::DecodingState>& state) const
332
+ {
333
+ #if 0 // non-stacked version
334
+ auto pairs = ReadRowOfPairs<false>(view, rowNumber);
335
+
336
+ if (pairs.empty() || !ChecksumIsValid(pairs))
337
+ return {};
338
+ #else
339
+ if (!state)
340
+ state = std::make_unique<DBERState>();
341
+ auto& allPairs = static_cast<DBERState*>(state.get())->allPairs;
342
+
343
+ // Stacked codes can be laid out in a number of ways. The following rules apply:
344
+ // * the first row starts with FINDER_A in left-to-right (l2r) layout
345
+ // * pairs in l2r layout start with a space, r2l ones with a bar
346
+ // * l2r and r2l finders always alternate
347
+ // * rows may contain any number of pairs
348
+ // * even rows may be reversed
349
+ // * a l2r pair that starts with a bar is actually a r2l pair on a reversed line
350
+ // * the last pair of the symbol may be missing the right character
351
+ //
352
+ // 3 examples: (r == l2r, l == r2l, R/L == r/l but reversed)
353
+ // r l r l | r l | r l r
354
+ // L R L R | r | l
355
+
356
+ if (!Insert(allPairs, ReadRowOfPairs<true>(view, rowNumber)))
357
+ return {};
358
+
359
+ auto pairs = FindValidSequence(allPairs);
360
+ if (pairs.empty())
361
+ return {};
362
+ #endif
363
+
364
+ auto txt = DecodeExpandedBits(BuildBitArray(pairs));
365
+ if (txt.empty())
366
+ return {};
367
+
368
+ RemovePairs(allPairs, pairs);
369
+
370
+ bool isStacked =
371
+ std::any_of(pairs.begin() + 1, pairs.end(), [center = pairs.front().center()](const Pair& p) { return p.xStart < center; });
372
+
373
+ // TODO: EstimatePosition misses part of the symbol in the stacked case where the last row contains less pairs than
374
+ // the first
375
+ // Symbology identifier: ISO/IEC 24724:2011 Section 9 and GS1 General Specifications 5.1.3 Figure 5.1.3-2
376
+ return {.content = Content(ByteArray(txt), {'e', '0', 0, AIFlag::GS1}),
377
+ .error = Error{},
378
+ .position = EstimatePosition(pairs.front(), pairs.back()),
379
+ .format = isStacked ? BarcodeFormat::DataBarExpStk : BarcodeFormat::DataBarExp,
380
+ .lineCount = EstimateLineCount(pairs.front(), pairs.back())};
381
+ }
382
+
383
+ } // namespace ZXing::OneD
@@ -0,0 +1,25 @@
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 "ODRowReader.h"
11
+
12
+ namespace ZXing::OneD {
13
+
14
+ /**
15
+ * Decodes DataBarExpandedReader (formerly known as RSS) symbols, including truncated and stacked variants. See ISO/IEC 24724:2006.
16
+ */
17
+ class DataBarExpandedReader : public RowReader
18
+ {
19
+ public:
20
+ using RowReader::RowReader;
21
+
22
+ BarcodeData decodePattern(int rowNumber, PatternView& view, std::unique_ptr<DecodingState>& state) const override;
23
+ };
24
+
25
+ } // namespace ZXing::OneD