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,20 @@
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 <vector>
10
+
11
+ namespace ZXing {
12
+
13
+ class DecoderResult;
14
+
15
+ namespace Pdf417 {
16
+
17
+ DecoderResult Decode(const std::vector<int>& codewords);
18
+
19
+ } // namespace Pdf417
20
+ } // namespace ZXing
@@ -0,0 +1,247 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "PDFDetectionResult.h"
8
+ #include "PDFCodewordDecoder.h"
9
+ #include "ZXAlgorithms.h"
10
+
11
+ #include <algorithm>
12
+ #include <array>
13
+
14
+ namespace ZXing {
15
+ namespace Pdf417 {
16
+
17
+ static const int ADJUST_ROW_NUMBER_SKIP = 2;
18
+
19
+ DetectionResult::DetectionResult(const BarcodeMetadata& barcodeMetadata, const Nullable<BoundingBox>& boundingBox) :
20
+ _barcodeMetadata(barcodeMetadata),
21
+ _detectionResultColumns(barcodeMetadata.columnCount() + 2),
22
+ _boundingBox(boundingBox)
23
+ {
24
+ }
25
+
26
+ void
27
+ DetectionResult::init(const BarcodeMetadata& barcodeMetadata, const Nullable<BoundingBox>& boundingBox)
28
+ {
29
+ _barcodeMetadata = barcodeMetadata;
30
+ _boundingBox = boundingBox;
31
+ _detectionResultColumns.resize(barcodeMetadata.columnCount() + 2);
32
+ std::fill(_detectionResultColumns.begin(), _detectionResultColumns.end(), nullptr);
33
+ }
34
+
35
+ static void AdjustIndicatorColumnRowNumbers(Nullable<DetectionResultColumn>& detectionResultColumn, const BarcodeMetadata& barcodeMetadata)
36
+ {
37
+ if (detectionResultColumn != nullptr) {
38
+ detectionResultColumn.value().adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata);
39
+ }
40
+ }
41
+
42
+ static void AdjustRowNumbersFromBothRI(std::vector<Nullable<DetectionResultColumn>>& detectionResultColumns)
43
+ {
44
+ if (detectionResultColumns.front() == nullptr || detectionResultColumns.back() == nullptr) {
45
+ return;
46
+ }
47
+ auto& LRIcodewords = detectionResultColumns.front().value().allCodewords();
48
+ auto& RRIcodewords = detectionResultColumns.back().value().allCodewords();
49
+ for (size_t codewordsRow = 0; codewordsRow < LRIcodewords.size(); codewordsRow++) {
50
+ if (LRIcodewords[codewordsRow] != nullptr && RRIcodewords[codewordsRow] != nullptr &&
51
+ LRIcodewords[codewordsRow].value().rowNumber() == RRIcodewords[codewordsRow].value().rowNumber()) {
52
+ auto lastColumn = detectionResultColumns.end() - 1;
53
+ for (auto columnIter = detectionResultColumns.begin() + 1; columnIter != lastColumn; ++columnIter) {
54
+ if (!columnIter->hasValue()) {
55
+ continue;
56
+ }
57
+ auto& codeword = columnIter->value().allCodewords()[codewordsRow];
58
+ if (codeword != nullptr) {
59
+ codeword.value().setRowNumber(LRIcodewords[codewordsRow].value().rowNumber());
60
+ if (!codeword.value().hasValidRowNumber()) {
61
+ columnIter->value().allCodewords()[codewordsRow] = nullptr;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ static int AdjustRowNumberIfValid(int rowIndicatorRowNumber, int invalidRowCounts, Codeword& codeword) {
70
+ if (!codeword.hasValidRowNumber()) {
71
+ if (codeword.isValidRowNumber(rowIndicatorRowNumber)) {
72
+ codeword.setRowNumber(rowIndicatorRowNumber);
73
+ invalidRowCounts = 0;
74
+ }
75
+ else {
76
+ ++invalidRowCounts;
77
+ }
78
+ }
79
+ return invalidRowCounts;
80
+ }
81
+
82
+ static int AdjustRowNumbersFromLRI(std::vector<Nullable<DetectionResultColumn>>& detectionResultColumns) {
83
+ if (detectionResultColumns.front() == nullptr) {
84
+ return 0;
85
+ }
86
+ int unadjustedCount = 0;
87
+ auto& codewords = detectionResultColumns.front().value().allCodewords();
88
+ for (size_t codewordsRow = 0; codewordsRow < codewords.size(); codewordsRow++) {
89
+ if (codewords[codewordsRow] == nullptr) {
90
+ continue;
91
+ }
92
+ int rowIndicatorRowNumber = codewords[codewordsRow].value().rowNumber();
93
+ int invalidRowCounts = 0;
94
+ auto lastColumn = detectionResultColumns.end() - 1;
95
+ for (auto columnIter = detectionResultColumns.begin() + 1; columnIter != lastColumn && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; ++columnIter) {
96
+ if (!columnIter->hasValue()) {
97
+ continue;
98
+ }
99
+ auto& codeword = columnIter->value().allCodewords()[codewordsRow];
100
+ if (codeword != nullptr) {
101
+ invalidRowCounts = AdjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword.value());
102
+ if (!codeword.value().hasValidRowNumber()) {
103
+ unadjustedCount++;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ return unadjustedCount;
109
+ }
110
+
111
+ static int AdjustRowNumbersFromRRI(std::vector<Nullable<DetectionResultColumn>>& detectionResultColumns) {
112
+ if (detectionResultColumns.back() == nullptr) {
113
+ return 0;
114
+ }
115
+ int unadjustedCount = 0;
116
+ auto& codewords = detectionResultColumns.back().value().allCodewords();
117
+ for (size_t codewordsRow = 0; codewordsRow < codewords.size(); codewordsRow++) {
118
+ if (codewords[codewordsRow] == nullptr) {
119
+ continue;
120
+ }
121
+ int rowIndicatorRowNumber = codewords[codewordsRow].value().rowNumber();
122
+ int invalidRowCounts = 0;
123
+ auto lastColumn = detectionResultColumns.end() - 1;
124
+ for (auto columnIter = detectionResultColumns.begin() + 1; columnIter != lastColumn && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; ++columnIter) {
125
+ if (!columnIter->hasValue()) {
126
+ continue;
127
+ }
128
+ auto& codeword = columnIter->value().allCodewords()[codewordsRow];
129
+ if (codeword != nullptr) {
130
+ invalidRowCounts = AdjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword.value());
131
+ if (!codeword.value().hasValidRowNumber()) {
132
+ unadjustedCount++;
133
+ }
134
+ }
135
+ }
136
+ }
137
+ return unadjustedCount;
138
+ }
139
+
140
+
141
+ static int AdjustRowNumbersByRow(std::vector<Nullable<DetectionResultColumn>>& detectionResultColumns) {
142
+ AdjustRowNumbersFromBothRI(detectionResultColumns);
143
+ // TODO we should only do full row adjustments if row numbers of left and right row indicator column match.
144
+ // Maybe it's even better to calculated the height (in codeword rows) and divide it by the number of barcode
145
+ // rows. This, together with the LRI and RRI row numbers should allow us to get a good estimate where a row
146
+ // number starts and ends.
147
+ int unadjustedCount = AdjustRowNumbersFromLRI(detectionResultColumns);
148
+ return unadjustedCount + AdjustRowNumbersFromRRI(detectionResultColumns);
149
+ }
150
+
151
+
152
+ /**
153
+ * @return true, if row number was adjusted, false otherwise
154
+ */
155
+ static bool AdjustRowNumber(Nullable<Codeword>& codeword, const Nullable<Codeword>& otherCodeword) {
156
+ if (codeword != nullptr && otherCodeword != nullptr
157
+ && otherCodeword.value().hasValidRowNumber() && otherCodeword.value().bucket() == codeword.value().bucket()) {
158
+ codeword.value().setRowNumber(otherCodeword.value().rowNumber());
159
+ return true;
160
+ }
161
+ return false;
162
+ }
163
+
164
+ static void AdjustRowNumbers(const std::vector<Nullable<DetectionResultColumn>>& detectionResultColumns, int barcodeColumn, int codewordsRow, std::vector<Nullable<Codeword>>& codewords) {
165
+ auto& codeword = codewords[codewordsRow];
166
+ auto& previousColumnCodewords = detectionResultColumns[barcodeColumn - 1].value().allCodewords();
167
+ auto& nextColumnCodewords = detectionResultColumns[barcodeColumn + 1] != nullptr ? detectionResultColumns[barcodeColumn + 1].value().allCodewords() : previousColumnCodewords;
168
+
169
+ std::array<Nullable<Codeword>, 14> otherCodewords;
170
+
171
+ otherCodewords[2] = previousColumnCodewords[codewordsRow];
172
+ otherCodewords[3] = nextColumnCodewords[codewordsRow];
173
+
174
+ if (codewordsRow > 0) {
175
+ otherCodewords[0] = codewords[codewordsRow - 1];
176
+ otherCodewords[4] = previousColumnCodewords[codewordsRow - 1];
177
+ otherCodewords[5] = nextColumnCodewords[codewordsRow - 1];
178
+ }
179
+ if (codewordsRow > 1) {
180
+ otherCodewords[8] = codewords[codewordsRow - 2];
181
+ otherCodewords[10] = previousColumnCodewords[codewordsRow - 2];
182
+ otherCodewords[11] = nextColumnCodewords[codewordsRow - 2];
183
+ }
184
+ if (codewordsRow < Size(codewords) - 1) {
185
+ otherCodewords[1] = codewords[codewordsRow + 1];
186
+ otherCodewords[6] = previousColumnCodewords[codewordsRow + 1];
187
+ otherCodewords[7] = nextColumnCodewords[codewordsRow + 1];
188
+ }
189
+ if (codewordsRow < Size(codewords) - 2) {
190
+ otherCodewords[9] = codewords[codewordsRow + 2];
191
+ otherCodewords[12] = previousColumnCodewords[codewordsRow + 2];
192
+ otherCodewords[13] = nextColumnCodewords[codewordsRow + 2];
193
+ }
194
+ for (const auto& otherCodeword : otherCodewords) {
195
+ if (AdjustRowNumber(codeword, otherCodeword)) {
196
+ return;
197
+ }
198
+ }
199
+ }
200
+
201
+
202
+ // TODO ensure that no detected codewords with unknown row number are left
203
+ // we should be able to estimate the row height and use it as a hint for the row number
204
+ // we should also fill the rows top to bottom and bottom to top
205
+ /**
206
+ * @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords
207
+ * will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers
208
+ */
209
+ static int AdjustRowNumbers(std::vector<Nullable<DetectionResultColumn>>& detectionResultColumns) {
210
+ int unadjustedCount = AdjustRowNumbersByRow(detectionResultColumns);
211
+ if (unadjustedCount == 0) {
212
+ return 0;
213
+ }
214
+ for (int barcodeColumn = 1; barcodeColumn < Size(detectionResultColumns) - 1; barcodeColumn++) {
215
+ if (detectionResultColumns[barcodeColumn] == nullptr) {
216
+ continue;
217
+ }
218
+ auto& codewords = detectionResultColumns[barcodeColumn].value().allCodewords();
219
+ for (int codewordsRow = 0; codewordsRow < Size(codewords); codewordsRow++) {
220
+ if (codewords[codewordsRow] == nullptr) {
221
+ continue;
222
+ }
223
+ if (!codewords[codewordsRow].value().hasValidRowNumber()) {
224
+ AdjustRowNumbers(detectionResultColumns, barcodeColumn, codewordsRow, codewords);
225
+ }
226
+ }
227
+ }
228
+ return unadjustedCount;
229
+ }
230
+
231
+
232
+ const std::vector<Nullable<DetectionResultColumn>> &
233
+ DetectionResult::allColumns()
234
+ {
235
+ AdjustIndicatorColumnRowNumbers(_detectionResultColumns.front(), _barcodeMetadata);
236
+ AdjustIndicatorColumnRowNumbers(_detectionResultColumns.back(), _barcodeMetadata);
237
+ int unadjustedCodewordCount = CodewordDecoder::MAX_CODEWORDS_IN_BARCODE;
238
+ int previousUnadjustedCount;
239
+ do {
240
+ previousUnadjustedCount = unadjustedCodewordCount;
241
+ unadjustedCodewordCount = AdjustRowNumbers(_detectionResultColumns);
242
+ } while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUnadjustedCount);
243
+ return _detectionResultColumns;
244
+ }
245
+
246
+ } // Pdf417
247
+ } // ZXing
@@ -0,0 +1,74 @@
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 "PDFBarcodeMetadata.h"
10
+ #include "PDFBoundingBox.h"
11
+ #include "PDFDetectionResultColumn.h"
12
+ #include "ZXNullable.h"
13
+ #include <vector>
14
+
15
+ namespace ZXing {
16
+ namespace Pdf417 {
17
+
18
+ /**
19
+ * @author Guenther Grau
20
+ */
21
+ class DetectionResult
22
+ {
23
+ BarcodeMetadata _barcodeMetadata;
24
+ std::vector<Nullable<DetectionResultColumn>> _detectionResultColumns;
25
+ Nullable<BoundingBox> _boundingBox;
26
+
27
+ public:
28
+ DetectionResult() = default;
29
+ DetectionResult(const BarcodeMetadata& barcodeMetadata, const Nullable<BoundingBox>& boundingBox);
30
+
31
+ void init(const BarcodeMetadata& barcodeMetadata, const Nullable<BoundingBox>& boundingBox);
32
+
33
+ const std::vector<Nullable<DetectionResultColumn>> & allColumns();
34
+
35
+ int barcodeColumnCount() const {
36
+ return _barcodeMetadata.columnCount();
37
+ }
38
+
39
+ int barcodeRowCount() const {
40
+ return _barcodeMetadata.rowCount();
41
+ }
42
+
43
+ int barcodeECLevel() const {
44
+ return _barcodeMetadata.errorCorrectionLevel();
45
+ }
46
+
47
+ void setBoundingBox(const BoundingBox& boundingBox) {
48
+ _boundingBox = boundingBox;
49
+ }
50
+
51
+ const Nullable<BoundingBox> & getBoundingBox() const {
52
+ return _boundingBox;
53
+ }
54
+
55
+ void setBoundingBox(const Nullable<BoundingBox>& box) {
56
+ _boundingBox = box;
57
+ }
58
+
59
+ void setColumn(int barcodeColumn, const Nullable<DetectionResultColumn>& detectionResultColumn) {
60
+ _detectionResultColumns[barcodeColumn] = detectionResultColumn;
61
+ }
62
+
63
+ const Nullable<DetectionResultColumn>& column(int barcodeColumn) const {
64
+ return _detectionResultColumns[barcodeColumn];
65
+ }
66
+
67
+ Nullable<DetectionResultColumn>& column(int barcodeColumn) {
68
+ return _detectionResultColumns[barcodeColumn];
69
+ }
70
+
71
+ };
72
+
73
+ } // Pdf417
74
+ } // ZXing
@@ -0,0 +1,321 @@
1
+ /*
2
+ * Copyright 2016 Nu-book Inc.
3
+ * Copyright 2016 ZXing authors
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "PDFDetectionResultColumn.h"
8
+ #include "PDFBarcodeMetadata.h"
9
+ #include "PDFBarcodeValue.h"
10
+ #include "ZXAlgorithms.h"
11
+
12
+ #include <algorithm>
13
+ #include <stdexcept>
14
+
15
+ namespace ZXing {
16
+ namespace Pdf417 {
17
+
18
+ static const int MAX_NEARBY_DISTANCE = 5;
19
+ static const int MIN_ROWS_IN_BARCODE = 3;
20
+ static const int MAX_ROWS_IN_BARCODE = 90;
21
+
22
+ DetectionResultColumn::DetectionResultColumn(const BoundingBox& boundingBox, RowIndicator rowIndicator) :
23
+ _boundingBox(boundingBox),
24
+ _rowIndicator(rowIndicator)
25
+ {
26
+ if (boundingBox.maxY() < boundingBox.minY()) {
27
+ throw std::invalid_argument("Invalid bounding box");
28
+ }
29
+ _codewords.resize(boundingBox.maxY() - boundingBox.minY() + 1);
30
+ }
31
+
32
+ Nullable<Codeword>
33
+ DetectionResultColumn::codewordNearby(int imageRow) const
34
+ {
35
+ int index = imageRowToCodewordIndex(imageRow);
36
+ if (_codewords[index] != nullptr) {
37
+ return _codewords[index];
38
+ }
39
+
40
+ for (int i = 1; i < MAX_NEARBY_DISTANCE; i++) {
41
+ int nearImageRow = imageRowToCodewordIndex(imageRow) - i;
42
+ if (nearImageRow >= 0) {
43
+ if (_codewords[nearImageRow] != nullptr) {
44
+ return _codewords[nearImageRow];
45
+ }
46
+ }
47
+ nearImageRow = imageRowToCodewordIndex(imageRow) + i;
48
+ if (nearImageRow < Size(_codewords)) {
49
+ if (_codewords[nearImageRow] != nullptr) {
50
+ return _codewords[nearImageRow];
51
+ }
52
+ }
53
+ }
54
+ return nullptr;
55
+ }
56
+
57
+ void
58
+ DetectionResultColumn::setRowNumbers()
59
+ {
60
+ for (auto& codeword : allCodewords()) {
61
+ if (codeword != nullptr) {
62
+ codeword.value().setRowNumberAsRowIndicatorColumn();
63
+ }
64
+ }
65
+ }
66
+
67
+ static void RemoveIncorrectCodewords(bool isLeft, std::vector<Nullable<Codeword>>& codewords, const BarcodeMetadata& barcodeMetadata)
68
+ {
69
+ // Remove codewords which do not match the metadata
70
+ // TODO Maybe we should keep the incorrect codewords for the start and end positions?
71
+ for (auto& item : codewords) {
72
+ if (item == nullptr) {
73
+ continue;
74
+ }
75
+
76
+ const auto& codeword = item.value();
77
+
78
+ int rowIndicatorValue = codeword.value() % 30;
79
+ int codewordRowNumber = codeword.rowNumber();
80
+ if (codewordRowNumber > barcodeMetadata.rowCount()) {
81
+ item = nullptr;
82
+ continue;
83
+ }
84
+ if (!isLeft) {
85
+ codewordRowNumber += 2;
86
+ }
87
+ switch (codewordRowNumber % 3) {
88
+ case 0:
89
+ if (rowIndicatorValue * 3 + 1 != barcodeMetadata.rowCountUpperPart()) {
90
+ item = nullptr;
91
+ }
92
+ break;
93
+ case 1:
94
+ if (rowIndicatorValue / 3 != barcodeMetadata.errorCorrectionLevel() ||
95
+ rowIndicatorValue % 3 != barcodeMetadata.rowCountLowerPart()) {
96
+ item = nullptr;
97
+ }
98
+ break;
99
+ case 2:
100
+ if (rowIndicatorValue + 1 != barcodeMetadata.columnCount()) {
101
+ item = nullptr;
102
+ }
103
+ break;
104
+ }
105
+ }
106
+ }
107
+
108
+ // TODO implement properly
109
+ // TODO maybe we should add missing codewords to store the correct row number to make
110
+ // finding row numbers for other columns easier
111
+ // use row height count to make detection of invalid row numbers more reliable
112
+ void
113
+ DetectionResultColumn::adjustCompleteIndicatorColumnRowNumbers(const BarcodeMetadata& barcodeMetadata)
114
+ {
115
+ if (!isRowIndicator()) {
116
+ return;
117
+ }
118
+
119
+ auto& codewords = allCodewords();
120
+ setRowNumbers();
121
+ RemoveIncorrectCodewords(isLeftRowIndicator(), codewords, barcodeMetadata);
122
+ const auto& bb = boundingBox();
123
+ auto top = isLeftRowIndicator() ? bb.topLeft() : bb.topRight();
124
+ auto bottom = isLeftRowIndicator() ? bb.bottomLeft() : bb.bottomRight();
125
+ int firstRow = imageRowToCodewordIndex((int)top.value().y());
126
+ int lastRow = imageRowToCodewordIndex((int)bottom.value().y());
127
+ // We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
128
+ // taller rows
129
+ //float averageRowHeight = (lastRow - firstRow) / (float)barcodeMetadata.rowCount();
130
+ int barcodeRow = -1;
131
+ int maxRowHeight = 1;
132
+ int currentRowHeight = 0;
133
+ int increment = 1;
134
+ for (int codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) {
135
+ if (codewords[codewordsRow] == nullptr) {
136
+ continue;
137
+ }
138
+ Codeword codeword = codewords[codewordsRow];
139
+ if (barcodeRow == -1 && codeword.rowNumber() == barcodeMetadata.rowCount() - 1) {
140
+ increment = -1;
141
+ barcodeRow = barcodeMetadata.rowCount();
142
+ }
143
+ // float expectedRowNumber = (codewordsRow - firstRow) / averageRowHeight;
144
+ // if (Math.abs(codeword.getRowNumber() - expectedRowNumber) > 2) {
145
+ // SimpleLog.log(LEVEL.WARNING,
146
+ // "Removing codeword, rowNumberSkew too high, codeword[" + codewordsRow + "]: Expected Row: " +
147
+ // expectedRowNumber + ", RealRow: " + codeword.getRowNumber() + ", value: " + codeword.getValue());
148
+ // codewords[codewordsRow] = null;
149
+ // }
150
+
151
+ int rowDifference = codeword.rowNumber() - barcodeRow;
152
+
153
+ if (rowDifference == 0) {
154
+ currentRowHeight++;
155
+ }
156
+ else if (rowDifference == increment) {
157
+ maxRowHeight = std::max(maxRowHeight, currentRowHeight);
158
+ currentRowHeight = 1;
159
+ barcodeRow = codeword.rowNumber();
160
+ }
161
+ else if (rowDifference < 0 ||
162
+ codeword.rowNumber() >= barcodeMetadata.rowCount() ||
163
+ rowDifference > codewordsRow) {
164
+ codewords[codewordsRow] = nullptr;
165
+ }
166
+ else {
167
+ int checkedRows;
168
+ if (maxRowHeight > 2) {
169
+ checkedRows = (maxRowHeight - 2) * rowDifference;
170
+ }
171
+ else {
172
+ checkedRows = rowDifference;
173
+ }
174
+ bool closePreviousCodewordFound = checkedRows >= codewordsRow;
175
+ for (int i = 1; i <= checkedRows && !closePreviousCodewordFound; i++) {
176
+ // there must be (height * rowDifference) number of codewords missing. For now we assume height = 1.
177
+ // This should hopefully get rid of most problems already.
178
+ closePreviousCodewordFound = codewords[codewordsRow - i] != nullptr;
179
+ }
180
+ if (closePreviousCodewordFound) {
181
+ codewords[codewordsRow] = nullptr;
182
+ }
183
+ else {
184
+ barcodeRow = codeword.rowNumber();
185
+ currentRowHeight = 1;
186
+ }
187
+ }
188
+ }
189
+ //return static_cast<int>(averageRowHeight + 0.5);
190
+ }
191
+
192
+ // TODO maybe we should add missing codewords to store the correct row number to make
193
+ // finding row numbers for other columns easier
194
+ // use row height count to make detection of invalid row numbers more reliable
195
+ void
196
+ DetectionResultColumn::adjustIncompleteIndicatorColumnRowNumbers(const BarcodeMetadata& barcodeMetadata)
197
+ {
198
+ if (!isRowIndicator()) {
199
+ return;
200
+ }
201
+
202
+ const auto& bb = boundingBox();
203
+ auto top = isLeftRowIndicator() ? bb.topLeft() : bb.topRight();
204
+ auto bottom = isLeftRowIndicator() ? bb.bottomLeft() : bb.bottomRight();
205
+ int firstRow = imageRowToCodewordIndex((int)top.value().y());
206
+ int lastRow = imageRowToCodewordIndex((int)bottom.value().y());
207
+ //float averageRowHeight = (lastRow - firstRow) / (float)barcodeMetadata.rowCount();
208
+ auto& codewords = allCodewords();
209
+ int barcodeRow = -1;
210
+ int maxRowHeight = 1;
211
+ int currentRowHeight = 0;
212
+ for (int codewordsRow = firstRow; codewordsRow < lastRow; codewordsRow++) {
213
+ if (codewords[codewordsRow] == nullptr) {
214
+ continue;
215
+ }
216
+ auto& item = codewords[codewordsRow];
217
+
218
+ auto& codeword = item.value();
219
+ codeword.setRowNumberAsRowIndicatorColumn();
220
+
221
+ int rowDifference = codeword.rowNumber() - barcodeRow;
222
+
223
+ // TODO improve handling with case where first row indicator doesn't start with 0
224
+
225
+ if (rowDifference == 0) {
226
+ currentRowHeight++;
227
+ }
228
+ else if (rowDifference == 1) {
229
+ maxRowHeight = std::max(maxRowHeight, currentRowHeight);
230
+ currentRowHeight = 1;
231
+ barcodeRow = codeword.rowNumber();
232
+ }
233
+ else if (codeword.rowNumber() >= barcodeMetadata.rowCount()) {
234
+ item = nullptr;
235
+ }
236
+ else {
237
+ barcodeRow = codeword.rowNumber();
238
+ currentRowHeight = 1;
239
+ }
240
+ }
241
+ //return static_cast<int>(averageRowHeight + 0.5);
242
+ }
243
+
244
+ // This is example of bad design, a getter should not modify object's state
245
+ bool
246
+ DetectionResultColumn::getRowHeights(std::vector<int>& result)
247
+ {
248
+ BarcodeMetadata barcodeMetadata;
249
+ if (!getBarcodeMetadata(barcodeMetadata)) {
250
+ return false;
251
+ }
252
+
253
+ adjustIncompleteIndicatorColumnRowNumbers(barcodeMetadata);
254
+ result.resize(barcodeMetadata.rowCount());
255
+ for (auto& item : allCodewords()) {
256
+ if (item != nullptr) {
257
+ size_t rowNumber = item.value().rowNumber();
258
+ if (rowNumber >= result.size()) {
259
+ // We have more rows than the barcode metadata allows for, ignore them.
260
+ continue;
261
+ }
262
+ result[rowNumber]++;
263
+ } // else throw exception?
264
+ }
265
+ return true;
266
+ }
267
+
268
+
269
+ // This is example of bad design, a getter should not modify object's state
270
+ bool
271
+ DetectionResultColumn::getBarcodeMetadata(BarcodeMetadata& result)
272
+ {
273
+ if (!isRowIndicator()) {
274
+ return false;
275
+ }
276
+
277
+ auto& codewords = allCodewords();
278
+ BarcodeValue barcodeColumnCount;
279
+ BarcodeValue barcodeRowCountUpperPart;
280
+ BarcodeValue barcodeRowCountLowerPart;
281
+ BarcodeValue barcodeECLevel;
282
+ for (auto& item : codewords) {
283
+ if (item == nullptr) {
284
+ continue;
285
+ }
286
+ auto& codeword = item.value();
287
+ codeword.setRowNumberAsRowIndicatorColumn();
288
+ int rowIndicatorValue = codeword.value() % 30;
289
+ int codewordRowNumber = codeword.rowNumber();
290
+ if (!isLeftRowIndicator()) {
291
+ codewordRowNumber += 2;
292
+ }
293
+ switch (codewordRowNumber % 3) {
294
+ case 0:
295
+ barcodeRowCountUpperPart.setValue(rowIndicatorValue * 3 + 1);
296
+ break;
297
+ case 1:
298
+ barcodeECLevel.setValue(rowIndicatorValue / 3);
299
+ barcodeRowCountLowerPart.setValue(rowIndicatorValue % 3);
300
+ break;
301
+ case 2:
302
+ barcodeColumnCount.setValue(rowIndicatorValue + 1);
303
+ break;
304
+ }
305
+ }
306
+ // Maybe we should check if we have ambiguous values?
307
+ auto cc = barcodeColumnCount.value();
308
+ auto rcu = barcodeRowCountUpperPart.value();
309
+ auto rcl = barcodeRowCountLowerPart.value();
310
+ auto ec = barcodeECLevel.value();
311
+ if (cc.empty() || rcu.empty() || rcl.empty() || ec.empty() || cc[0] < 1 || rcu[0] + rcl[0] < MIN_ROWS_IN_BARCODE || rcu[0] + rcl[0] > MAX_ROWS_IN_BARCODE) {
312
+ return false;
313
+ }
314
+ result = { cc[0], rcu[0], rcl[0], ec[0] };
315
+ RemoveIncorrectCodewords(isLeftRowIndicator(), codewords, result);
316
+ return true;
317
+ }
318
+
319
+
320
+ } // Pdf417
321
+ } // ZXing