react-native-executorch 0.4.7 → 0.5.1-rc.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 (1021) hide show
  1. package/android/CMakeLists.txt +17 -0
  2. package/android/build.gradle +76 -13
  3. package/android/libs/classes.jar +0 -0
  4. package/android/src/main/cpp/CMakeLists.txt +73 -0
  5. package/android/src/main/cpp/ETInstallerModule.cpp +76 -0
  6. package/android/src/main/cpp/ETInstallerModule.h +43 -0
  7. package/android/src/main/java/com/swmansion/rnexecutorch/ETInstaller.kt +66 -0
  8. package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +3 -3
  9. package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +7 -113
  10. package/common/ada/ada.cpp +17406 -0
  11. package/common/ada/ada.h +10274 -0
  12. package/common/pfft/pfft.c +2205 -0
  13. package/common/pfft/pfft.h +185 -0
  14. package/common/rnexecutorch/Log.h +489 -0
  15. package/common/rnexecutorch/RnExecutorchInstaller.cpp +78 -0
  16. package/common/rnexecutorch/RnExecutorchInstaller.h +112 -0
  17. package/common/rnexecutorch/TokenizerModule.cpp +52 -0
  18. package/common/rnexecutorch/TokenizerModule.h +26 -0
  19. package/common/rnexecutorch/data_processing/FFT.cpp +21 -0
  20. package/common/rnexecutorch/data_processing/FFT.h +23 -0
  21. package/common/rnexecutorch/data_processing/FileUtils.h +30 -0
  22. package/common/rnexecutorch/data_processing/ImageProcessing.cpp +240 -0
  23. package/common/rnexecutorch/data_processing/ImageProcessing.h +55 -0
  24. package/common/rnexecutorch/data_processing/Numerical.cpp +82 -0
  25. package/common/rnexecutorch/data_processing/Numerical.h +23 -0
  26. package/common/rnexecutorch/data_processing/base64.cpp +110 -0
  27. package/common/rnexecutorch/data_processing/base64.h +46 -0
  28. package/common/rnexecutorch/data_processing/dsp.cpp +65 -0
  29. package/common/rnexecutorch/data_processing/dsp.h +12 -0
  30. package/common/rnexecutorch/host_objects/JSTensorViewIn.h +12 -0
  31. package/common/rnexecutorch/host_objects/JSTensorViewOut.h +22 -0
  32. package/common/rnexecutorch/host_objects/JsiConversions.h +410 -0
  33. package/common/rnexecutorch/host_objects/ModelHostObject.h +239 -0
  34. package/common/rnexecutorch/jsi/JsiHostObject.cpp +108 -0
  35. package/common/rnexecutorch/jsi/JsiHostObject.h +87 -0
  36. package/common/rnexecutorch/jsi/OwningArrayBuffer.h +40 -0
  37. package/common/rnexecutorch/jsi/Promise.cpp +20 -0
  38. package/common/rnexecutorch/jsi/Promise.h +69 -0
  39. package/common/rnexecutorch/jsi/RuntimeAwareCache.h +58 -0
  40. package/common/rnexecutorch/jsi/RuntimeLifecycleMonitor.cpp +53 -0
  41. package/common/rnexecutorch/jsi/RuntimeLifecycleMonitor.h +35 -0
  42. package/common/rnexecutorch/metaprogramming/ConstructorHelpers.h +131 -0
  43. package/common/rnexecutorch/metaprogramming/FunctionHelpers.h +50 -0
  44. package/common/rnexecutorch/metaprogramming/TypeConcepts.h +37 -0
  45. package/common/rnexecutorch/models/BaseModel.cpp +181 -0
  46. package/common/rnexecutorch/models/BaseModel.h +47 -0
  47. package/common/rnexecutorch/models/EncoderDecoderBase.cpp +21 -0
  48. package/common/rnexecutorch/models/EncoderDecoderBase.h +31 -0
  49. package/common/rnexecutorch/models/classification/Classification.cpp +72 -0
  50. package/common/rnexecutorch/models/classification/Classification.h +26 -0
  51. package/{ios/RnExecutorch/models/classification/Constants.mm → common/rnexecutorch/models/classification/Constants.h} +7 -2
  52. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.cpp +27 -0
  53. package/common/rnexecutorch/models/embeddings/BaseEmbeddings.h +17 -0
  54. package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.cpp +45 -0
  55. package/common/rnexecutorch/models/embeddings/image/ImageEmbeddings.h +23 -0
  56. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.cpp +61 -0
  57. package/common/rnexecutorch/models/embeddings/text/TextEmbeddings.h +26 -0
  58. package/{ios/RnExecutorch/models/image_segmentation/Constants.mm → common/rnexecutorch/models/image_segmentation/Constants.h} +7 -2
  59. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.cpp +173 -0
  60. package/common/rnexecutorch/models/image_segmentation/ImageSegmentation.h +43 -0
  61. package/{ios/RnExecutorch/utils/Constants.mm → common/rnexecutorch/models/object_detection/Constants.h} +9 -2
  62. package/common/rnexecutorch/models/object_detection/ObjectDetection.cpp +82 -0
  63. package/common/rnexecutorch/models/object_detection/ObjectDetection.h +31 -0
  64. package/{ios/RnExecutorch/utils/ObjectDetectionUtils.mm → common/rnexecutorch/models/object_detection/Utils.cpp} +10 -30
  65. package/common/rnexecutorch/models/object_detection/Utils.h +17 -0
  66. package/common/rnexecutorch/models/ocr/CTCLabelConverter.cpp +88 -0
  67. package/common/rnexecutorch/models/ocr/CTCLabelConverter.h +29 -0
  68. package/common/rnexecutorch/models/ocr/Constants.h +34 -0
  69. package/common/rnexecutorch/models/ocr/Detector.cpp +102 -0
  70. package/common/rnexecutorch/models/ocr/Detector.h +30 -0
  71. package/common/rnexecutorch/models/ocr/DetectorUtils.cpp +703 -0
  72. package/common/rnexecutorch/models/ocr/DetectorUtils.h +80 -0
  73. package/common/rnexecutorch/models/ocr/OCR.cpp +52 -0
  74. package/common/rnexecutorch/models/ocr/OCR.h +36 -0
  75. package/common/rnexecutorch/models/ocr/RecognitionHandler.cpp +107 -0
  76. package/common/rnexecutorch/models/ocr/RecognitionHandler.h +40 -0
  77. package/common/rnexecutorch/models/ocr/RecognitionHandlerUtils.cpp +153 -0
  78. package/common/rnexecutorch/models/ocr/RecognitionHandlerUtils.h +72 -0
  79. package/common/rnexecutorch/models/ocr/Recognizer.cpp +80 -0
  80. package/common/rnexecutorch/models/ocr/Recognizer.h +36 -0
  81. package/common/rnexecutorch/models/ocr/RecognizerUtils.cpp +202 -0
  82. package/common/rnexecutorch/models/ocr/RecognizerUtils.h +70 -0
  83. package/common/rnexecutorch/models/ocr/Types.h +37 -0
  84. package/common/rnexecutorch/models/speech_to_text/MoonshineStrategy.cpp +31 -0
  85. package/common/rnexecutorch/models/speech_to_text/MoonshineStrategy.h +21 -0
  86. package/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp +70 -0
  87. package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +31 -0
  88. package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +26 -0
  89. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +38 -0
  90. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +25 -0
  91. package/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp +55 -0
  92. package/common/rnexecutorch/models/style_transfer/StyleTransfer.h +29 -0
  93. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.cpp +92 -0
  94. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.h +49 -0
  95. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.cpp +180 -0
  96. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.h +78 -0
  97. package/common/rnexecutorch/tests/LogTest.cpp +530 -0
  98. package/common/rnexecutorch/tests/README.md +20 -0
  99. package/common/rnexecutorch/tests/run_all_tests.sh +14 -0
  100. package/common/rnexecutorch/tests/run_test.sh +18 -0
  101. package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
  102. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  103. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  104. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  105. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  106. package/ios/RnExecutorch/ETInstaller.h +8 -0
  107. package/ios/RnExecutorch/ETInstaller.mm +56 -0
  108. package/ios/RnExecutorch/utils/Conversions.h +8 -9
  109. package/ios/RnExecutorch/utils/Numerical.h +2 -0
  110. package/ios/RnExecutorch.xcodeproj/project.pbxproj +73 -0
  111. package/lib/common/Logger.d.ts +8 -0
  112. package/lib/common/Logger.js +19 -0
  113. package/lib/constants/modelUrls.d.ts +89 -0
  114. package/lib/constants/modelUrls.js +116 -0
  115. package/lib/constants/sttDefaults.js +66 -0
  116. package/lib/controllers/LLMController.js +210 -0
  117. package/lib/controllers/OCRController.js +65 -0
  118. package/lib/controllers/SpeechToTextController.d.ts +52 -0
  119. package/lib/controllers/SpeechToTextController.js +343 -0
  120. package/lib/hooks/natural_language_processing/useSpeechToText.js +44 -0
  121. package/lib/index.d.ts +50 -0
  122. package/{src/index.tsx → lib/index.js} +22 -10
  123. package/lib/module/Error.js +8 -6
  124. package/lib/module/Error.js.map +1 -1
  125. package/lib/module/common/Logger.js +23 -0
  126. package/lib/module/common/Logger.js.map +1 -0
  127. package/lib/module/constants/llmDefaults.js +8 -0
  128. package/lib/module/constants/llmDefaults.js.map +1 -1
  129. package/lib/module/constants/modelUrls.js +300 -84
  130. package/lib/module/constants/modelUrls.js.map +1 -1
  131. package/lib/module/constants/ocr/models.js +181 -286
  132. package/lib/module/constants/ocr/models.js.map +1 -1
  133. package/lib/module/constants/ocr/symbols.js +63 -63
  134. package/lib/module/constants/sttDefaults.js +12 -10
  135. package/lib/module/constants/sttDefaults.js.map +1 -1
  136. package/lib/module/controllers/LLMController.js +17 -11
  137. package/lib/module/controllers/LLMController.js.map +1 -1
  138. package/lib/module/controllers/OCRController.js +16 -9
  139. package/lib/module/controllers/OCRController.js.map +1 -1
  140. package/lib/module/controllers/SpeechToTextController.js +32 -19
  141. package/lib/module/controllers/SpeechToTextController.js.map +1 -1
  142. package/lib/module/controllers/VerticalOCRController.js +16 -9
  143. package/lib/module/controllers/VerticalOCRController.js.map +1 -1
  144. package/lib/module/hooks/computer_vision/useClassification.js +5 -5
  145. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  146. package/lib/module/hooks/computer_vision/useImageEmbeddings.js +13 -0
  147. package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -0
  148. package/lib/module/hooks/computer_vision/useImageSegmentation.js +4 -4
  149. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
  150. package/lib/module/hooks/computer_vision/useOCR.js +14 -15
  151. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  152. package/lib/module/hooks/computer_vision/useObjectDetection.js +5 -5
  153. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  154. package/lib/module/hooks/computer_vision/useStyleTransfer.js +5 -5
  155. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  156. package/lib/module/hooks/computer_vision/useVerticalOCR.js +16 -17
  157. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  158. package/lib/module/hooks/general/useExecutorchModule.js +5 -3
  159. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  160. package/lib/module/hooks/natural_language_processing/useLLM.js +22 -25
  161. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  162. package/lib/module/hooks/natural_language_processing/useSpeechToText.js +16 -14
  163. package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
  164. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +4 -5
  165. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
  166. package/lib/module/hooks/natural_language_processing/useTokenizer.js +20 -19
  167. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
  168. package/lib/module/hooks/useNonStaticModule.js +52 -0
  169. package/lib/module/hooks/useNonStaticModule.js.map +1 -0
  170. package/lib/module/index.js +16 -2
  171. package/lib/module/index.js.map +1 -1
  172. package/lib/module/modules/BaseModule.js +6 -3
  173. package/lib/module/modules/BaseModule.js.map +1 -1
  174. package/lib/module/modules/BaseNonStaticModule.js +17 -0
  175. package/lib/module/modules/BaseNonStaticModule.js.map +1 -0
  176. package/lib/module/modules/computer_vision/ClassificationModule.js +13 -8
  177. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  178. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +19 -0
  179. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -0
  180. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +21 -19
  181. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
  182. package/lib/module/modules/computer_vision/OCRModule.js +13 -10
  183. package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
  184. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +13 -8
  185. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  186. package/lib/module/modules/computer_vision/StyleTransferModule.js +13 -8
  187. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  188. package/lib/module/modules/computer_vision/VerticalOCRModule.js +15 -10
  189. package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
  190. package/lib/module/modules/general/ExecutorchModule.js +10 -36
  191. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  192. package/lib/module/modules/natural_language_processing/LLMModule.js +18 -22
  193. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  194. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +27 -16
  195. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  196. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +15 -8
  197. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
  198. package/lib/module/modules/natural_language_processing/TokenizerModule.js +20 -14
  199. package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -1
  200. package/lib/module/native/NativeETInstaller.js +5 -0
  201. package/lib/module/native/NativeETInstaller.js.map +1 -0
  202. package/lib/module/native/RnExecutorchModules.js +2 -11
  203. package/lib/module/native/RnExecutorchModules.js.map +1 -1
  204. package/lib/module/types/common.js +25 -8
  205. package/lib/module/types/common.js.map +1 -1
  206. package/lib/module/types/stt.js +6 -0
  207. package/lib/module/types/stt.js.map +1 -1
  208. package/lib/module/utils/ResourceFetcher.js +276 -114
  209. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  210. package/lib/module/utils/ResourceFetcherUtils.js +155 -0
  211. package/lib/module/utils/ResourceFetcherUtils.js.map +1 -0
  212. package/lib/module/utils/llm.js +41 -1
  213. package/lib/module/utils/llm.js.map +1 -1
  214. package/lib/modules/natural_language_processing/SpeechToTextModule.d.ts +14 -0
  215. package/lib/modules/natural_language_processing/SpeechToTextModule.js +30 -0
  216. package/lib/modules/natural_language_processing/TokenizerModule.js +29 -0
  217. package/lib/native/RnExecutorchModules.d.ts +3 -0
  218. package/lib/native/RnExecutorchModules.js +16 -0
  219. package/lib/typescript/Error.d.ts +2 -0
  220. package/lib/typescript/Error.d.ts.map +1 -1
  221. package/lib/typescript/common/Logger.d.ts +9 -0
  222. package/lib/typescript/common/Logger.d.ts.map +1 -0
  223. package/lib/typescript/constants/llmDefaults.d.ts +1 -0
  224. package/lib/typescript/constants/llmDefaults.d.ts.map +1 -1
  225. package/lib/typescript/constants/modelUrls.d.ts +223 -79
  226. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  227. package/lib/typescript/constants/ocr/models.d.ts +882 -284
  228. package/lib/typescript/constants/ocr/models.d.ts.map +1 -1
  229. package/lib/typescript/constants/sttDefaults.d.ts +1 -0
  230. package/lib/typescript/constants/sttDefaults.d.ts.map +1 -1
  231. package/lib/typescript/controllers/LLMController.d.ts +3 -4
  232. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  233. package/lib/typescript/controllers/OCRController.d.ts +5 -6
  234. package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
  235. package/lib/typescript/controllers/SpeechToTextController.d.ts +11 -6
  236. package/lib/typescript/controllers/SpeechToTextController.d.ts.map +1 -1
  237. package/lib/typescript/controllers/VerticalOCRController.d.ts +5 -6
  238. package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
  239. package/lib/typescript/hooks/computer_vision/useClassification.d.ts +8 -6
  240. package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
  241. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts +16 -0
  242. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts.map +1 -0
  243. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +5 -3
  244. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -1
  245. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +4 -4
  246. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  247. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -3
  248. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
  249. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +5 -3
  250. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
  251. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +3 -5
  252. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  253. package/lib/typescript/hooks/general/useExecutorchModule.d.ts +1 -1
  254. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -4
  255. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  256. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +7 -5
  257. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
  258. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +9 -5
  259. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -1
  260. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +6 -4
  261. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -1
  262. package/lib/typescript/hooks/useNonStaticModule.d.ts +21 -0
  263. package/lib/typescript/hooks/useNonStaticModule.d.ts.map +1 -0
  264. package/lib/typescript/index.d.ts +18 -2
  265. package/lib/typescript/index.d.ts.map +1 -1
  266. package/lib/typescript/modules/BaseModule.d.ts +1 -1
  267. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  268. package/lib/typescript/modules/BaseNonStaticModule.d.ts +10 -0
  269. package/lib/typescript/modules/BaseNonStaticModule.d.ts.map +1 -0
  270. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +6 -6
  271. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  272. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +9 -0
  273. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -0
  274. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +8 -28
  275. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
  276. package/lib/typescript/modules/computer_vision/OCRModule.d.ts +8 -7
  277. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  278. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +7 -5
  279. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  280. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
  281. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  282. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +7 -8
  283. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  284. package/lib/typescript/modules/general/ExecutorchModule.d.ts +5 -8
  285. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  286. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +16 -16
  287. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  288. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +19 -9
  289. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  290. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +7 -5
  291. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
  292. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +10 -9
  293. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -1
  294. package/lib/typescript/native/{NativeStyleTransfer.d.ts → NativeETInstaller.d.ts} +2 -3
  295. package/lib/typescript/native/NativeETInstaller.d.ts.map +1 -0
  296. package/lib/typescript/native/RnExecutorchModules.d.ts +3 -21
  297. package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
  298. package/lib/typescript/types/common.d.ts +30 -2
  299. package/lib/typescript/types/common.d.ts.map +1 -1
  300. package/lib/typescript/types/stt.d.ts +5 -1
  301. package/lib/typescript/types/stt.d.ts.map +1 -1
  302. package/lib/typescript/utils/ResourceFetcher.d.ts +18 -10
  303. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  304. package/lib/typescript/utils/ResourceFetcherUtils.d.ts +55 -0
  305. package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -0
  306. package/lib/typescript/utils/llm.d.ts +4 -0
  307. package/lib/typescript/utils/llm.d.ts.map +1 -1
  308. package/lib/utils/ResourceFetcherUtils.js +119 -0
  309. package/lib/utils/llm.js +72 -0
  310. package/package.json +22 -64
  311. package/react-native-executorch.podspec +75 -3
  312. package/src/Error.ts +8 -10
  313. package/src/common/Logger.ts +25 -0
  314. package/src/constants/llmDefaults.ts +11 -0
  315. package/src/constants/modelUrls.ts +365 -168
  316. package/src/constants/ocr/models.ts +826 -395
  317. package/src/constants/ocr/symbols.ts +63 -63
  318. package/src/constants/sttDefaults.ts +14 -18
  319. package/src/controllers/LLMController.ts +28 -18
  320. package/src/controllers/OCRController.ts +24 -15
  321. package/src/controllers/SpeechToTextController.ts +53 -40
  322. package/src/controllers/VerticalOCRController.ts +24 -14
  323. package/src/hooks/computer_vision/useClassification.ts +10 -11
  324. package/src/hooks/computer_vision/useImageEmbeddings.ts +15 -0
  325. package/src/hooks/computer_vision/useImageSegmentation.ts +5 -8
  326. package/src/hooks/computer_vision/useOCR.ts +29 -21
  327. package/src/hooks/computer_vision/useObjectDetection.ts +6 -9
  328. package/src/hooks/computer_vision/useStyleTransfer.ts +6 -6
  329. package/src/hooks/computer_vision/useVerticalOCR.ts +30 -27
  330. package/src/hooks/general/useExecutorchModule.ts +3 -3
  331. package/src/hooks/natural_language_processing/useLLM.ts +38 -28
  332. package/src/hooks/natural_language_processing/useSpeechToText.ts +34 -26
  333. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +11 -11
  334. package/src/hooks/natural_language_processing/useTokenizer.ts +22 -22
  335. package/src/hooks/useNonStaticModule.ts +74 -0
  336. package/src/index.ts +108 -0
  337. package/src/modules/BaseModule.ts +9 -3
  338. package/src/modules/BaseNonStaticModule.ts +26 -0
  339. package/src/modules/computer_vision/ClassificationModule.ts +20 -11
  340. package/src/modules/computer_vision/ImageEmbeddingsModule.ts +26 -0
  341. package/src/modules/computer_vision/ImageSegmentationModule.ts +35 -27
  342. package/src/modules/computer_vision/OCRModule.ts +23 -15
  343. package/src/modules/computer_vision/ObjectDetectionModule.ts +24 -11
  344. package/src/modules/computer_vision/StyleTransferModule.ts +20 -11
  345. package/src/modules/computer_vision/VerticalOCRModule.ts +25 -21
  346. package/src/modules/general/ExecutorchModule.ts +18 -48
  347. package/src/modules/natural_language_processing/LLMModule.ts +27 -30
  348. package/src/modules/natural_language_processing/SpeechToTextModule.ts +42 -37
  349. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +27 -12
  350. package/src/modules/natural_language_processing/TokenizerModule.ts +27 -17
  351. package/src/native/NativeETInstaller.ts +8 -0
  352. package/src/native/RnExecutorchModules.ts +4 -46
  353. package/src/types/common.ts +40 -12
  354. package/src/types/stt.ts +5 -1
  355. package/src/utils/ResourceFetcher.ts +338 -119
  356. package/src/utils/ResourceFetcherUtils.ts +186 -0
  357. package/src/utils/llm.ts +65 -1
  358. package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
  359. package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
  360. package/third-party/android/libs/opencv/arm64-v8a/libopencv_core.a +0 -0
  361. package/third-party/android/libs/opencv/arm64-v8a/libopencv_features2d.a +0 -0
  362. package/third-party/android/libs/opencv/arm64-v8a/libopencv_highgui.a +0 -0
  363. package/third-party/android/libs/opencv/arm64-v8a/libopencv_imgproc.a +0 -0
  364. package/third-party/android/libs/opencv/arm64-v8a/libopencv_photo.a +0 -0
  365. package/third-party/android/libs/opencv/arm64-v8a/libopencv_video.a +0 -0
  366. package/third-party/android/libs/opencv/x86_64/libopencv_core.a +0 -0
  367. package/third-party/android/libs/opencv/x86_64/libopencv_features2d.a +0 -0
  368. package/third-party/android/libs/opencv/x86_64/libopencv_highgui.a +0 -0
  369. package/third-party/android/libs/opencv/x86_64/libopencv_imgproc.a +0 -0
  370. package/third-party/android/libs/opencv/x86_64/libopencv_photo.a +0 -0
  371. package/third-party/android/libs/opencv/x86_64/libopencv_video.a +0 -0
  372. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv.a +0 -0
  373. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv_hal.a +0 -0
  374. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv_thread.a +0 -0
  375. package/third-party/include/c10/macros/Export.h +163 -0
  376. package/third-party/include/c10/macros/Macros.h +497 -0
  377. package/third-party/include/c10/util/BFloat16-inl.h +342 -0
  378. package/third-party/include/c10/util/BFloat16-math.h +266 -0
  379. package/third-party/include/c10/util/BFloat16.h +125 -0
  380. package/third-party/include/c10/util/Half-inl.h +347 -0
  381. package/third-party/include/c10/util/Half.h +416 -0
  382. package/third-party/include/c10/util/TypeSafeSignMath.h +133 -0
  383. package/third-party/include/c10/util/bit_cast.h +43 -0
  384. package/third-party/include/c10/util/floating_point_utils.h +33 -0
  385. package/third-party/include/c10/util/irange.h +107 -0
  386. package/third-party/include/executorch/ExecuTorch.h +13 -0
  387. package/third-party/include/executorch/ExecuTorchError.h +16 -0
  388. package/third-party/include/executorch/ExecuTorchLog.h +76 -0
  389. package/third-party/include/executorch/ExecuTorchModule.h +286 -0
  390. package/third-party/include/executorch/ExecuTorchTensor.h +742 -0
  391. package/third-party/include/executorch/ExecuTorchValue.h +219 -0
  392. package/third-party/include/executorch/extension/module/module.h +492 -0
  393. package/third-party/include/executorch/extension/tensor/tensor.h +13 -0
  394. package/third-party/include/executorch/extension/tensor/tensor_accessor.h +190 -0
  395. package/third-party/include/executorch/extension/tensor/tensor_ptr.h +347 -0
  396. package/third-party/include/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  397. package/third-party/include/executorch/runtime/backend/backend_execution_context.h +71 -0
  398. package/third-party/include/executorch/runtime/backend/backend_init_context.h +72 -0
  399. package/third-party/include/executorch/runtime/backend/interface.h +166 -0
  400. package/third-party/include/executorch/runtime/core/array_ref.h +235 -0
  401. package/third-party/include/executorch/runtime/core/data_loader.h +136 -0
  402. package/third-party/include/executorch/runtime/core/defines.h +20 -0
  403. package/third-party/include/executorch/runtime/core/error.h +229 -0
  404. package/third-party/include/executorch/runtime/core/evalue.h +521 -0
  405. package/third-party/include/executorch/runtime/core/event_tracer.h +565 -0
  406. package/third-party/include/executorch/runtime/core/event_tracer_hooks.h +323 -0
  407. package/third-party/include/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  408. package/third-party/include/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  409. package/third-party/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  410. package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  411. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  412. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  413. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  414. package/third-party/include/executorch/runtime/core/freeable_buffer.h +107 -0
  415. package/third-party/include/executorch/runtime/core/hierarchical_allocator.h +107 -0
  416. package/third-party/include/executorch/runtime/core/memory_allocator.h +198 -0
  417. package/third-party/include/executorch/runtime/core/named_data_map.h +86 -0
  418. package/third-party/include/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  419. package/third-party/include/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  420. package/third-party/include/executorch/runtime/core/portable_type/bits_types.h +83 -0
  421. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  422. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  423. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  424. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  425. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  426. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  427. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  428. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  429. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  430. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  431. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  432. package/third-party/include/executorch/runtime/core/portable_type/complex.h +44 -0
  433. package/third-party/include/executorch/runtime/core/portable_type/device.h +70 -0
  434. package/third-party/include/executorch/runtime/core/portable_type/half.h +27 -0
  435. package/third-party/include/executorch/runtime/core/portable_type/optional.h +36 -0
  436. package/third-party/include/executorch/runtime/core/portable_type/qint_types.h +83 -0
  437. package/third-party/include/executorch/runtime/core/portable_type/scalar.h +110 -0
  438. package/third-party/include/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  439. package/third-party/include/executorch/runtime/core/portable_type/string_view.h +29 -0
  440. package/third-party/include/executorch/runtime/core/portable_type/tensor.h +142 -0
  441. package/third-party/include/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  442. package/third-party/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  443. package/third-party/include/executorch/runtime/core/result.h +258 -0
  444. package/third-party/include/executorch/runtime/core/span.h +93 -0
  445. package/third-party/include/executorch/runtime/core/tag.h +71 -0
  446. package/third-party/include/executorch/runtime/core/tensor_layout.h +79 -0
  447. package/third-party/include/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  448. package/third-party/include/executorch/runtime/executor/memory_manager.h +113 -0
  449. package/third-party/include/executorch/runtime/executor/method.h +387 -0
  450. package/third-party/include/executorch/runtime/executor/method_meta.h +251 -0
  451. package/third-party/include/executorch/runtime/executor/program.h +320 -0
  452. package/third-party/include/executorch/runtime/executor/pte_data_map.h +144 -0
  453. package/third-party/include/executorch/runtime/executor/tensor_parser.h +156 -0
  454. package/third-party/include/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  455. package/third-party/include/executorch/runtime/kernel/operator_registry.h +278 -0
  456. package/third-party/include/executorch/runtime/platform/abort.h +36 -0
  457. package/third-party/include/executorch/runtime/platform/assert.h +119 -0
  458. package/third-party/include/executorch/runtime/platform/clock.h +43 -0
  459. package/third-party/include/executorch/runtime/platform/compat_unistd.h +75 -0
  460. package/third-party/include/executorch/runtime/platform/compiler.h +191 -0
  461. package/third-party/include/executorch/runtime/platform/log.h +177 -0
  462. package/third-party/include/executorch/runtime/platform/platform.h +133 -0
  463. package/third-party/include/executorch/runtime/platform/profiler.h +292 -0
  464. package/third-party/include/executorch/runtime/platform/runtime.h +35 -0
  465. package/third-party/include/executorch/runtime/platform/system.h +49 -0
  466. package/third-party/include/executorch/runtime/platform/types.h +24 -0
  467. package/third-party/include/executorch/schema/extended_header.h +76 -0
  468. package/third-party/include/opencv2/core/affine.hpp +676 -0
  469. package/third-party/include/opencv2/core/async.hpp +107 -0
  470. package/third-party/include/opencv2/core/base.hpp +735 -0
  471. package/third-party/include/opencv2/core/bindings_utils.hpp +279 -0
  472. package/third-party/include/opencv2/core/bufferpool.hpp +39 -0
  473. package/third-party/include/opencv2/core/check.hpp +231 -0
  474. package/third-party/include/opencv2/core/core.hpp +55 -0
  475. package/third-party/include/opencv2/core/core_c.h +3261 -0
  476. package/third-party/include/opencv2/core/cv_cpu_dispatch.h +404 -0
  477. package/third-party/include/opencv2/core/cv_cpu_helper.h +856 -0
  478. package/third-party/include/opencv2/core/cvdef.h +1003 -0
  479. package/third-party/include/opencv2/core/cvstd.hpp +196 -0
  480. package/third-party/include/opencv2/core/cvstd.inl.hpp +188 -0
  481. package/third-party/include/opencv2/core/cvstd_wrapper.hpp +187 -0
  482. package/third-party/include/opencv2/core/detail/async_promise.hpp +73 -0
  483. package/third-party/include/opencv2/core/detail/dispatch_helper.impl.hpp +48 -0
  484. package/third-party/include/opencv2/core/detail/exception_ptr.hpp +24 -0
  485. package/third-party/include/opencv2/core/dualquaternion.hpp +1054 -0
  486. package/third-party/include/opencv2/core/dualquaternion.inl.hpp +464 -0
  487. package/third-party/include/opencv2/core/eigen.hpp +405 -0
  488. package/third-party/include/opencv2/core/fast_math.hpp +433 -0
  489. package/third-party/include/opencv2/core/hal/hal.hpp +451 -0
  490. package/third-party/include/opencv2/core/hal/interface.h +191 -0
  491. package/third-party/include/opencv2/core/hal/intrin.hpp +1222 -0
  492. package/third-party/include/opencv2/core/hal/intrin_avx.hpp +3378 -0
  493. package/third-party/include/opencv2/core/hal/intrin_avx512.hpp +3688 -0
  494. package/third-party/include/opencv2/core/hal/intrin_cpp.hpp +3446 -0
  495. package/third-party/include/opencv2/core/hal/intrin_forward.hpp +195 -0
  496. package/third-party/include/opencv2/core/hal/intrin_lasx.hpp +3243 -0
  497. package/third-party/include/opencv2/core/hal/intrin_lsx.hpp +2671 -0
  498. package/third-party/include/opencv2/core/hal/intrin_math.hpp +772 -0
  499. package/third-party/include/opencv2/core/hal/intrin_msa.hpp +1973 -0
  500. package/third-party/include/opencv2/core/hal/intrin_neon.hpp +2710 -0
  501. package/third-party/include/opencv2/core/hal/intrin_rvv071.hpp +3452 -0
  502. package/third-party/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2559 -0
  503. package/third-party/include/opencv2/core/hal/intrin_sse.hpp +3528 -0
  504. package/third-party/include/opencv2/core/hal/intrin_sse_em.hpp +175 -0
  505. package/third-party/include/opencv2/core/hal/intrin_vsx.hpp +1756 -0
  506. package/third-party/include/opencv2/core/hal/intrin_wasm.hpp +2911 -0
  507. package/third-party/include/opencv2/core/hal/msa_macros.h +2079 -0
  508. package/third-party/include/opencv2/core/hal/simd_utils.impl.hpp +313 -0
  509. package/third-party/include/opencv2/core/mat.hpp +3842 -0
  510. package/third-party/include/opencv2/core/mat.inl.hpp +2753 -0
  511. package/third-party/include/opencv2/core/matx.hpp +603 -0
  512. package/third-party/include/opencv2/core/matx.inl.hpp +1132 -0
  513. package/third-party/include/opencv2/core/neon_utils.hpp +127 -0
  514. package/third-party/include/opencv2/core/operations.hpp +610 -0
  515. package/third-party/include/opencv2/core/optim.hpp +362 -0
  516. package/third-party/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +66 -0
  517. package/third-party/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +148 -0
  518. package/third-party/include/opencv2/core/parallel/parallel_backend.hpp +108 -0
  519. package/third-party/include/opencv2/core/persistence.hpp +1321 -0
  520. package/third-party/include/opencv2/core/quaternion.hpp +1889 -0
  521. package/third-party/include/opencv2/core/quaternion.inl.hpp +907 -0
  522. package/third-party/include/opencv2/core/saturate.hpp +347 -0
  523. package/third-party/include/opencv2/core/simd_intrinsics.hpp +90 -0
  524. package/third-party/include/opencv2/core/softfloat.hpp +657 -0
  525. package/third-party/include/opencv2/core/sse_utils.hpp +861 -0
  526. package/third-party/include/opencv2/core/traits.hpp +417 -0
  527. package/third-party/include/opencv2/core/types.hpp +2368 -0
  528. package/third-party/include/opencv2/core/types_c.h +2064 -0
  529. package/third-party/include/opencv2/core/utility.hpp +1296 -0
  530. package/third-party/include/opencv2/core/utils/allocator_stats.hpp +31 -0
  531. package/third-party/include/opencv2/core/utils/allocator_stats.impl.hpp +111 -0
  532. package/third-party/include/opencv2/core/utils/filesystem.hpp +91 -0
  533. package/third-party/include/opencv2/core/utils/fp_control_utils.hpp +70 -0
  534. package/third-party/include/opencv2/core/utils/instrumentation.hpp +127 -0
  535. package/third-party/include/opencv2/core/utils/logger.defines.hpp +50 -0
  536. package/third-party/include/opencv2/core/utils/logger.hpp +258 -0
  537. package/third-party/include/opencv2/core/utils/logtag.hpp +27 -0
  538. package/third-party/include/opencv2/core/utils/tls.hpp +230 -0
  539. package/third-party/include/opencv2/core/utils/trace.hpp +281 -0
  540. package/third-party/include/opencv2/core/version.hpp +29 -0
  541. package/third-party/include/opencv2/core/vsx_utils.hpp +1115 -0
  542. package/third-party/include/opencv2/core.hpp +3699 -0
  543. package/third-party/include/opencv2/cvconfig.h +155 -0
  544. package/third-party/include/opencv2/dnn/dnn.hpp +51 -0
  545. package/third-party/include/opencv2/dnn.hpp +17 -0
  546. package/third-party/include/opencv2/features2d/features2d.hpp +55 -0
  547. package/third-party/include/opencv2/features2d/hal/interface.h +32 -0
  548. package/third-party/include/opencv2/features2d.hpp +1756 -0
  549. package/third-party/include/opencv2/highgui/highgui.hpp +113 -0
  550. package/third-party/include/opencv2/highgui.hpp +17 -0
  551. package/third-party/include/opencv2/imgproc/bindings.hpp +34 -0
  552. package/third-party/include/opencv2/imgproc/detail/gcgraph.hpp +355 -0
  553. package/third-party/include/opencv2/imgproc/detail/legacy.hpp +35 -0
  554. package/third-party/include/opencv2/imgproc/hal/hal.hpp +246 -0
  555. package/third-party/include/opencv2/imgproc/hal/interface.h +52 -0
  556. package/third-party/include/opencv2/imgproc/imgproc.hpp +55 -0
  557. package/third-party/include/opencv2/imgproc/imgproc_c.h +1261 -0
  558. package/third-party/include/opencv2/imgproc/segmentation.hpp +168 -0
  559. package/third-party/include/opencv2/imgproc/types_c.h +632 -0
  560. package/third-party/include/opencv2/imgproc.hpp +5956 -0
  561. package/third-party/include/opencv2/opencv.hpp +102 -0
  562. package/third-party/include/opencv2/opencv_modules.hpp +19 -0
  563. package/third-party/include/opencv2/photo/legacy/constants_c.h +10 -0
  564. package/third-party/include/opencv2/photo/photo.hpp +55 -0
  565. package/third-party/include/opencv2/photo.hpp +975 -0
  566. package/third-party/include/opencv2/video/background_segm.hpp +341 -0
  567. package/third-party/include/opencv2/video/detail/tracking.detail.hpp +435 -0
  568. package/third-party/include/opencv2/video/legacy/constants_c.h +15 -0
  569. package/third-party/include/opencv2/video/tracking.hpp +1014 -0
  570. package/third-party/include/opencv2/video/video.hpp +55 -0
  571. package/third-party/include/opencv2/video.hpp +65 -0
  572. package/third-party/include/tokenizers-cpp/tokenizers_c.h +61 -0
  573. package/third-party/include/tokenizers-cpp/tokenizers_cpp.h +118 -0
  574. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.h +27 -0
  575. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm +249 -0
  576. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.h +14 -0
  577. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.mm +80 -0
  578. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.h +32 -0
  579. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.mm +95 -0
  580. package/third-party/ios/ExecutorchLib/ExecutorchLib/InputType.h +12 -0
  581. package/third-party/ios/ExecutorchLib/ExecutorchLib/Utils.hpp +217 -0
  582. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.cpp +11 -0
  583. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.h +11 -0
  584. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/irunner.h +48 -0
  585. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/runner.cpp +278 -0
  586. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/runner.h +67 -0
  587. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/stats.h +164 -0
  588. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_decoder_runner.cpp +65 -0
  589. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_decoder_runner.h +105 -0
  590. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_prefiller.cpp +91 -0
  591. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_prefiller.h +51 -0
  592. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_token_generator.h +162 -0
  593. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/util.h +108 -0
  594. package/third-party/ios/ExecutorchLib/ExecutorchLib/sampler/sampler.cpp +193 -0
  595. package/third-party/ios/ExecutorchLib/ExecutorchLib/sampler/sampler.h +64 -0
  596. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/base64.h +202 -0
  597. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.cpp +313 -0
  598. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.h +57 -0
  599. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.cpp +78 -0
  600. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.h +23 -0
  601. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.cpp +427 -0
  602. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.h +87 -0
  603. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tokenizer.h +76 -0
  604. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.pbxproj +683 -0
  605. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  606. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.xcworkspace/xcuserdata/norbertklockiewicz.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  607. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/xcuserdata/norbertklockiewicz.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  608. package/third-party/ios/ExecutorchLib/build.sh +44 -0
  609. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/Info.plist +43 -0
  610. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64/libbackend_coreml_ios.a +0 -0
  611. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64-simulator/libbackend_coreml_simulator.a +0 -0
  612. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/Info.plist +43 -0
  613. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64/libbackend_mps_ios.a +0 -0
  614. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64-simulator/libbackend_mps_simulator.a +0 -0
  615. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/Info.plist +43 -0
  616. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64/libbackend_xnnpack_ios.a +0 -0
  617. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64-simulator/libbackend_xnnpack_simulator.a +0 -0
  618. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/Info.plist +47 -0
  619. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Export.h +163 -0
  620. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Macros.h +497 -0
  621. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-inl.h +342 -0
  622. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-math.h +266 -0
  623. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16.h +125 -0
  624. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half-inl.h +347 -0
  625. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half.h +416 -0
  626. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/TypeSafeSignMath.h +133 -0
  627. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/bit_cast.h +43 -0
  628. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/floating_point_utils.h +33 -0
  629. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/irange.h +107 -0
  630. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorch.h +13 -0
  631. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchError.h +16 -0
  632. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchLog.h +76 -0
  633. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchModule.h +286 -0
  634. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchTensor.h +742 -0
  635. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchValue.h +219 -0
  636. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/module/module.h +492 -0
  637. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor.h +13 -0
  638. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_accessor.h +190 -0
  639. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr.h +347 -0
  640. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  641. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_execution_context.h +71 -0
  642. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_init_context.h +72 -0
  643. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/interface.h +166 -0
  644. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/array_ref.h +235 -0
  645. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/data_loader.h +136 -0
  646. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/defines.h +20 -0
  647. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/error.h +229 -0
  648. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/evalue.h +521 -0
  649. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer.h +565 -0
  650. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks.h +323 -0
  651. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  652. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  653. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  654. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  655. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  656. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  657. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  658. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/freeable_buffer.h +107 -0
  659. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/hierarchical_allocator.h +107 -0
  660. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/memory_allocator.h +198 -0
  661. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/named_data_map.h +86 -0
  662. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  663. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  664. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bits_types.h +83 -0
  665. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  666. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  667. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  668. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  669. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  670. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  671. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  672. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  673. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  674. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  675. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  676. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/complex.h +44 -0
  677. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/device.h +70 -0
  678. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/half.h +27 -0
  679. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/optional.h +36 -0
  680. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/qint_types.h +83 -0
  681. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar.h +110 -0
  682. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  683. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/string_view.h +29 -0
  684. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor.h +142 -0
  685. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  686. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  687. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/result.h +258 -0
  688. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/span.h +93 -0
  689. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tag.h +71 -0
  690. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_layout.h +79 -0
  691. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  692. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/memory_manager.h +113 -0
  693. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method.h +387 -0
  694. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method_meta.h +251 -0
  695. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/program.h +320 -0
  696. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/pte_data_map.h +144 -0
  697. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/tensor_parser.h +156 -0
  698. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  699. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/operator_registry.h +278 -0
  700. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/abort.h +36 -0
  701. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/assert.h +119 -0
  702. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/clock.h +43 -0
  703. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compat_unistd.h +75 -0
  704. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compiler.h +191 -0
  705. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/log.h +177 -0
  706. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/platform.h +133 -0
  707. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/profiler.h +292 -0
  708. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/runtime.h +35 -0
  709. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/system.h +49 -0
  710. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/types.h +24 -0
  711. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/schema/extended_header.h +76 -0
  712. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/module.modulemap +5 -0
  713. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/libexecutorch_ios.a +0 -0
  714. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Export.h +163 -0
  715. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Macros.h +497 -0
  716. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-inl.h +342 -0
  717. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-math.h +266 -0
  718. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16.h +125 -0
  719. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half-inl.h +347 -0
  720. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half.h +416 -0
  721. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/TypeSafeSignMath.h +133 -0
  722. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/bit_cast.h +43 -0
  723. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/floating_point_utils.h +33 -0
  724. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/irange.h +107 -0
  725. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorch.h +13 -0
  726. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchError.h +16 -0
  727. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchLog.h +76 -0
  728. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchModule.h +286 -0
  729. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchTensor.h +742 -0
  730. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchValue.h +219 -0
  731. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/module/module.h +492 -0
  732. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor.h +13 -0
  733. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_accessor.h +190 -0
  734. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr.h +347 -0
  735. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  736. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_execution_context.h +71 -0
  737. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_init_context.h +72 -0
  738. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/interface.h +166 -0
  739. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/array_ref.h +235 -0
  740. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/data_loader.h +136 -0
  741. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/defines.h +20 -0
  742. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/error.h +229 -0
  743. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/evalue.h +521 -0
  744. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer.h +565 -0
  745. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks.h +323 -0
  746. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  747. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  748. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  749. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  750. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  751. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  752. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  753. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/freeable_buffer.h +107 -0
  754. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/hierarchical_allocator.h +107 -0
  755. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/memory_allocator.h +198 -0
  756. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/named_data_map.h +86 -0
  757. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  758. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  759. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bits_types.h +83 -0
  760. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  761. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  762. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  763. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  764. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  765. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  766. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  767. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  768. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  769. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  770. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  771. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/complex.h +44 -0
  772. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/device.h +70 -0
  773. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/half.h +27 -0
  774. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/optional.h +36 -0
  775. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/qint_types.h +83 -0
  776. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar.h +110 -0
  777. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  778. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/string_view.h +29 -0
  779. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor.h +142 -0
  780. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  781. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  782. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/result.h +258 -0
  783. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/span.h +93 -0
  784. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tag.h +71 -0
  785. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_layout.h +79 -0
  786. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  787. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/memory_manager.h +113 -0
  788. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method.h +387 -0
  789. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method_meta.h +251 -0
  790. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/program.h +320 -0
  791. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/pte_data_map.h +144 -0
  792. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/tensor_parser.h +156 -0
  793. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  794. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/operator_registry.h +278 -0
  795. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/abort.h +36 -0
  796. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/assert.h +119 -0
  797. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/clock.h +43 -0
  798. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compat_unistd.h +75 -0
  799. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compiler.h +191 -0
  800. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/log.h +177 -0
  801. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/platform.h +133 -0
  802. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/profiler.h +292 -0
  803. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/runtime.h +35 -0
  804. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/system.h +49 -0
  805. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/types.h +24 -0
  806. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/schema/extended_header.h +76 -0
  807. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/module.modulemap +5 -0
  808. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/libexecutorch_simulator.a +0 -0
  809. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/Info.plist +43 -0
  810. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64/libkernels_custom_ios.a +0 -0
  811. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64-simulator/libkernels_custom_simulator.a +0 -0
  812. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/Info.plist +43 -0
  813. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64/libkernels_optimized_ios.a +0 -0
  814. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64-simulator/libkernels_optimized_simulator.a +0 -0
  815. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/Info.plist +43 -0
  816. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64/libkernels_portable_ios.a +0 -0
  817. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64-simulator/libkernels_portable_simulator.a +0 -0
  818. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/Info.plist +43 -0
  819. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64/libkernels_quantized_ios.a +0 -0
  820. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64-simulator/libkernels_quantized_simulator.a +0 -0
  821. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/Info.plist +43 -0
  822. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/bitmap256.h +82 -0
  823. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/filtered_re2.h +111 -0
  824. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/pod_array.h +43 -0
  825. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter.h +130 -0
  826. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter_tree.h +139 -0
  827. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prog.h +483 -0
  828. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/re2.h +994 -0
  829. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/regexp.h +692 -0
  830. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/set.h +85 -0
  831. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_array.h +367 -0
  832. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_set.h +241 -0
  833. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/stringpiece.h +205 -0
  834. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_casefold.h +78 -0
  835. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_groups.h +64 -0
  836. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/walker-inl.h +235 -0
  837. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Info.plist +26 -0
  838. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/re2 +0 -0
  839. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/bitmap256.h +82 -0
  840. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/filtered_re2.h +111 -0
  841. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/pod_array.h +43 -0
  842. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter.h +130 -0
  843. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter_tree.h +139 -0
  844. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prog.h +483 -0
  845. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/re2.h +994 -0
  846. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/regexp.h +692 -0
  847. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/set.h +85 -0
  848. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_array.h +367 -0
  849. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_set.h +241 -0
  850. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/stringpiece.h +205 -0
  851. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_casefold.h +78 -0
  852. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_groups.h +64 -0
  853. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/walker-inl.h +235 -0
  854. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Info.plist +26 -0
  855. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/re2 +0 -0
  856. package/third-party/ios/ios.toolchain.cmake +1122 -0
  857. package/LICENSE +0 -79
  858. package/README.md +0 -148
  859. package/android/src/main/java/com/swmansion/rnexecutorch/Classification.kt +0 -64
  860. package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +0 -90
  861. package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +0 -58
  862. package/android/src/main/java/com/swmansion/rnexecutorch/OCR.kt +0 -90
  863. package/android/src/main/java/com/swmansion/rnexecutorch/ObjectDetection.kt +0 -64
  864. package/android/src/main/java/com/swmansion/rnexecutorch/SpeechToText.kt +0 -91
  865. package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +0 -54
  866. package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +0 -51
  867. package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +0 -86
  868. package/android/src/main/java/com/swmansion/rnexecutorch/VerticalOCR.kt +0 -179
  869. package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +0 -54
  870. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +0 -48
  871. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +0 -37
  872. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +0 -46
  873. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/Constants.kt +0 -1005
  874. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +0 -26
  875. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +0 -142
  876. package/android/src/main/java/com/swmansion/rnexecutorch/models/objectDetection/SSDLiteLargeModel.kt +0 -74
  877. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/Detector.kt +0 -82
  878. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/RecognitionHandler.kt +0 -117
  879. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/Recognizer.kt +0 -51
  880. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/VerticalDetector.kt +0 -89
  881. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/CTCLabelConverter.kt +0 -58
  882. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/Constants.kt +0 -31
  883. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/DetectorUtils.kt +0 -608
  884. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +0 -430
  885. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/BaseS2TDecoder.kt +0 -39
  886. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/BaseS2TModule.kt +0 -43
  887. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/Moonshine.kt +0 -16
  888. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/MoonshineDecoder.kt +0 -23
  889. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/MoonshineEncoder.kt +0 -20
  890. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/Whisper.kt +0 -16
  891. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/WhisperDecoder.kt +0 -22
  892. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/WhisperEncoder.kt +0 -29
  893. package/android/src/main/java/com/swmansion/rnexecutorch/models/styleTransfer/StyleTransferModel.kt +0 -43
  894. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -87
  895. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ETError.kt +0 -34
  896. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ImageProcessor.kt +0 -237
  897. package/android/src/main/java/com/swmansion/rnexecutorch/utils/Numerical.kt +0 -8
  898. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ObjectDetectionUtils.kt +0 -201
  899. package/android/src/main/java/com/swmansion/rnexecutorch/utils/STFT.kt +0 -50
  900. package/android/src/main/java/com/swmansion/rnexecutorch/utils/TensorUtils.kt +0 -103
  901. package/ios/RnExecutorch/Classification.h +0 -5
  902. package/ios/RnExecutorch/Classification.mm +0 -54
  903. package/ios/RnExecutorch/ETModule.h +0 -5
  904. package/ios/RnExecutorch/ETModule.mm +0 -75
  905. package/ios/RnExecutorch/ImageSegmentation.h +0 -5
  906. package/ios/RnExecutorch/ImageSegmentation.mm +0 -60
  907. package/ios/RnExecutorch/OCR.h +0 -5
  908. package/ios/RnExecutorch/OCR.mm +0 -96
  909. package/ios/RnExecutorch/ObjectDetection.h +0 -5
  910. package/ios/RnExecutorch/ObjectDetection.mm +0 -56
  911. package/ios/RnExecutorch/SpeechToText.h +0 -5
  912. package/ios/RnExecutorch/SpeechToText.mm +0 -125
  913. package/ios/RnExecutorch/StyleTransfer.h +0 -5
  914. package/ios/RnExecutorch/StyleTransfer.mm +0 -55
  915. package/ios/RnExecutorch/TextEmbeddings.h +0 -5
  916. package/ios/RnExecutorch/TextEmbeddings.mm +0 -62
  917. package/ios/RnExecutorch/Tokenizer.h +0 -5
  918. package/ios/RnExecutorch/Tokenizer.mm +0 -83
  919. package/ios/RnExecutorch/VerticalOCR.h +0 -5
  920. package/ios/RnExecutorch/VerticalOCR.mm +0 -183
  921. package/ios/RnExecutorch/models/BaseModel.h +0 -21
  922. package/ios/RnExecutorch/models/BaseModel.mm +0 -43
  923. package/ios/RnExecutorch/models/classification/ClassificationModel.h +0 -10
  924. package/ios/RnExecutorch/models/classification/ClassificationModel.mm +0 -53
  925. package/ios/RnExecutorch/models/classification/Constants.h +0 -3
  926. package/ios/RnExecutorch/models/image_segmentation/Constants.h +0 -4
  927. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +0 -10
  928. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +0 -146
  929. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.hpp +0 -11
  930. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +0 -64
  931. package/ios/RnExecutorch/models/ocr/Detector.h +0 -9
  932. package/ios/RnExecutorch/models/ocr/Detector.mm +0 -101
  933. package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +0 -16
  934. package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +0 -135
  935. package/ios/RnExecutorch/models/ocr/Recognizer.h +0 -8
  936. package/ios/RnExecutorch/models/ocr/Recognizer.mm +0 -77
  937. package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -10
  938. package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +0 -118
  939. package/ios/RnExecutorch/models/ocr/utils/CTCLabelConverter.h +0 -16
  940. package/ios/RnExecutorch/models/ocr/utils/CTCLabelConverter.mm +0 -80
  941. package/ios/RnExecutorch/models/ocr/utils/Constants.h +0 -26
  942. package/ios/RnExecutorch/models/ocr/utils/DetectorUtils.h +0 -31
  943. package/ios/RnExecutorch/models/ocr/utils/DetectorUtils.mm +0 -754
  944. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.h +0 -10
  945. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -67
  946. package/ios/RnExecutorch/models/ocr/utils/RecognizerUtils.h +0 -35
  947. package/ios/RnExecutorch/models/ocr/utils/RecognizerUtils.mm +0 -331
  948. package/ios/RnExecutorch/models/stt/Moonshine.hpp +0 -13
  949. package/ios/RnExecutorch/models/stt/Moonshine.mm +0 -64
  950. package/ios/RnExecutorch/models/stt/MoonshineDecoder.hpp +0 -16
  951. package/ios/RnExecutorch/models/stt/MoonshineDecoder.mm +0 -24
  952. package/ios/RnExecutorch/models/stt/MoonshineEncoder.hpp +0 -15
  953. package/ios/RnExecutorch/models/stt/MoonshineEncoder.mm +0 -18
  954. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.hpp +0 -26
  955. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +0 -19
  956. package/ios/RnExecutorch/models/stt/Whisper.hpp +0 -12
  957. package/ios/RnExecutorch/models/stt/Whisper.mm +0 -68
  958. package/ios/RnExecutorch/models/stt/WhisperDecoder.hpp +0 -16
  959. package/ios/RnExecutorch/models/stt/WhisperDecoder.mm +0 -22
  960. package/ios/RnExecutorch/models/stt/WhisperEncoder.hpp +0 -15
  961. package/ios/RnExecutorch/models/stt/WhisperEncoder.mm +0 -21
  962. package/ios/RnExecutorch/models/style_transfer/StyleTransferModel.h +0 -11
  963. package/ios/RnExecutorch/models/style_transfer/StyleTransferModel.mm +0 -50
  964. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +0 -15
  965. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +0 -45
  966. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +0 -8
  967. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +0 -49
  968. package/ios/RnExecutorch/utils/Constants.h +0 -8
  969. package/ios/RnExecutorch/utils/ObjectDetectionUtils.hpp +0 -23
  970. package/ios/RnExecutorch/utils/SFFT.hpp +0 -13
  971. package/ios/RnExecutorch/utils/SFFT.mm +0 -71
  972. package/lib/module/native/NativeClassification.js +0 -5
  973. package/lib/module/native/NativeClassification.js.map +0 -1
  974. package/lib/module/native/NativeETModule.js +0 -5
  975. package/lib/module/native/NativeETModule.js.map +0 -1
  976. package/lib/module/native/NativeImageSegmentation.js +0 -5
  977. package/lib/module/native/NativeImageSegmentation.js.map +0 -1
  978. package/lib/module/native/NativeOCR.js +0 -5
  979. package/lib/module/native/NativeOCR.js.map +0 -1
  980. package/lib/module/native/NativeObjectDetection.js +0 -5
  981. package/lib/module/native/NativeObjectDetection.js.map +0 -1
  982. package/lib/module/native/NativeSpeechToText.js +0 -5
  983. package/lib/module/native/NativeSpeechToText.js.map +0 -1
  984. package/lib/module/native/NativeStyleTransfer.js +0 -5
  985. package/lib/module/native/NativeStyleTransfer.js.map +0 -1
  986. package/lib/module/native/NativeTextEmbeddings.js +0 -5
  987. package/lib/module/native/NativeTextEmbeddings.js.map +0 -1
  988. package/lib/module/native/NativeTokenizer.js +0 -5
  989. package/lib/module/native/NativeTokenizer.js.map +0 -1
  990. package/lib/module/native/NativeVerticalOCR.js +0 -5
  991. package/lib/module/native/NativeVerticalOCR.js.map +0 -1
  992. package/lib/module/package.json +0 -1
  993. package/lib/typescript/native/NativeClassification.d.ts +0 -10
  994. package/lib/typescript/native/NativeClassification.d.ts.map +0 -1
  995. package/lib/typescript/native/NativeETModule.d.ts +0 -9
  996. package/lib/typescript/native/NativeETModule.d.ts.map +0 -1
  997. package/lib/typescript/native/NativeImageSegmentation.d.ts +0 -10
  998. package/lib/typescript/native/NativeImageSegmentation.d.ts.map +0 -1
  999. package/lib/typescript/native/NativeOCR.d.ts +0 -9
  1000. package/lib/typescript/native/NativeOCR.d.ts.map +0 -1
  1001. package/lib/typescript/native/NativeObjectDetection.d.ts +0 -9
  1002. package/lib/typescript/native/NativeObjectDetection.d.ts.map +0 -1
  1003. package/lib/typescript/native/NativeSpeechToText.d.ts +0 -12
  1004. package/lib/typescript/native/NativeSpeechToText.d.ts.map +0 -1
  1005. package/lib/typescript/native/NativeStyleTransfer.d.ts.map +0 -1
  1006. package/lib/typescript/native/NativeTextEmbeddings.d.ts +0 -8
  1007. package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +0 -1
  1008. package/lib/typescript/native/NativeTokenizer.d.ts +0 -12
  1009. package/lib/typescript/native/NativeTokenizer.d.ts.map +0 -1
  1010. package/lib/typescript/native/NativeVerticalOCR.d.ts +0 -9
  1011. package/lib/typescript/native/NativeVerticalOCR.d.ts.map +0 -1
  1012. package/src/native/NativeClassification.ts +0 -9
  1013. package/src/native/NativeETModule.ts +0 -14
  1014. package/src/native/NativeImageSegmentation.ts +0 -14
  1015. package/src/native/NativeOCR.ts +0 -16
  1016. package/src/native/NativeObjectDetection.ts +0 -10
  1017. package/src/native/NativeSpeechToText.ts +0 -17
  1018. package/src/native/NativeStyleTransfer.ts +0 -10
  1019. package/src/native/NativeTextEmbeddings.ts +0 -9
  1020. package/src/native/NativeTokenizer.ts +0 -13
  1021. package/src/native/NativeVerticalOCR.ts +0 -16
@@ -0,0 +1,2368 @@
1
+ /*M///////////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
+ //
5
+ // By downloading, copying, installing or using the software you agree to this
6
+ license.
7
+ // If you do not agree to this license, do not download, install,
8
+ // copy or use the software.
9
+ //
10
+ //
11
+ // License Agreement
12
+ // For Open Source Computer Vision Library
13
+ //
14
+ // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
15
+ // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
16
+ // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
17
+ // Third party copyrights are property of their respective owners.
18
+ //
19
+ // Redistribution and use in source and binary forms, with or without
20
+ modification,
21
+ // are permitted provided that the following conditions are met:
22
+ //
23
+ // * Redistribution's of source code must retain the above copyright notice,
24
+ // this list of conditions and the following disclaimer.
25
+ //
26
+ // * Redistribution's in binary form must reproduce the above copyright
27
+ notice,
28
+ // this list of conditions and the following disclaimer in the documentation
29
+ // and/or other materials provided with the distribution.
30
+ //
31
+ // * The name of the copyright holders may not be used to endorse or promote
32
+ products
33
+ // derived from this software without specific prior written permission.
34
+ //
35
+ // This software is provided by the copyright holders and contributors "as is"
36
+ and
37
+ // any express or implied warranties, including, but not limited to, the implied
38
+ // warranties of merchantability and fitness for a particular purpose are
39
+ disclaimed.
40
+ // In no event shall the Intel Corporation or contributors be liable for any
41
+ direct,
42
+ // indirect, incidental, special, exemplary, or consequential damages
43
+ // (including, but not limited to, procurement of substitute goods or services;
44
+ // loss of use, data, or profits; or business interruption) however caused
45
+ // and on any theory of liability, whether in contract, strict liability,
46
+ // or tort (including negligence or otherwise) arising in any way out of
47
+ // the use of this software, even if advised of the possibility of such damage.
48
+ //
49
+ //M*/
50
+
51
+ #ifndef OPENCV_CORE_TYPES_HPP
52
+ #define OPENCV_CORE_TYPES_HPP
53
+
54
+ #ifndef __cplusplus
55
+ #error types.hpp header must be compiled as C++
56
+ #endif
57
+
58
+ #include <cfloat>
59
+ #include <climits>
60
+ #include <limits>
61
+ #include <vector>
62
+
63
+ #include "opencv2/core/cvdef.h"
64
+ #include "opencv2/core/cvstd.hpp"
65
+ #include "opencv2/core/matx.hpp"
66
+
67
+ #ifdef _MSC_VER
68
+ #pragma warning(push)
69
+ #pragma warning(disable : 4459) // declaration of '...' hides global declaration
70
+ #endif
71
+
72
+ namespace cv {
73
+
74
+ //! @addtogroup core_basic
75
+ //! @{
76
+
77
+ //////////////////////////////// Complex //////////////////////////////
78
+
79
+ /** @brief A complex number class.
80
+
81
+ The template class is similar and compatible with std::complex, however it
82
+ provides slightly more convenient access to the real and imaginary parts using
83
+ through the simple field access, as opposite to std::complex::real() and
84
+ std::complex::imag().
85
+ */
86
+ template <typename _Tp> class Complex {
87
+ public:
88
+ //! default constructor
89
+ Complex();
90
+ Complex(_Tp _re, _Tp _im = 0);
91
+
92
+ //! conversion to another data type
93
+ template <typename T2> operator Complex<T2>() const;
94
+ //! conjugation
95
+ Complex conj() const;
96
+
97
+ _Tp re, im; ///< the real and the imaginary parts
98
+ };
99
+
100
+ typedef Complex<float> Complexf;
101
+ typedef Complex<double> Complexd;
102
+
103
+ template <typename _Tp> class DataType<Complex<_Tp>> {
104
+ public:
105
+ typedef Complex<_Tp> value_type;
106
+ typedef value_type work_type;
107
+ typedef _Tp channel_type;
108
+
109
+ enum {
110
+ generic_type = 0,
111
+ channels = 2,
112
+ fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
113
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
114
+ ,
115
+ depth = DataType<channel_type>::depth,
116
+ type = CV_MAKETYPE(depth, channels)
117
+ #endif
118
+ };
119
+
120
+ typedef Vec<channel_type, channels> vec_type;
121
+ };
122
+
123
+ namespace traits {
124
+ template <typename _Tp> struct Depth<Complex<_Tp>> {
125
+ enum { value = Depth<_Tp>::value };
126
+ };
127
+ template <typename _Tp> struct Type<Complex<_Tp>> {
128
+ enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) };
129
+ };
130
+ } // namespace traits
131
+
132
+ //////////////////////////////// Point_ ////////////////////////////////
133
+
134
+ /** @brief Template class for 2D points specified by its coordinates `x` and
135
+ `y`.
136
+
137
+ An instance of the class is interchangeable with C structures, CvPoint and
138
+ CvPoint2D32f . There is also a cast operator to convert point coordinates to the
139
+ specified type. The conversion from floating-point coordinates to integer
140
+ coordinates is done by rounding. Commonly, the conversion uses this operation
141
+ for each of the coordinates. Besides the class members listed in the declaration
142
+ above, the following operations on points are implemented:
143
+ @code
144
+ pt1 = pt2 + pt3;
145
+ pt1 = pt2 - pt3;
146
+ pt1 = pt2 * a;
147
+ pt1 = a * pt2;
148
+ pt1 = pt2 / a;
149
+ pt1 += pt2;
150
+ pt1 -= pt2;
151
+ pt1 *= a;
152
+ pt1 /= a;
153
+ double value = norm(pt); // L2 norm
154
+ pt1 == pt2;
155
+ pt1 != pt2;
156
+ @endcode
157
+ For your convenience, the following type aliases are defined:
158
+ @code
159
+ typedef Point_<int> Point2i;
160
+ typedef Point2i Point;
161
+ typedef Point_<float> Point2f;
162
+ typedef Point_<double> Point2d;
163
+ @endcode
164
+ Example:
165
+ @code
166
+ Point2f a(0.3f, 0.f), b(0.f, 0.4f);
167
+ Point pt = (a + b)*10.f;
168
+ cout << pt.x << ", " << pt.y << endl;
169
+ @endcode
170
+ */
171
+ template <typename _Tp> class Point_ {
172
+ public:
173
+ typedef _Tp value_type;
174
+
175
+ //! default constructor
176
+ Point_();
177
+ Point_(_Tp _x, _Tp _y);
178
+ #if (defined(__GNUC__) && __GNUC__ < 5) && \
179
+ !defined(__clang__) // GCC 4.x bug. Details:
180
+ // https://github.com/opencv/opencv/pull/20837
181
+ Point_(const Point_ &pt);
182
+ Point_(Point_ &&pt) CV_NOEXCEPT = default;
183
+ #elif OPENCV_ABI_COMPATIBILITY < 500
184
+ Point_(const Point_ &pt) = default;
185
+ Point_(Point_ &&pt) CV_NOEXCEPT = default;
186
+ #endif
187
+ Point_(const Size_<_Tp> &sz);
188
+ Point_(const Vec<_Tp, 2> &v);
189
+
190
+ #if (defined(__GNUC__) && __GNUC__ < 5) && \
191
+ !defined(__clang__) // GCC 4.x bug. Details:
192
+ // https://github.com/opencv/opencv/pull/20837
193
+ Point_ &operator=(const Point_ &pt);
194
+ Point_ &operator=(Point_ &&pt) CV_NOEXCEPT = default;
195
+ #elif OPENCV_ABI_COMPATIBILITY < 500
196
+ Point_ &operator=(const Point_ &pt) = default;
197
+ Point_ &operator=(Point_ &&pt) CV_NOEXCEPT = default;
198
+ #endif
199
+ //! conversion to another data type
200
+ template <typename _Tp2> operator Point_<_Tp2>() const;
201
+
202
+ //! conversion to the old-style C structures
203
+ operator Vec<_Tp, 2>() const;
204
+
205
+ //! dot product
206
+ _Tp dot(const Point_ &pt) const;
207
+ //! dot product computed in double-precision arithmetics
208
+ double ddot(const Point_ &pt) const;
209
+ //! cross-product
210
+ double cross(const Point_ &pt) const;
211
+ //! checks whether the point is inside the specified rectangle
212
+ bool inside(const Rect_<_Tp> &r) const;
213
+ _Tp x; //!< x coordinate of the point
214
+ _Tp y; //!< y coordinate of the point
215
+ };
216
+
217
+ typedef Point_<int> Point2i;
218
+ typedef Point_<int64> Point2l;
219
+ typedef Point_<float> Point2f;
220
+ typedef Point_<double> Point2d;
221
+ typedef Point2i Point;
222
+
223
+ template <typename _Tp> class DataType<Point_<_Tp>> {
224
+ public:
225
+ typedef Point_<_Tp> value_type;
226
+ typedef Point_<typename DataType<_Tp>::work_type> work_type;
227
+ typedef _Tp channel_type;
228
+
229
+ enum {
230
+ generic_type = 0,
231
+ channels = 2,
232
+ fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
233
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
234
+ ,
235
+ depth = DataType<channel_type>::depth,
236
+ type = CV_MAKETYPE(depth, channels)
237
+ #endif
238
+ };
239
+
240
+ typedef Vec<channel_type, channels> vec_type;
241
+ };
242
+
243
+ namespace traits {
244
+ template <typename _Tp> struct Depth<Point_<_Tp>> {
245
+ enum { value = Depth<_Tp>::value };
246
+ };
247
+ template <typename _Tp> struct Type<Point_<_Tp>> {
248
+ enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) };
249
+ };
250
+ } // namespace traits
251
+
252
+ //////////////////////////////// Point3_ ////////////////////////////////
253
+
254
+ /** @brief Template class for 3D points specified by its coordinates `x`, `y`
255
+ and `z`.
256
+
257
+ An instance of the class is interchangeable with the C structure CvPoint2D32f .
258
+ Similarly to Point_ , the coordinates of 3D points can be converted to another
259
+ type. The vector arithmetic and comparison operations are also supported.
260
+
261
+ The following Point3_\<\> aliases are available:
262
+ @code
263
+ typedef Point3_<int> Point3i;
264
+ typedef Point3_<float> Point3f;
265
+ typedef Point3_<double> Point3d;
266
+ @endcode
267
+ @see cv::Point3i, cv::Point3f and cv::Point3d
268
+ */
269
+ template <typename _Tp> class Point3_ {
270
+ public:
271
+ typedef _Tp value_type;
272
+
273
+ //! default constructor
274
+ Point3_();
275
+ Point3_(_Tp _x, _Tp _y, _Tp _z);
276
+ #if OPENCV_ABI_COMPATIBILITY < 500
277
+ Point3_(const Point3_ &pt) = default;
278
+ Point3_(Point3_ &&pt) CV_NOEXCEPT = default;
279
+ #endif
280
+ explicit Point3_(const Point_<_Tp> &pt);
281
+ Point3_(const Vec<_Tp, 3> &v);
282
+
283
+ #if OPENCV_ABI_COMPATIBILITY < 500
284
+ Point3_ &operator=(const Point3_ &pt) = default;
285
+ Point3_ &operator=(Point3_ &&pt) CV_NOEXCEPT = default;
286
+ #endif
287
+ //! conversion to another data type
288
+ template <typename _Tp2> operator Point3_<_Tp2>() const;
289
+ //! conversion to cv::Vec<>
290
+ operator Vec<_Tp, 3>() const;
291
+
292
+ //! dot product
293
+ _Tp dot(const Point3_ &pt) const;
294
+ //! dot product computed in double-precision arithmetics
295
+ double ddot(const Point3_ &pt) const;
296
+ //! cross product of the 2 3D points
297
+ Point3_ cross(const Point3_ &pt) const;
298
+ _Tp x; //!< x coordinate of the 3D point
299
+ _Tp y; //!< y coordinate of the 3D point
300
+ _Tp z; //!< z coordinate of the 3D point
301
+ };
302
+
303
+ typedef Point3_<int> Point3i;
304
+ typedef Point3_<float> Point3f;
305
+ typedef Point3_<double> Point3d;
306
+
307
+ template <typename _Tp> class DataType<Point3_<_Tp>> {
308
+ public:
309
+ typedef Point3_<_Tp> value_type;
310
+ typedef Point3_<typename DataType<_Tp>::work_type> work_type;
311
+ typedef _Tp channel_type;
312
+
313
+ enum {
314
+ generic_type = 0,
315
+ channels = 3,
316
+ fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
317
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
318
+ ,
319
+ depth = DataType<channel_type>::depth,
320
+ type = CV_MAKETYPE(depth, channels)
321
+ #endif
322
+ };
323
+
324
+ typedef Vec<channel_type, channels> vec_type;
325
+ };
326
+
327
+ namespace traits {
328
+ template <typename _Tp> struct Depth<Point3_<_Tp>> {
329
+ enum { value = Depth<_Tp>::value };
330
+ };
331
+ template <typename _Tp> struct Type<Point3_<_Tp>> {
332
+ enum { value = CV_MAKETYPE(Depth<_Tp>::value, 3) };
333
+ };
334
+ } // namespace traits
335
+
336
+ //////////////////////////////// Size_ ////////////////////////////////
337
+
338
+ /** @brief Template class for specifying the size of an image or rectangle.
339
+
340
+ The class includes two members called width and height. The structure can be
341
+ converted to and from the old OpenCV structures CvSize and CvSize2D32f . The
342
+ same set of arithmetic and comparison operations as for Point_ is available.
343
+
344
+ OpenCV defines the following Size_\<\> aliases:
345
+ @code
346
+ typedef Size_<int> Size2i;
347
+ typedef Size2i Size;
348
+ typedef Size_<float> Size2f;
349
+ @endcode
350
+ */
351
+ template <typename _Tp> class Size_ {
352
+ public:
353
+ typedef _Tp value_type;
354
+
355
+ //! default constructor
356
+ Size_();
357
+ Size_(_Tp _width, _Tp _height);
358
+ #if OPENCV_ABI_COMPATIBILITY < 500
359
+ Size_(const Size_ &sz) = default;
360
+ Size_(Size_ &&sz) CV_NOEXCEPT = default;
361
+ #endif
362
+ Size_(const Point_<_Tp> &pt);
363
+
364
+ #if OPENCV_ABI_COMPATIBILITY < 500
365
+ Size_ &operator=(const Size_ &sz) = default;
366
+ Size_ &operator=(Size_ &&sz) CV_NOEXCEPT = default;
367
+ #endif
368
+ //! the area (width*height)
369
+ _Tp area() const;
370
+ //! aspect ratio (width/height)
371
+ double aspectRatio() const;
372
+ //! true if empty
373
+ bool empty() const;
374
+
375
+ //! conversion of another data type.
376
+ template <typename _Tp2> operator Size_<_Tp2>() const;
377
+
378
+ _Tp width; //!< the width
379
+ _Tp height; //!< the height
380
+ };
381
+
382
+ typedef Size_<int> Size2i;
383
+ typedef Size_<int64> Size2l;
384
+ typedef Size_<float> Size2f;
385
+ typedef Size_<double> Size2d;
386
+ typedef Size2i Size;
387
+
388
+ template <typename _Tp> class DataType<Size_<_Tp>> {
389
+ public:
390
+ typedef Size_<_Tp> value_type;
391
+ typedef Size_<typename DataType<_Tp>::work_type> work_type;
392
+ typedef _Tp channel_type;
393
+
394
+ enum {
395
+ generic_type = 0,
396
+ channels = 2,
397
+ fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
398
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
399
+ ,
400
+ depth = DataType<channel_type>::depth,
401
+ type = CV_MAKETYPE(depth, channels)
402
+ #endif
403
+ };
404
+
405
+ typedef Vec<channel_type, channels> vec_type;
406
+ };
407
+
408
+ namespace traits {
409
+ template <typename _Tp> struct Depth<Size_<_Tp>> {
410
+ enum { value = Depth<_Tp>::value };
411
+ };
412
+ template <typename _Tp> struct Type<Size_<_Tp>> {
413
+ enum { value = CV_MAKETYPE(Depth<_Tp>::value, 2) };
414
+ };
415
+ } // namespace traits
416
+
417
+ //////////////////////////////// Rect_ ////////////////////////////////
418
+
419
+ /** @brief Template class for 2D rectangles
420
+
421
+ described by the following parameters:
422
+ - Coordinates of the top-left corner. This is a default interpretation of
423
+ Rect_::x and Rect_::y in OpenCV. Though, in your algorithms you may count x and
424
+ y from the bottom-left corner.
425
+ - Rectangle width and height.
426
+
427
+ OpenCV typically assumes that the top and left boundary of the rectangle are
428
+ inclusive, while the right and bottom boundaries are not. For example, the
429
+ method Rect_::contains returns true if
430
+
431
+ \f[x \leq pt.x < x+width,
432
+ y \leq pt.y < y+height\f]
433
+
434
+ Virtually every loop over an image ROI in OpenCV (where ROI is specified by
435
+ Rect_\<int\> ) is implemented as:
436
+ @code
437
+ for(int y = roi.y; y < roi.y + roi.height; y++)
438
+ for(int x = roi.x; x < roi.x + roi.width; x++)
439
+ {
440
+ // ...
441
+ }
442
+ @endcode
443
+ In addition to the class members, the following operations on rectangles are
444
+ implemented:
445
+ - \f$\texttt{rect} = \texttt{rect} \pm \texttt{point}\f$ (shifting a rectangle
446
+ by a certain offset)
447
+ - \f$\texttt{rect} = \texttt{rect} \pm \texttt{size}\f$ (expanding or
448
+ shrinking a rectangle by a certain amount)
449
+ - rect += point, rect -= point, rect += size, rect -= size (augmenting
450
+ operations)
451
+ - rect = rect1 & rect2 (rectangle intersection)
452
+ - rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 )
453
+ - rect &= rect1, rect |= rect1 (and the corresponding augmenting operations)
454
+ - rect == rect1, rect != rect1 (rectangle comparison)
455
+
456
+ This is an example how the partial ordering on rectangles can be established
457
+ (rect1 \f$\subseteq\f$ rect2):
458
+ @code
459
+ template<typename _Tp> inline bool
460
+ operator <= (const Rect_<_Tp>& r1, const Rect_<_Tp>& r2)
461
+ {
462
+ return (r1 & r2) == r1;
463
+ }
464
+ @endcode
465
+ For your convenience, the Rect_\<\> alias is available: cv::Rect
466
+ */
467
+ template <typename _Tp> class Rect_ {
468
+ public:
469
+ typedef _Tp value_type;
470
+
471
+ //! default constructor
472
+ Rect_();
473
+ Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
474
+ #if OPENCV_ABI_COMPATIBILITY < 500
475
+ Rect_(const Rect_ &r) = default;
476
+ Rect_(Rect_ &&r) CV_NOEXCEPT = default;
477
+ #endif
478
+ Rect_(const Point_<_Tp> &org, const Size_<_Tp> &sz);
479
+ Rect_(const Point_<_Tp> &pt1, const Point_<_Tp> &pt2);
480
+
481
+ #if OPENCV_ABI_COMPATIBILITY < 500
482
+ Rect_ &operator=(const Rect_ &r) = default;
483
+ Rect_ &operator=(Rect_ &&r) CV_NOEXCEPT = default;
484
+ #endif
485
+ //! the top-left corner
486
+ Point_<_Tp> tl() const;
487
+ //! the bottom-right corner
488
+ Point_<_Tp> br() const;
489
+
490
+ //! size (width, height) of the rectangle
491
+ Size_<_Tp> size() const;
492
+ //! area (width*height) of the rectangle
493
+ _Tp area() const;
494
+ //! true if empty
495
+ bool empty() const;
496
+
497
+ //! conversion to another data type
498
+ template <typename _Tp2> operator Rect_<_Tp2>() const;
499
+
500
+ //! checks whether the rectangle contains the point
501
+ /*! @warning After OpenCV 4.11.0, when calling Rect.contains() with
502
+ * cv::Point2f / cv::Point2d point, point should not convert/round to int.
503
+ * ```
504
+ * Rect_<int> r(0,0,500,500); Point_<float> pt(250.0f, 499.9f);
505
+ * r.contains(pt) returns false.(OpenCV 4.10.0 or before)
506
+ * r.contains(pt) returns true. (OpenCV 4.11.0 or later)
507
+ * ```
508
+ */
509
+ template <typename _Tp2> inline bool contains(const Point_<_Tp2> &pt) const;
510
+
511
+ _Tp x; //!< x coordinate of the top-left corner
512
+ _Tp y; //!< y coordinate of the top-left corner
513
+ _Tp width; //!< width of the rectangle
514
+ _Tp height; //!< height of the rectangle
515
+ };
516
+
517
+ typedef Rect_<int> Rect2i;
518
+ typedef Rect_<float> Rect2f;
519
+ typedef Rect_<double> Rect2d;
520
+ typedef Rect2i Rect;
521
+
522
+ template <typename _Tp> class DataType<Rect_<_Tp>> {
523
+ public:
524
+ typedef Rect_<_Tp> value_type;
525
+ typedef Rect_<typename DataType<_Tp>::work_type> work_type;
526
+ typedef _Tp channel_type;
527
+
528
+ enum {
529
+ generic_type = 0,
530
+ channels = 4,
531
+ fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
532
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
533
+ ,
534
+ depth = DataType<channel_type>::depth,
535
+ type = CV_MAKETYPE(depth, channels)
536
+ #endif
537
+ };
538
+
539
+ typedef Vec<channel_type, channels> vec_type;
540
+ };
541
+
542
+ namespace traits {
543
+ template <typename _Tp> struct Depth<Rect_<_Tp>> {
544
+ enum { value = Depth<_Tp>::value };
545
+ };
546
+ template <typename _Tp> struct Type<Rect_<_Tp>> {
547
+ enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) };
548
+ };
549
+ } // namespace traits
550
+
551
+ ///////////////////////////// RotatedRect /////////////////////////////
552
+
553
+ /** @brief The class represents rotated (i.e. not up-right) rectangles on a
554
+ plane.
555
+
556
+ Each rectangle is specified by the center point (mass center), length of each
557
+ side (represented by #Size2f structure) and the rotation angle in degrees.
558
+
559
+ The sample below demonstrates how to use RotatedRect:
560
+ @snippet snippets/core_various.cpp RotatedRect_demo
561
+ ![image](pics/rotatedrect.png)
562
+
563
+ @sa CamShift, fitEllipse, minAreaRect, CvBox2D
564
+ */
565
+ class CV_EXPORTS_W_SIMPLE RotatedRect {
566
+ public:
567
+ //! default constructor
568
+ CV_WRAP RotatedRect();
569
+ /** full constructor
570
+ @param center The rectangle mass center.
571
+ @param size Width and height of the rectangle.
572
+ @param angle The rotation angle in a clockwise direction. When the angle is 0,
573
+ 90, 180, 270 etc., the rectangle becomes an up-right rectangle.
574
+ */
575
+ CV_WRAP RotatedRect(const Point2f &center, const Size2f &size, float angle);
576
+ /**
577
+ Any 3 end points of the RotatedRect. They must be given in order (either
578
+ clockwise or anticlockwise).
579
+ */
580
+ CV_WRAP RotatedRect(const Point2f &point1, const Point2f &point2,
581
+ const Point2f &point3);
582
+
583
+ /** returns 4 vertices of the rotated rectangle
584
+ @param pts The points array for storing rectangle vertices. The order is
585
+ _bottomLeft_, _topLeft_, topRight, bottomRight.
586
+ @note _Bottom_, _Top_, _Left_ and _Right_ sides refer to the original
587
+ rectangle (angle is 0), so after 180 degree rotation _bottomLeft_ point will
588
+ be located at the top right corner of the rectangle.
589
+ */
590
+ void points(Point2f pts[]) const;
591
+
592
+ CV_WRAP void points(CV_OUT std::vector<Point2f> &pts) const;
593
+
594
+ //! returns the minimal up-right integer rectangle containing the rotated
595
+ //! rectangle
596
+ CV_WRAP Rect boundingRect() const;
597
+ //! returns the minimal (exact) floating point rectangle containing the
598
+ //! rotated rectangle, not intended for use with images
599
+ CV_WRAP Rect2f boundingRect2f() const;
600
+ //! returns the rectangle mass center
601
+ CV_PROP_RW Point2f center;
602
+ //! returns width and height of the rectangle
603
+ CV_PROP_RW Size2f size;
604
+ //! returns the rotation angle. When the angle is 0, 90, 180, 270 etc., the
605
+ //! rectangle becomes an up-right rectangle.
606
+ CV_PROP_RW float angle;
607
+ };
608
+
609
+ template <> class DataType<RotatedRect> {
610
+ public:
611
+ typedef RotatedRect value_type;
612
+ typedef value_type work_type;
613
+ typedef float channel_type;
614
+
615
+ enum {
616
+ generic_type = 0,
617
+ channels = (int)sizeof(value_type) / sizeof(channel_type), // 5
618
+ fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
619
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
620
+ ,
621
+ depth = DataType<channel_type>::depth,
622
+ type = CV_MAKETYPE(depth, channels)
623
+ #endif
624
+ };
625
+
626
+ typedef Vec<channel_type, channels> vec_type;
627
+ };
628
+
629
+ namespace traits {
630
+ template <> struct Depth<RotatedRect> {
631
+ enum { value = Depth<float>::value };
632
+ };
633
+ template <> struct Type<RotatedRect> {
634
+ enum {
635
+ value = CV_MAKETYPE(Depth<float>::value,
636
+ (int)sizeof(RotatedRect) / sizeof(float))
637
+ };
638
+ };
639
+ } // namespace traits
640
+
641
+ //////////////////////////////// Range /////////////////////////////////
642
+
643
+ /** @brief Template class specifying a continuous subsequence (slice) of a
644
+ sequence.
645
+
646
+ The class is used to specify a row or a column span in a matrix ( Mat ) and for
647
+ many other purposes. Range(a,b) is basically the same as a:b in Matlab or a..b
648
+ in Python. As in Python, start is an inclusive left boundary of the range and
649
+ end is an exclusive right boundary of the range. Such a half-opened interval is
650
+ usually denoted as \f$[start,end)\f$ .
651
+
652
+ The static method Range::all() returns a special variable that means "the whole
653
+ sequence" or "the whole range", just like " : " in Matlab or " ... " in Python.
654
+ All the methods and functions in OpenCV that take Range support this special
655
+ Range::all() value. But, of course, in case of your own custom processing, you
656
+ will probably have to check and handle it explicitly:
657
+ @code
658
+ void my_function(..., const Range& r, ....)
659
+ {
660
+ if(r == Range::all()) {
661
+ // process all the data
662
+ }
663
+ else {
664
+ // process [r.start, r.end)
665
+ }
666
+ }
667
+ @endcode
668
+ */
669
+ class CV_EXPORTS Range {
670
+ public:
671
+ Range();
672
+ Range(int _start, int _end);
673
+ int size() const;
674
+ bool empty() const;
675
+ static Range all();
676
+
677
+ int start, end;
678
+ };
679
+
680
+ template <> class DataType<Range> {
681
+ public:
682
+ typedef Range value_type;
683
+ typedef value_type work_type;
684
+ typedef int channel_type;
685
+
686
+ enum {
687
+ generic_type = 0,
688
+ channels = 2,
689
+ fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
690
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
691
+ ,
692
+ depth = DataType<channel_type>::depth,
693
+ type = CV_MAKETYPE(depth, channels)
694
+ #endif
695
+ };
696
+
697
+ typedef Vec<channel_type, channels> vec_type;
698
+ };
699
+
700
+ namespace traits {
701
+ template <> struct Depth<Range> {
702
+ enum { value = Depth<int>::value };
703
+ };
704
+ template <> struct Type<Range> {
705
+ enum { value = CV_MAKETYPE(Depth<int>::value, 2) };
706
+ };
707
+ } // namespace traits
708
+
709
+ //////////////////////////////// Scalar_ ///////////////////////////////
710
+
711
+ /** @brief Template class for a 4-element vector derived from Vec.
712
+
713
+ Being derived from Vec\<_Tp, 4\> , Scalar\_ and Scalar can be used just as
714
+ typical 4-element vectors. In addition, they can be converted to/from CvScalar .
715
+ The type Scalar is widely used in OpenCV to pass pixel values.
716
+ */
717
+ template <typename _Tp> class Scalar_ : public Vec<_Tp, 4> {
718
+ public:
719
+ //! default constructor
720
+ Scalar_();
721
+ Scalar_(_Tp v0, _Tp v1, _Tp v2 = 0, _Tp v3 = 0);
722
+ Scalar_(_Tp v0);
723
+
724
+ Scalar_(const Scalar_ &s);
725
+ Scalar_(Scalar_ &&s) CV_NOEXCEPT;
726
+
727
+ Scalar_ &operator=(const Scalar_ &s);
728
+ Scalar_ &operator=(Scalar_ &&s) CV_NOEXCEPT;
729
+
730
+ template <typename _Tp2, int cn> Scalar_(const Vec<_Tp2, cn> &v);
731
+
732
+ //! returns a scalar with all elements set to v0
733
+ static Scalar_<_Tp> all(_Tp v0);
734
+
735
+ //! conversion to another data type
736
+ template <typename T2> operator Scalar_<T2>() const;
737
+
738
+ //! per-element product
739
+ Scalar_<_Tp> mul(const Scalar_<_Tp> &a, double scale = 1) const;
740
+
741
+ //! returns (v0, -v1, -v2, -v3)
742
+ Scalar_<_Tp> conj() const;
743
+
744
+ //! returns true iff v1 == v2 == v3 == 0
745
+ bool isReal() const;
746
+ };
747
+
748
+ typedef Scalar_<double> Scalar;
749
+
750
+ template <typename _Tp> class DataType<Scalar_<_Tp>> {
751
+ public:
752
+ typedef Scalar_<_Tp> value_type;
753
+ typedef Scalar_<typename DataType<_Tp>::work_type> work_type;
754
+ typedef _Tp channel_type;
755
+
756
+ enum {
757
+ generic_type = 0,
758
+ channels = 4,
759
+ fmt = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
760
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
761
+ ,
762
+ depth = DataType<channel_type>::depth,
763
+ type = CV_MAKETYPE(depth, channels)
764
+ #endif
765
+ };
766
+
767
+ typedef Vec<channel_type, channels> vec_type;
768
+ };
769
+
770
+ namespace traits {
771
+ template <typename _Tp> struct Depth<Scalar_<_Tp>> {
772
+ enum { value = Depth<_Tp>::value };
773
+ };
774
+ template <typename _Tp> struct Type<Scalar_<_Tp>> {
775
+ enum { value = CV_MAKETYPE(Depth<_Tp>::value, 4) };
776
+ };
777
+ } // namespace traits
778
+
779
+ /////////////////////////////// KeyPoint ////////////////////////////////
780
+
781
+ /** @brief Data structure for salient point detectors.
782
+
783
+ The class instance stores a keypoint, i.e. a point feature found by one of many
784
+ available keypoint detectors, such as Harris corner detector, #FAST,
785
+ %StarDetector, %SURF, %SIFT etc.
786
+
787
+ The keypoint is characterized by the 2D position, scale (proportional to the
788
+ diameter of the neighborhood that needs to be taken into account), orientation
789
+ and some other parameters. The keypoint neighborhood is then analyzed by another
790
+ algorithm that builds a descriptor (usually represented as a feature vector).
791
+ The keypoints representing the same object in different images can then be
792
+ matched using %KDTree or another method.
793
+ */
794
+ class CV_EXPORTS_W_SIMPLE KeyPoint {
795
+ public:
796
+ //! the default constructor
797
+ CV_WRAP KeyPoint();
798
+ /**
799
+ @param pt x & y coordinates of the keypoint
800
+ @param size keypoint diameter
801
+ @param angle keypoint orientation
802
+ @param response keypoint detector response on the keypoint (that is, strength
803
+ of the keypoint)
804
+ @param octave pyramid octave in which the keypoint has been detected
805
+ @param class_id object id
806
+ */
807
+ KeyPoint(Point2f pt, float size, float angle = -1, float response = 0,
808
+ int octave = 0, int class_id = -1);
809
+ /**
810
+ @param x x-coordinate of the keypoint
811
+ @param y y-coordinate of the keypoint
812
+ @param size keypoint diameter
813
+ @param angle keypoint orientation
814
+ @param response keypoint detector response on the keypoint (that is, strength
815
+ of the keypoint)
816
+ @param octave pyramid octave in which the keypoint has been detected
817
+ @param class_id object id
818
+ */
819
+ CV_WRAP KeyPoint(float x, float y, float size, float angle = -1,
820
+ float response = 0, int octave = 0, int class_id = -1);
821
+
822
+ size_t hash() const;
823
+
824
+ /**
825
+ This method converts vector of keypoints to vector of points or the reverse,
826
+ where each keypoint is assigned the same size and the same orientation.
827
+
828
+ @param keypoints Keypoints obtained from any feature detection algorithm like
829
+ SIFT/SURF/ORB
830
+ @param points2f Array of (x,y) coordinates of each keypoint
831
+ @param keypointIndexes Array of indexes of keypoints to be converted to
832
+ points. (Acts like a mask to convert only specified keypoints)
833
+ */
834
+ CV_WRAP static void
835
+ convert(const std::vector<KeyPoint> &keypoints,
836
+ CV_OUT std::vector<Point2f> &points2f,
837
+ const std::vector<int> &keypointIndexes = std::vector<int>());
838
+ /** @overload
839
+ @param points2f Array of (x,y) coordinates of each keypoint
840
+ @param keypoints Keypoints obtained from any feature detection algorithm like
841
+ SIFT/SURF/ORB
842
+ @param size keypoint diameter
843
+ @param response keypoint detector response on the keypoint (that is, strength
844
+ of the keypoint)
845
+ @param octave pyramid octave in which the keypoint has been detected
846
+ @param class_id object id
847
+ */
848
+ CV_WRAP static void convert(const std::vector<Point2f> &points2f,
849
+ CV_OUT std::vector<KeyPoint> &keypoints,
850
+ float size = 1, float response = 1,
851
+ int octave = 0, int class_id = -1);
852
+
853
+ /**
854
+ This method computes overlap for pair of keypoints. Overlap is the ratio
855
+ between area of keypoint regions' intersection and area of keypoint regions'
856
+ union (considering keypoint region as circle). If they don't overlap, we get
857
+ zero. If they coincide at same location with same size, we get 1.
858
+ @param kp1 First keypoint
859
+ @param kp2 Second keypoint
860
+ */
861
+ CV_WRAP static float overlap(const KeyPoint &kp1, const KeyPoint &kp2);
862
+
863
+ CV_PROP_RW Point2f pt; //!< coordinates of the keypoints
864
+ CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood
865
+ CV_PROP_RW float
866
+ angle; //!< computed orientation of the keypoint (-1 if not applicable);
867
+ //!< it's in [0,360) degrees and measured relative to
868
+ //!< image coordinate system, ie in clockwise.
869
+ CV_PROP_RW float response; //!< the response by which the most strong
870
+ //!< keypoints have been selected. Can be used for
871
+ //!< the further sorting or subsampling
872
+ CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has
873
+ //!< been extracted
874
+ CV_PROP_RW int class_id; //!< object class (if the keypoints need to be
875
+ //!< clustered by an object they belong to)
876
+ };
877
+
878
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
879
+ template <> class DataType<KeyPoint> {
880
+ public:
881
+ typedef KeyPoint value_type;
882
+ typedef float work_type;
883
+ typedef float channel_type;
884
+
885
+ enum {
886
+ generic_type = 0,
887
+ depth = DataType<channel_type>::depth,
888
+ channels = (int)(sizeof(value_type) / sizeof(channel_type)), // 7
889
+ fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
890
+ type = CV_MAKETYPE(depth, channels)
891
+ };
892
+
893
+ typedef Vec<channel_type, channels> vec_type;
894
+ };
895
+ #endif
896
+
897
+ //////////////////////////////// DMatch /////////////////////////////////
898
+
899
+ /** @brief Class for matching keypoint descriptors
900
+
901
+ query descriptor index, train descriptor index, train image index, and distance
902
+ between descriptors.
903
+ */
904
+ class CV_EXPORTS_W_SIMPLE DMatch {
905
+ public:
906
+ CV_WRAP DMatch();
907
+ CV_WRAP DMatch(int _queryIdx, int _trainIdx, float _distance);
908
+ CV_WRAP DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance);
909
+
910
+ CV_PROP_RW int queryIdx; //!< query descriptor index
911
+ CV_PROP_RW int trainIdx; //!< train descriptor index
912
+ CV_PROP_RW int imgIdx; //!< train image index
913
+
914
+ CV_PROP_RW float distance;
915
+
916
+ // less is better
917
+ bool operator<(const DMatch &m) const;
918
+ };
919
+
920
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
921
+ template <> class DataType<DMatch> {
922
+ public:
923
+ typedef DMatch value_type;
924
+ typedef int work_type;
925
+ typedef int channel_type;
926
+
927
+ enum {
928
+ generic_type = 0,
929
+ depth = DataType<channel_type>::depth,
930
+ channels = (int)(sizeof(value_type) / sizeof(channel_type)), // 4
931
+ fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
932
+ type = CV_MAKETYPE(depth, channels)
933
+ };
934
+
935
+ typedef Vec<channel_type, channels> vec_type;
936
+ };
937
+ #endif
938
+
939
+ ///////////////////////////// TermCriteria //////////////////////////////
940
+
941
+ /** @brief The class defining termination criteria for iterative algorithms.
942
+
943
+ You can initialize it by default constructor and then override any parameters,
944
+ or the structure may be fully initialized using the advanced variant of the
945
+ constructor.
946
+ */
947
+ class CV_EXPORTS TermCriteria {
948
+ public:
949
+ /**
950
+ Criteria type, can be one of: COUNT, EPS or COUNT + EPS
951
+ */
952
+ enum Type {
953
+ COUNT = 1, //!< the maximum number of iterations or elements to compute
954
+ MAX_ITER = COUNT, //!< ditto
955
+ EPS = 2 //!< the desired accuracy or change in parameters at which the
956
+ //!< iterative algorithm stops
957
+ };
958
+
959
+ //! default constructor
960
+ TermCriteria();
961
+ /**
962
+ @param type The type of termination criteria, one of TermCriteria::Type
963
+ @param maxCount The maximum number of iterations or elements to compute.
964
+ @param epsilon The desired accuracy or change in parameters at which the
965
+ iterative algorithm stops.
966
+ */
967
+ TermCriteria(int type, int maxCount, double epsilon);
968
+
969
+ inline bool isValid() const {
970
+ const bool isCount = (type & COUNT) && maxCount > 0;
971
+ const bool isEps = (type & EPS) && !cvIsNaN(epsilon);
972
+ return isCount || isEps;
973
+ }
974
+
975
+ int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS
976
+ int maxCount; //!< the maximum number of iterations/elements
977
+ double epsilon; //!< the desired accuracy
978
+ };
979
+
980
+ //! @} core_basic
981
+
982
+ ///////////////////////// raster image moments //////////////////////////
983
+
984
+ //! @addtogroup imgproc_shape
985
+ //! @{
986
+
987
+ /** @brief struct returned by cv::moments
988
+
989
+ The spatial moments \f$\texttt{Moments::m}_{ji}\f$ are computed as:
990
+
991
+ \f[\texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot
992
+ y^i \right )\f]
993
+
994
+ The central moments \f$\texttt{Moments::mu}_{ji}\f$ are computed as:
995
+
996
+ \f[\texttt{mu} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot (x -
997
+ \bar{x} )^j \cdot (y - \bar{y} )^i \right )\f]
998
+
999
+ where \f$(\bar{x}, \bar{y})\f$ is the mass center:
1000
+
1001
+ \f[\bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} =
1002
+ \frac{\texttt{m}_{01}}{\texttt{m}_{00}}\f]
1003
+
1004
+ The normalized central moments \f$\texttt{Moments::nu}_{ij}\f$ are computed as:
1005
+
1006
+ \f[\texttt{nu} _{ji}= \frac{\texttt{mu}_{ji}}{\texttt{m}_{00}^{(i+j)/2+1}} .\f]
1007
+
1008
+ @note
1009
+ \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$
1010
+ \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$ ,
1011
+ hence the values are not stored.
1012
+
1013
+ The moments of a contour are defined in the same way but computed using the
1014
+ Green's formula (see <http://en.wikipedia.org/wiki/Green_theorem>). So, due to a
1015
+ limited raster resolution, the moments computed for a contour are slightly
1016
+ different from the moments computed for the same rasterized contour.
1017
+
1018
+ @note
1019
+ Since the contour moments are computed using Green formula, you may get
1020
+ seemingly odd results for contours with self-intersections, e.g. a zero area
1021
+ (m00) for butterfly-shaped contours.
1022
+ */
1023
+ class CV_EXPORTS_W_MAP Moments {
1024
+ public:
1025
+ //! the default constructor
1026
+ Moments();
1027
+ //! the full constructor
1028
+ Moments(double m00, double m10, double m01, double m20, double m11,
1029
+ double m02, double m30, double m21, double m12, double m03);
1030
+ ////! the conversion from CvMoments
1031
+ // Moments( const CvMoments& moments );
1032
+ ////! the conversion to CvMoments
1033
+ // operator CvMoments() const;
1034
+
1035
+ //! @name spatial moments
1036
+ //! @{
1037
+ CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
1038
+ //! @}
1039
+
1040
+ //! @name central moments
1041
+ //! @{
1042
+ CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03;
1043
+ //! @}
1044
+
1045
+ //! @name central normalized moments
1046
+ //! @{
1047
+ CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03;
1048
+ //! @}
1049
+ };
1050
+
1051
+ template <> class DataType<Moments> {
1052
+ public:
1053
+ typedef Moments value_type;
1054
+ typedef double work_type;
1055
+ typedef double channel_type;
1056
+
1057
+ enum {
1058
+ generic_type = 0,
1059
+ channels = (int)(sizeof(value_type) / sizeof(channel_type)), // 24
1060
+ fmt = DataType<channel_type>::fmt + ((channels - 1) << 8)
1061
+ #ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
1062
+ ,
1063
+ depth = DataType<channel_type>::depth,
1064
+ type = CV_MAKETYPE(depth, channels)
1065
+ #endif
1066
+ };
1067
+
1068
+ typedef Vec<channel_type, channels> vec_type;
1069
+ };
1070
+
1071
+ namespace traits {
1072
+ template <> struct Depth<Moments> {
1073
+ enum { value = Depth<double>::value };
1074
+ };
1075
+ template <> struct Type<Moments> {
1076
+ enum {
1077
+ value = CV_MAKETYPE(Depth<double>::value,
1078
+ (int)(sizeof(Moments) / sizeof(double)))
1079
+ };
1080
+ };
1081
+ } // namespace traits
1082
+
1083
+ //! @} imgproc_shape
1084
+
1085
+ //! @cond IGNORED
1086
+
1087
+ /////////////////////////////////////////////////////////////////////////
1088
+ ///////////////////////////// Implementation ////////////////////////////
1089
+ /////////////////////////////////////////////////////////////////////////
1090
+
1091
+ //////////////////////////////// Complex ////////////////////////////////
1092
+
1093
+ template <typename _Tp> inline Complex<_Tp>::Complex() : re(0), im(0) {}
1094
+
1095
+ template <typename _Tp>
1096
+ inline Complex<_Tp>::Complex(_Tp _re, _Tp _im) : re(_re), im(_im) {}
1097
+
1098
+ template <typename _Tp>
1099
+ template <typename T2>
1100
+ inline Complex<_Tp>::operator Complex<T2>() const {
1101
+ return Complex<T2>(saturate_cast<T2>(re), saturate_cast<T2>(im));
1102
+ }
1103
+
1104
+ template <typename _Tp> inline Complex<_Tp> Complex<_Tp>::conj() const {
1105
+ return Complex<_Tp>(re, -im);
1106
+ }
1107
+
1108
+ template <typename _Tp>
1109
+ static inline bool operator==(const Complex<_Tp> &a, const Complex<_Tp> &b) {
1110
+ return a.re == b.re && a.im == b.im;
1111
+ }
1112
+
1113
+ template <typename _Tp>
1114
+ static inline bool operator!=(const Complex<_Tp> &a, const Complex<_Tp> &b) {
1115
+ return a.re != b.re || a.im != b.im;
1116
+ }
1117
+
1118
+ template <typename _Tp>
1119
+ static inline Complex<_Tp> operator+(const Complex<_Tp> &a,
1120
+ const Complex<_Tp> &b) {
1121
+ return Complex<_Tp>(a.re + b.re, a.im + b.im);
1122
+ }
1123
+
1124
+ template <typename _Tp>
1125
+ static inline Complex<_Tp> &operator+=(Complex<_Tp> &a, const Complex<_Tp> &b) {
1126
+ a.re += b.re;
1127
+ a.im += b.im;
1128
+ return a;
1129
+ }
1130
+
1131
+ template <typename _Tp>
1132
+ static inline Complex<_Tp> operator-(const Complex<_Tp> &a,
1133
+ const Complex<_Tp> &b) {
1134
+ return Complex<_Tp>(a.re - b.re, a.im - b.im);
1135
+ }
1136
+
1137
+ template <typename _Tp>
1138
+ static inline Complex<_Tp> &operator-=(Complex<_Tp> &a, const Complex<_Tp> &b) {
1139
+ a.re -= b.re;
1140
+ a.im -= b.im;
1141
+ return a;
1142
+ }
1143
+
1144
+ template <typename _Tp>
1145
+ static inline Complex<_Tp> operator-(const Complex<_Tp> &a) {
1146
+ return Complex<_Tp>(-a.re, -a.im);
1147
+ }
1148
+
1149
+ template <typename _Tp>
1150
+ static inline Complex<_Tp> operator*(const Complex<_Tp> &a,
1151
+ const Complex<_Tp> &b) {
1152
+ return Complex<_Tp>(a.re * b.re - a.im * b.im, a.re * b.im + a.im * b.re);
1153
+ }
1154
+
1155
+ template <typename _Tp>
1156
+ static inline Complex<_Tp> operator*(const Complex<_Tp> &a, _Tp b) {
1157
+ return Complex<_Tp>(a.re * b, a.im * b);
1158
+ }
1159
+
1160
+ template <typename _Tp>
1161
+ static inline Complex<_Tp> operator*(_Tp b, const Complex<_Tp> &a) {
1162
+ return Complex<_Tp>(a.re * b, a.im * b);
1163
+ }
1164
+
1165
+ template <typename _Tp>
1166
+ static inline Complex<_Tp> operator+(const Complex<_Tp> &a, _Tp b) {
1167
+ return Complex<_Tp>(a.re + b, a.im);
1168
+ }
1169
+
1170
+ template <typename _Tp>
1171
+ static inline Complex<_Tp> operator-(const Complex<_Tp> &a, _Tp b) {
1172
+ return Complex<_Tp>(a.re - b, a.im);
1173
+ }
1174
+
1175
+ template <typename _Tp>
1176
+ static inline Complex<_Tp> operator+(_Tp b, const Complex<_Tp> &a) {
1177
+ return Complex<_Tp>(a.re + b, a.im);
1178
+ }
1179
+
1180
+ template <typename _Tp>
1181
+ static inline Complex<_Tp> operator-(_Tp b, const Complex<_Tp> &a) {
1182
+ return Complex<_Tp>(b - a.re, -a.im);
1183
+ }
1184
+
1185
+ template <typename _Tp>
1186
+ static inline Complex<_Tp> &operator+=(Complex<_Tp> &a, _Tp b) {
1187
+ a.re += b;
1188
+ return a;
1189
+ }
1190
+
1191
+ template <typename _Tp>
1192
+ static inline Complex<_Tp> &operator-=(Complex<_Tp> &a, _Tp b) {
1193
+ a.re -= b;
1194
+ return a;
1195
+ }
1196
+
1197
+ template <typename _Tp>
1198
+ static inline Complex<_Tp> &operator*=(Complex<_Tp> &a, _Tp b) {
1199
+ a.re *= b;
1200
+ a.im *= b;
1201
+ return a;
1202
+ }
1203
+
1204
+ template <typename _Tp> static inline double abs(const Complex<_Tp> &a) {
1205
+ return std::sqrt((double)a.re * a.re + (double)a.im * a.im);
1206
+ }
1207
+
1208
+ template <typename _Tp>
1209
+ static inline Complex<_Tp> operator/(const Complex<_Tp> &a,
1210
+ const Complex<_Tp> &b) {
1211
+ double t = 1. / ((double)b.re * b.re + (double)b.im * b.im);
1212
+ return Complex<_Tp>((_Tp)((a.re * b.re + a.im * b.im) * t),
1213
+ (_Tp)((-a.re * b.im + a.im * b.re) * t));
1214
+ }
1215
+
1216
+ template <typename _Tp>
1217
+ static inline Complex<_Tp> &operator/=(Complex<_Tp> &a, const Complex<_Tp> &b) {
1218
+ a = a / b;
1219
+ return a;
1220
+ }
1221
+
1222
+ template <typename _Tp>
1223
+ static inline Complex<_Tp> operator/(const Complex<_Tp> &a, _Tp b) {
1224
+ _Tp t = (_Tp)1 / b;
1225
+ return Complex<_Tp>(a.re * t, a.im * t);
1226
+ }
1227
+
1228
+ template <typename _Tp>
1229
+ static inline Complex<_Tp> operator/(_Tp b, const Complex<_Tp> &a) {
1230
+ return Complex<_Tp>(b) / a;
1231
+ }
1232
+
1233
+ template <typename _Tp>
1234
+ static inline Complex<_Tp> operator/=(const Complex<_Tp> &a, _Tp b) {
1235
+ _Tp t = (_Tp)1 / b;
1236
+ a.re *= t;
1237
+ a.im *= t;
1238
+ return a;
1239
+ }
1240
+
1241
+ //////////////////////////////// 2D Point ///////////////////////////////
1242
+
1243
+ template <typename _Tp> inline Point_<_Tp>::Point_() : x(0), y(0) {}
1244
+
1245
+ template <typename _Tp>
1246
+ inline Point_<_Tp>::Point_(_Tp _x, _Tp _y) : x(_x), y(_y) {}
1247
+
1248
+ #if (defined(__GNUC__) && __GNUC__ < 5) && \
1249
+ !defined(__clang__) // GCC 4.x bug. Details:
1250
+ // https://github.com/opencv/opencv/pull/20837
1251
+ template <typename _Tp>
1252
+ inline Point_<_Tp>::Point_(const Point_ &pt) : x(pt.x), y(pt.y) {}
1253
+ #endif
1254
+
1255
+ template <typename _Tp>
1256
+ inline Point_<_Tp>::Point_(const Size_<_Tp> &sz) : x(sz.width), y(sz.height) {}
1257
+
1258
+ template <typename _Tp>
1259
+ inline Point_<_Tp>::Point_(const Vec<_Tp, 2> &v) : x(v[0]), y(v[1]) {}
1260
+
1261
+ #if (defined(__GNUC__) && __GNUC__ < 5) && \
1262
+ !defined(__clang__) // GCC 4.x bug. Details:
1263
+ // https://github.com/opencv/opencv/pull/20837
1264
+ template <typename _Tp>
1265
+ inline Point_<_Tp> &Point_<_Tp>::operator=(const Point_ &pt) {
1266
+ x = pt.x;
1267
+ y = pt.y;
1268
+ return *this;
1269
+ }
1270
+ #endif
1271
+
1272
+ template <typename _Tp>
1273
+ template <typename _Tp2>
1274
+ inline Point_<_Tp>::operator Point_<_Tp2>() const {
1275
+ return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y));
1276
+ }
1277
+
1278
+ template <typename _Tp> inline Point_<_Tp>::operator Vec<_Tp, 2>() const {
1279
+ return Vec<_Tp, 2>(x, y);
1280
+ }
1281
+
1282
+ template <typename _Tp> inline _Tp Point_<_Tp>::dot(const Point_ &pt) const {
1283
+ return saturate_cast<_Tp>(x * pt.x + y * pt.y);
1284
+ }
1285
+
1286
+ template <typename _Tp>
1287
+ inline double Point_<_Tp>::ddot(const Point_ &pt) const {
1288
+ return (double)x * (double)(pt.x) + (double)y * (double)(pt.y);
1289
+ }
1290
+
1291
+ template <typename _Tp>
1292
+ inline double Point_<_Tp>::cross(const Point_ &pt) const {
1293
+ return (double)x * pt.y - (double)y * pt.x;
1294
+ }
1295
+
1296
+ template <typename _Tp>
1297
+ inline bool Point_<_Tp>::inside(const Rect_<_Tp> &r) const {
1298
+ return r.contains(*this);
1299
+ }
1300
+
1301
+ template <typename _Tp>
1302
+ static inline Point_<_Tp> &operator+=(Point_<_Tp> &a, const Point_<_Tp> &b) {
1303
+ a.x += b.x;
1304
+ a.y += b.y;
1305
+ return a;
1306
+ }
1307
+
1308
+ template <typename _Tp>
1309
+ static inline Point_<_Tp> &operator-=(Point_<_Tp> &a, const Point_<_Tp> &b) {
1310
+ a.x -= b.x;
1311
+ a.y -= b.y;
1312
+ return a;
1313
+ }
1314
+
1315
+ template <typename _Tp>
1316
+ static inline Point_<_Tp> &operator*=(Point_<_Tp> &a, int b) {
1317
+ a.x = saturate_cast<_Tp>(a.x * b);
1318
+ a.y = saturate_cast<_Tp>(a.y * b);
1319
+ return a;
1320
+ }
1321
+
1322
+ template <typename _Tp>
1323
+ static inline Point_<_Tp> &operator*=(Point_<_Tp> &a, float b) {
1324
+ a.x = saturate_cast<_Tp>(a.x * b);
1325
+ a.y = saturate_cast<_Tp>(a.y * b);
1326
+ return a;
1327
+ }
1328
+
1329
+ template <typename _Tp>
1330
+ static inline Point_<_Tp> &operator*=(Point_<_Tp> &a, double b) {
1331
+ a.x = saturate_cast<_Tp>(a.x * b);
1332
+ a.y = saturate_cast<_Tp>(a.y * b);
1333
+ return a;
1334
+ }
1335
+
1336
+ template <typename _Tp>
1337
+ static inline Point_<_Tp> &operator/=(Point_<_Tp> &a, int b) {
1338
+ a.x = saturate_cast<_Tp>(a.x / b);
1339
+ a.y = saturate_cast<_Tp>(a.y / b);
1340
+ return a;
1341
+ }
1342
+
1343
+ template <typename _Tp>
1344
+ static inline Point_<_Tp> &operator/=(Point_<_Tp> &a, float b) {
1345
+ a.x = saturate_cast<_Tp>(a.x / b);
1346
+ a.y = saturate_cast<_Tp>(a.y / b);
1347
+ return a;
1348
+ }
1349
+
1350
+ template <typename _Tp>
1351
+ static inline Point_<_Tp> &operator/=(Point_<_Tp> &a, double b) {
1352
+ a.x = saturate_cast<_Tp>(a.x / b);
1353
+ a.y = saturate_cast<_Tp>(a.y / b);
1354
+ return a;
1355
+ }
1356
+
1357
+ template <typename _Tp> static inline double norm(const Point_<_Tp> &pt) {
1358
+ return std::sqrt((double)pt.x * pt.x + (double)pt.y * pt.y);
1359
+ }
1360
+
1361
+ template <typename _Tp>
1362
+ static inline bool operator==(const Point_<_Tp> &a, const Point_<_Tp> &b) {
1363
+ return a.x == b.x && a.y == b.y;
1364
+ }
1365
+
1366
+ template <typename _Tp>
1367
+ static inline bool operator!=(const Point_<_Tp> &a, const Point_<_Tp> &b) {
1368
+ return a.x != b.x || a.y != b.y;
1369
+ }
1370
+
1371
+ template <typename _Tp>
1372
+ static inline Point_<_Tp> operator+(const Point_<_Tp> &a,
1373
+ const Point_<_Tp> &b) {
1374
+ return Point_<_Tp>(saturate_cast<_Tp>(a.x + b.x),
1375
+ saturate_cast<_Tp>(a.y + b.y));
1376
+ }
1377
+
1378
+ template <typename _Tp>
1379
+ static inline Point_<_Tp> operator-(const Point_<_Tp> &a,
1380
+ const Point_<_Tp> &b) {
1381
+ return Point_<_Tp>(saturate_cast<_Tp>(a.x - b.x),
1382
+ saturate_cast<_Tp>(a.y - b.y));
1383
+ }
1384
+
1385
+ template <typename _Tp>
1386
+ static inline Point_<_Tp> operator-(const Point_<_Tp> &a) {
1387
+ return Point_<_Tp>(saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y));
1388
+ }
1389
+
1390
+ template <typename _Tp>
1391
+ static inline Point_<_Tp> operator*(const Point_<_Tp> &a, int b) {
1392
+ return Point_<_Tp>(saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b));
1393
+ }
1394
+
1395
+ template <typename _Tp>
1396
+ static inline Point_<_Tp> operator*(int a, const Point_<_Tp> &b) {
1397
+ return Point_<_Tp>(saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a));
1398
+ }
1399
+
1400
+ template <typename _Tp>
1401
+ static inline Point_<_Tp> operator*(const Point_<_Tp> &a, float b) {
1402
+ return Point_<_Tp>(saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b));
1403
+ }
1404
+
1405
+ template <typename _Tp>
1406
+ static inline Point_<_Tp> operator*(float a, const Point_<_Tp> &b) {
1407
+ return Point_<_Tp>(saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a));
1408
+ }
1409
+
1410
+ template <typename _Tp>
1411
+ static inline Point_<_Tp> operator*(const Point_<_Tp> &a, double b) {
1412
+ return Point_<_Tp>(saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b));
1413
+ }
1414
+
1415
+ template <typename _Tp>
1416
+ static inline Point_<_Tp> operator*(double a, const Point_<_Tp> &b) {
1417
+ return Point_<_Tp>(saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a));
1418
+ }
1419
+
1420
+ template <typename _Tp>
1421
+ static inline Point_<_Tp> operator*(const Matx<_Tp, 2, 2> &a,
1422
+ const Point_<_Tp> &b) {
1423
+ Matx<_Tp, 2, 1> tmp = a * Vec<_Tp, 2>(b.x, b.y);
1424
+ return Point_<_Tp>(tmp.val[0], tmp.val[1]);
1425
+ }
1426
+
1427
+ template <typename _Tp>
1428
+ static inline Point3_<_Tp> operator*(const Matx<_Tp, 3, 3> &a,
1429
+ const Point_<_Tp> &b) {
1430
+ Matx<_Tp, 3, 1> tmp = a * Vec<_Tp, 3>(b.x, b.y, 1);
1431
+ return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
1432
+ }
1433
+
1434
+ template <typename _Tp>
1435
+ static inline Point_<_Tp> operator/(const Point_<_Tp> &a, int b) {
1436
+ Point_<_Tp> tmp(a);
1437
+ tmp /= b;
1438
+ return tmp;
1439
+ }
1440
+
1441
+ template <typename _Tp>
1442
+ static inline Point_<_Tp> operator/(const Point_<_Tp> &a, float b) {
1443
+ Point_<_Tp> tmp(a);
1444
+ tmp /= b;
1445
+ return tmp;
1446
+ }
1447
+
1448
+ template <typename _Tp>
1449
+ static inline Point_<_Tp> operator/(const Point_<_Tp> &a, double b) {
1450
+ Point_<_Tp> tmp(a);
1451
+ tmp /= b;
1452
+ return tmp;
1453
+ }
1454
+
1455
+ template <typename _AccTp>
1456
+ static inline _AccTp normL2Sqr(const Point_<int> &pt);
1457
+ template <typename _AccTp>
1458
+ static inline _AccTp normL2Sqr(const Point_<int64> &pt);
1459
+ template <typename _AccTp>
1460
+ static inline _AccTp normL2Sqr(const Point_<float> &pt);
1461
+ template <typename _AccTp>
1462
+ static inline _AccTp normL2Sqr(const Point_<double> &pt);
1463
+
1464
+ template <> inline int normL2Sqr<int>(const Point_<int> &pt) {
1465
+ return pt.dot(pt);
1466
+ }
1467
+ template <> inline int64 normL2Sqr<int64>(const Point_<int64> &pt) {
1468
+ return pt.dot(pt);
1469
+ }
1470
+ template <> inline float normL2Sqr<float>(const Point_<float> &pt) {
1471
+ return pt.dot(pt);
1472
+ }
1473
+ template <> inline double normL2Sqr<double>(const Point_<int> &pt) {
1474
+ return pt.dot(pt);
1475
+ }
1476
+
1477
+ template <> inline double normL2Sqr<double>(const Point_<float> &pt) {
1478
+ return pt.ddot(pt);
1479
+ }
1480
+ template <> inline double normL2Sqr<double>(const Point_<double> &pt) {
1481
+ return pt.ddot(pt);
1482
+ }
1483
+
1484
+ //////////////////////////////// 3D Point ///////////////////////////////
1485
+
1486
+ template <typename _Tp> inline Point3_<_Tp>::Point3_() : x(0), y(0), z(0) {}
1487
+
1488
+ template <typename _Tp>
1489
+ inline Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) : x(_x), y(_y), z(_z) {}
1490
+
1491
+ template <typename _Tp>
1492
+ inline Point3_<_Tp>::Point3_(const Point_<_Tp> &pt)
1493
+ : x(pt.x), y(pt.y), z(_Tp()) {}
1494
+
1495
+ template <typename _Tp>
1496
+ inline Point3_<_Tp>::Point3_(const Vec<_Tp, 3> &v)
1497
+ : x(v[0]), y(v[1]), z(v[2]) {}
1498
+
1499
+ template <typename _Tp>
1500
+ template <typename _Tp2>
1501
+ inline Point3_<_Tp>::operator Point3_<_Tp2>() const {
1502
+ return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y),
1503
+ saturate_cast<_Tp2>(z));
1504
+ }
1505
+
1506
+ template <typename _Tp> inline Point3_<_Tp>::operator Vec<_Tp, 3>() const {
1507
+ return Vec<_Tp, 3>(x, y, z);
1508
+ }
1509
+
1510
+ template <typename _Tp> inline _Tp Point3_<_Tp>::dot(const Point3_ &pt) const {
1511
+ return saturate_cast<_Tp>(x * pt.x + y * pt.y + z * pt.z);
1512
+ }
1513
+
1514
+ template <typename _Tp>
1515
+ inline double Point3_<_Tp>::ddot(const Point3_ &pt) const {
1516
+ return (double)x * pt.x + (double)y * pt.y + (double)z * pt.z;
1517
+ }
1518
+
1519
+ template <typename _Tp>
1520
+ inline Point3_<_Tp> Point3_<_Tp>::cross(const Point3_<_Tp> &pt) const {
1521
+ return Point3_<_Tp>(y * pt.z - z * pt.y, z * pt.x - x * pt.z,
1522
+ x * pt.y - y * pt.x);
1523
+ }
1524
+
1525
+ template <typename _Tp>
1526
+ static inline Point3_<_Tp> &operator+=(Point3_<_Tp> &a, const Point3_<_Tp> &b) {
1527
+ a.x += b.x;
1528
+ a.y += b.y;
1529
+ a.z += b.z;
1530
+ return a;
1531
+ }
1532
+
1533
+ template <typename _Tp>
1534
+ static inline Point3_<_Tp> &operator-=(Point3_<_Tp> &a, const Point3_<_Tp> &b) {
1535
+ a.x -= b.x;
1536
+ a.y -= b.y;
1537
+ a.z -= b.z;
1538
+ return a;
1539
+ }
1540
+
1541
+ template <typename _Tp>
1542
+ static inline Point3_<_Tp> &operator*=(Point3_<_Tp> &a, int b) {
1543
+ a.x = saturate_cast<_Tp>(a.x * b);
1544
+ a.y = saturate_cast<_Tp>(a.y * b);
1545
+ a.z = saturate_cast<_Tp>(a.z * b);
1546
+ return a;
1547
+ }
1548
+
1549
+ template <typename _Tp>
1550
+ static inline Point3_<_Tp> &operator*=(Point3_<_Tp> &a, float b) {
1551
+ a.x = saturate_cast<_Tp>(a.x * b);
1552
+ a.y = saturate_cast<_Tp>(a.y * b);
1553
+ a.z = saturate_cast<_Tp>(a.z * b);
1554
+ return a;
1555
+ }
1556
+
1557
+ template <typename _Tp>
1558
+ static inline Point3_<_Tp> &operator*=(Point3_<_Tp> &a, double b) {
1559
+ a.x = saturate_cast<_Tp>(a.x * b);
1560
+ a.y = saturate_cast<_Tp>(a.y * b);
1561
+ a.z = saturate_cast<_Tp>(a.z * b);
1562
+ return a;
1563
+ }
1564
+
1565
+ template <typename _Tp>
1566
+ static inline Point3_<_Tp> &operator/=(Point3_<_Tp> &a, int b) {
1567
+ a.x = saturate_cast<_Tp>(a.x / b);
1568
+ a.y = saturate_cast<_Tp>(a.y / b);
1569
+ a.z = saturate_cast<_Tp>(a.z / b);
1570
+ return a;
1571
+ }
1572
+
1573
+ template <typename _Tp>
1574
+ static inline Point3_<_Tp> &operator/=(Point3_<_Tp> &a, float b) {
1575
+ a.x = saturate_cast<_Tp>(a.x / b);
1576
+ a.y = saturate_cast<_Tp>(a.y / b);
1577
+ a.z = saturate_cast<_Tp>(a.z / b);
1578
+ return a;
1579
+ }
1580
+
1581
+ template <typename _Tp>
1582
+ static inline Point3_<_Tp> &operator/=(Point3_<_Tp> &a, double b) {
1583
+ a.x = saturate_cast<_Tp>(a.x / b);
1584
+ a.y = saturate_cast<_Tp>(a.y / b);
1585
+ a.z = saturate_cast<_Tp>(a.z / b);
1586
+ return a;
1587
+ }
1588
+
1589
+ template <typename _Tp> static inline double norm(const Point3_<_Tp> &pt) {
1590
+ return std::sqrt((double)pt.x * pt.x + (double)pt.y * pt.y +
1591
+ (double)pt.z * pt.z);
1592
+ }
1593
+
1594
+ template <typename _Tp>
1595
+ static inline bool operator==(const Point3_<_Tp> &a, const Point3_<_Tp> &b) {
1596
+ return a.x == b.x && a.y == b.y && a.z == b.z;
1597
+ }
1598
+
1599
+ template <typename _Tp>
1600
+ static inline bool operator!=(const Point3_<_Tp> &a, const Point3_<_Tp> &b) {
1601
+ return a.x != b.x || a.y != b.y || a.z != b.z;
1602
+ }
1603
+
1604
+ template <typename _Tp>
1605
+ static inline Point3_<_Tp> operator+(const Point3_<_Tp> &a,
1606
+ const Point3_<_Tp> &b) {
1607
+ return Point3_<_Tp>(saturate_cast<_Tp>(a.x + b.x),
1608
+ saturate_cast<_Tp>(a.y + b.y),
1609
+ saturate_cast<_Tp>(a.z + b.z));
1610
+ }
1611
+
1612
+ template <typename _Tp>
1613
+ static inline Point3_<_Tp> operator-(const Point3_<_Tp> &a,
1614
+ const Point3_<_Tp> &b) {
1615
+ return Point3_<_Tp>(saturate_cast<_Tp>(a.x - b.x),
1616
+ saturate_cast<_Tp>(a.y - b.y),
1617
+ saturate_cast<_Tp>(a.z - b.z));
1618
+ }
1619
+
1620
+ template <typename _Tp>
1621
+ static inline Point3_<_Tp> operator-(const Point3_<_Tp> &a) {
1622
+ return Point3_<_Tp>(saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y),
1623
+ saturate_cast<_Tp>(-a.z));
1624
+ }
1625
+
1626
+ template <typename _Tp>
1627
+ static inline Point3_<_Tp> operator*(const Point3_<_Tp> &a, int b) {
1628
+ return Point3_<_Tp>(saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b),
1629
+ saturate_cast<_Tp>(a.z * b));
1630
+ }
1631
+
1632
+ template <typename _Tp>
1633
+ static inline Point3_<_Tp> operator*(int a, const Point3_<_Tp> &b) {
1634
+ return Point3_<_Tp>(saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a),
1635
+ saturate_cast<_Tp>(b.z * a));
1636
+ }
1637
+
1638
+ template <typename _Tp>
1639
+ static inline Point3_<_Tp> operator*(const Point3_<_Tp> &a, float b) {
1640
+ return Point3_<_Tp>(saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b),
1641
+ saturate_cast<_Tp>(a.z * b));
1642
+ }
1643
+
1644
+ template <typename _Tp>
1645
+ static inline Point3_<_Tp> operator*(float a, const Point3_<_Tp> &b) {
1646
+ return Point3_<_Tp>(saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a),
1647
+ saturate_cast<_Tp>(b.z * a));
1648
+ }
1649
+
1650
+ template <typename _Tp>
1651
+ static inline Point3_<_Tp> operator*(const Point3_<_Tp> &a, double b) {
1652
+ return Point3_<_Tp>(saturate_cast<_Tp>(a.x * b), saturate_cast<_Tp>(a.y * b),
1653
+ saturate_cast<_Tp>(a.z * b));
1654
+ }
1655
+
1656
+ template <typename _Tp>
1657
+ static inline Point3_<_Tp> operator*(double a, const Point3_<_Tp> &b) {
1658
+ return Point3_<_Tp>(saturate_cast<_Tp>(b.x * a), saturate_cast<_Tp>(b.y * a),
1659
+ saturate_cast<_Tp>(b.z * a));
1660
+ }
1661
+
1662
+ template <typename _Tp>
1663
+ static inline Point3_<_Tp> operator*(const Matx<_Tp, 3, 3> &a,
1664
+ const Point3_<_Tp> &b) {
1665
+ Matx<_Tp, 3, 1> tmp = a * Vec<_Tp, 3>(b.x, b.y, b.z);
1666
+ return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
1667
+ }
1668
+
1669
+ template <typename _Tp>
1670
+ static inline Matx<_Tp, 4, 1> operator*(const Matx<_Tp, 4, 4> &a,
1671
+ const Point3_<_Tp> &b) {
1672
+ return a * Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1);
1673
+ }
1674
+
1675
+ template <typename _Tp>
1676
+ static inline Point3_<_Tp> operator/(const Point3_<_Tp> &a, int b) {
1677
+ Point3_<_Tp> tmp(a);
1678
+ tmp /= b;
1679
+ return tmp;
1680
+ }
1681
+
1682
+ template <typename _Tp>
1683
+ static inline Point3_<_Tp> operator/(const Point3_<_Tp> &a, float b) {
1684
+ Point3_<_Tp> tmp(a);
1685
+ tmp /= b;
1686
+ return tmp;
1687
+ }
1688
+
1689
+ template <typename _Tp>
1690
+ static inline Point3_<_Tp> operator/(const Point3_<_Tp> &a, double b) {
1691
+ Point3_<_Tp> tmp(a);
1692
+ tmp /= b;
1693
+ return tmp;
1694
+ }
1695
+
1696
+ ////////////////////////////////// Size /////////////////////////////////
1697
+
1698
+ template <typename _Tp> inline Size_<_Tp>::Size_() : width(0), height(0) {}
1699
+
1700
+ template <typename _Tp>
1701
+ inline Size_<_Tp>::Size_(_Tp _width, _Tp _height)
1702
+ : width(_width), height(_height) {}
1703
+
1704
+ template <typename _Tp>
1705
+ inline Size_<_Tp>::Size_(const Point_<_Tp> &pt) : width(pt.x), height(pt.y) {}
1706
+
1707
+ template <typename _Tp>
1708
+ template <typename _Tp2>
1709
+ inline Size_<_Tp>::operator Size_<_Tp2>() const {
1710
+ return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
1711
+ }
1712
+
1713
+ template <typename _Tp> inline _Tp Size_<_Tp>::area() const {
1714
+ const _Tp result = width * height;
1715
+ CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer || width == 0 ||
1716
+ result / width ==
1717
+ height); // make sure the result fits in the return value
1718
+ return result;
1719
+ }
1720
+
1721
+ template <typename _Tp> inline double Size_<_Tp>::aspectRatio() const {
1722
+ return width / static_cast<double>(height);
1723
+ }
1724
+
1725
+ template <typename _Tp> inline bool Size_<_Tp>::empty() const {
1726
+ return width <= 0 || height <= 0;
1727
+ }
1728
+
1729
+ template <typename _Tp>
1730
+ static inline Size_<_Tp> &operator*=(Size_<_Tp> &a, _Tp b) {
1731
+ a.width *= b;
1732
+ a.height *= b;
1733
+ return a;
1734
+ }
1735
+
1736
+ template <typename _Tp>
1737
+ static inline Size_<_Tp> operator*(const Size_<_Tp> &a, _Tp b) {
1738
+ Size_<_Tp> tmp(a);
1739
+ tmp *= b;
1740
+ return tmp;
1741
+ }
1742
+
1743
+ template <typename _Tp>
1744
+ static inline Size_<_Tp> &operator/=(Size_<_Tp> &a, _Tp b) {
1745
+ a.width /= b;
1746
+ a.height /= b;
1747
+ return a;
1748
+ }
1749
+
1750
+ template <typename _Tp>
1751
+ static inline Size_<_Tp> operator/(const Size_<_Tp> &a, _Tp b) {
1752
+ Size_<_Tp> tmp(a);
1753
+ tmp /= b;
1754
+ return tmp;
1755
+ }
1756
+
1757
+ template <typename _Tp>
1758
+ static inline Size_<_Tp> &operator+=(Size_<_Tp> &a, const Size_<_Tp> &b) {
1759
+ a.width += b.width;
1760
+ a.height += b.height;
1761
+ return a;
1762
+ }
1763
+
1764
+ template <typename _Tp>
1765
+ static inline Size_<_Tp> operator+(const Size_<_Tp> &a, const Size_<_Tp> &b) {
1766
+ Size_<_Tp> tmp(a);
1767
+ tmp += b;
1768
+ return tmp;
1769
+ }
1770
+
1771
+ template <typename _Tp>
1772
+ static inline Size_<_Tp> &operator-=(Size_<_Tp> &a, const Size_<_Tp> &b) {
1773
+ a.width -= b.width;
1774
+ a.height -= b.height;
1775
+ return a;
1776
+ }
1777
+
1778
+ template <typename _Tp>
1779
+ static inline Size_<_Tp> operator-(const Size_<_Tp> &a, const Size_<_Tp> &b) {
1780
+ Size_<_Tp> tmp(a);
1781
+ tmp -= b;
1782
+ return tmp;
1783
+ }
1784
+
1785
+ template <typename _Tp>
1786
+ static inline bool operator==(const Size_<_Tp> &a, const Size_<_Tp> &b) {
1787
+ return a.width == b.width && a.height == b.height;
1788
+ }
1789
+
1790
+ template <typename _Tp>
1791
+ static inline bool operator!=(const Size_<_Tp> &a, const Size_<_Tp> &b) {
1792
+ return !(a == b);
1793
+ }
1794
+
1795
+ ////////////////////////////////// Rect /////////////////////////////////
1796
+
1797
+ template <typename _Tp>
1798
+ inline Rect_<_Tp>::Rect_() : x(0), y(0), width(0), height(0) {}
1799
+
1800
+ template <typename _Tp>
1801
+ inline Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height)
1802
+ : x(_x), y(_y), width(_width), height(_height) {}
1803
+
1804
+ template <typename _Tp>
1805
+ inline Rect_<_Tp>::Rect_(const Point_<_Tp> &org, const Size_<_Tp> &sz)
1806
+ : x(org.x), y(org.y), width(sz.width), height(sz.height) {}
1807
+
1808
+ template <typename _Tp>
1809
+ inline Rect_<_Tp>::Rect_(const Point_<_Tp> &pt1, const Point_<_Tp> &pt2) {
1810
+ x = std::min(pt1.x, pt2.x);
1811
+ y = std::min(pt1.y, pt2.y);
1812
+ width = std::max(pt1.x, pt2.x) - x;
1813
+ height = std::max(pt1.y, pt2.y) - y;
1814
+ }
1815
+
1816
+ template <typename _Tp> inline Point_<_Tp> Rect_<_Tp>::tl() const {
1817
+ return Point_<_Tp>(x, y);
1818
+ }
1819
+
1820
+ template <typename _Tp> inline Point_<_Tp> Rect_<_Tp>::br() const {
1821
+ return Point_<_Tp>(x + width, y + height);
1822
+ }
1823
+
1824
+ template <typename _Tp> inline Size_<_Tp> Rect_<_Tp>::size() const {
1825
+ return Size_<_Tp>(width, height);
1826
+ }
1827
+
1828
+ template <typename _Tp> inline _Tp Rect_<_Tp>::area() const {
1829
+ const _Tp result = width * height;
1830
+ CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer || width == 0 ||
1831
+ result / width ==
1832
+ height); // make sure the result fits in the return value
1833
+ return result;
1834
+ }
1835
+
1836
+ template <typename _Tp> inline bool Rect_<_Tp>::empty() const {
1837
+ return width <= 0 || height <= 0;
1838
+ }
1839
+
1840
+ template <typename _Tp>
1841
+ template <typename _Tp2>
1842
+ inline Rect_<_Tp>::operator Rect_<_Tp2>() const {
1843
+ return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y),
1844
+ saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height));
1845
+ }
1846
+
1847
+ template <typename _Tp>
1848
+ template <typename _Tp2>
1849
+ inline bool Rect_<_Tp>::contains(const Point_<_Tp2> &pt) const {
1850
+ return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height;
1851
+ }
1852
+ // See https://github.com/opencv/opencv/issues/26016
1853
+ template <>
1854
+ template <>
1855
+ inline bool Rect_<int>::contains(const Point_<double> &pt) const {
1856
+ // std::numeric_limits<int>::digits is 31.
1857
+ // std::numeric_limits<double>::digits is 53.
1858
+ // So conversion int->double does not lead to accuracy errors.
1859
+ const Rect_<double> _rect(static_cast<double>(x), static_cast<double>(y),
1860
+ static_cast<double>(width),
1861
+ static_cast<double>(height));
1862
+ return _rect.contains(pt);
1863
+ }
1864
+ template <>
1865
+ template <>
1866
+ inline bool Rect_<int>::contains(const Point_<float> &_pt) const {
1867
+ // std::numeric_limits<float>::digits is 24.
1868
+ // std::numeric_limits<double>::digits is 53.
1869
+ // So conversion float->double does not lead to accuracy errors.
1870
+ return contains(
1871
+ Point_<double>(static_cast<double>(_pt.x), static_cast<double>(_pt.y)));
1872
+ }
1873
+
1874
+ template <typename _Tp>
1875
+ static inline Rect_<_Tp> &operator+=(Rect_<_Tp> &a, const Point_<_Tp> &b) {
1876
+ a.x += b.x;
1877
+ a.y += b.y;
1878
+ return a;
1879
+ }
1880
+
1881
+ template <typename _Tp>
1882
+ static inline Rect_<_Tp> &operator-=(Rect_<_Tp> &a, const Point_<_Tp> &b) {
1883
+ a.x -= b.x;
1884
+ a.y -= b.y;
1885
+ return a;
1886
+ }
1887
+
1888
+ template <typename _Tp>
1889
+ static inline Rect_<_Tp> &operator+=(Rect_<_Tp> &a, const Size_<_Tp> &b) {
1890
+ a.width += b.width;
1891
+ a.height += b.height;
1892
+ return a;
1893
+ }
1894
+
1895
+ template <typename _Tp>
1896
+ static inline Rect_<_Tp> &operator-=(Rect_<_Tp> &a, const Size_<_Tp> &b) {
1897
+ const _Tp width = a.width - b.width;
1898
+ const _Tp height = a.height - b.height;
1899
+ CV_DbgAssert(width >= 0 && height >= 0);
1900
+ a.width = width;
1901
+ a.height = height;
1902
+ return a;
1903
+ }
1904
+
1905
+ template <typename _Tp>
1906
+ static inline Rect_<_Tp> &operator&=(Rect_<_Tp> &a, const Rect_<_Tp> &b) {
1907
+ if (a.empty() || b.empty()) {
1908
+ a = Rect();
1909
+ return a;
1910
+ }
1911
+ const Rect_<_Tp> &Rx_min = (a.x < b.x) ? a : b;
1912
+ const Rect_<_Tp> &Rx_max = (a.x < b.x) ? b : a;
1913
+ const Rect_<_Tp> &Ry_min = (a.y < b.y) ? a : b;
1914
+ const Rect_<_Tp> &Ry_max = (a.y < b.y) ? b : a;
1915
+ // Looking at the formula below, we will compute Rx_min.width - (Rx_max.x -
1916
+ // Rx_min.x) but we want to avoid overflows. Rx_min.width >= 0 and (Rx_max.x -
1917
+ // Rx_min.x) >= 0 by definition so the difference does not overflow. The only
1918
+ // thing that can overflow is (Rx_max.x - Rx_min.x). And it can only overflow
1919
+ // if Rx_min.x < 0. Let us first deal with the following case.
1920
+ if ((Rx_min.x < 0 && Rx_min.x + Rx_min.width < Rx_max.x) ||
1921
+ (Ry_min.y < 0 && Ry_min.y + Ry_min.height < Ry_max.y)) {
1922
+ a = Rect();
1923
+ return a;
1924
+ }
1925
+ // We now know that either Rx_min.x >= 0, or
1926
+ // Rx_min.x < 0 && Rx_min.x + Rx_min.width >= Rx_max.x and therefore
1927
+ // Rx_min.width >= (Rx_max.x - Rx_min.x) which means (Rx_max.x - Rx_min.x)
1928
+ // is inferior to a valid int and therefore does not overflow.
1929
+ a.width = std::min(Rx_min.width - (Rx_max.x - Rx_min.x), Rx_max.width);
1930
+ a.height = std::min(Ry_min.height - (Ry_max.y - Ry_min.y), Ry_max.height);
1931
+ a.x = Rx_max.x;
1932
+ a.y = Ry_max.y;
1933
+ if (a.empty())
1934
+ a = Rect();
1935
+ return a;
1936
+ }
1937
+
1938
+ template <typename _Tp>
1939
+ static inline Rect_<_Tp> &operator|=(Rect_<_Tp> &a, const Rect_<_Tp> &b) {
1940
+ if (a.empty()) {
1941
+ a = b;
1942
+ } else if (!b.empty()) {
1943
+ _Tp x1 = std::min(a.x, b.x);
1944
+ _Tp y1 = std::min(a.y, b.y);
1945
+ a.width = std::max(a.x + a.width, b.x + b.width) - x1;
1946
+ a.height = std::max(a.y + a.height, b.y + b.height) - y1;
1947
+ a.x = x1;
1948
+ a.y = y1;
1949
+ }
1950
+ return a;
1951
+ }
1952
+
1953
+ template <typename _Tp>
1954
+ static inline bool operator==(const Rect_<_Tp> &a, const Rect_<_Tp> &b) {
1955
+ return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
1956
+ }
1957
+
1958
+ template <typename _Tp>
1959
+ static inline bool operator!=(const Rect_<_Tp> &a, const Rect_<_Tp> &b) {
1960
+ return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height;
1961
+ }
1962
+
1963
+ template <typename _Tp>
1964
+ static inline Rect_<_Tp> operator+(const Rect_<_Tp> &a, const Point_<_Tp> &b) {
1965
+ return Rect_<_Tp>(a.x + b.x, a.y + b.y, a.width, a.height);
1966
+ }
1967
+
1968
+ template <typename _Tp>
1969
+ static inline Rect_<_Tp> operator-(const Rect_<_Tp> &a, const Point_<_Tp> &b) {
1970
+ return Rect_<_Tp>(a.x - b.x, a.y - b.y, a.width, a.height);
1971
+ }
1972
+
1973
+ template <typename _Tp>
1974
+ static inline Rect_<_Tp> operator+(const Rect_<_Tp> &a, const Size_<_Tp> &b) {
1975
+ return Rect_<_Tp>(a.x, a.y, a.width + b.width, a.height + b.height);
1976
+ }
1977
+
1978
+ template <typename _Tp>
1979
+ static inline Rect_<_Tp> operator-(const Rect_<_Tp> &a, const Size_<_Tp> &b) {
1980
+ const _Tp width = a.width - b.width;
1981
+ const _Tp height = a.height - b.height;
1982
+ CV_DbgAssert(width >= 0 && height >= 0);
1983
+ return Rect_<_Tp>(a.x, a.y, width, height);
1984
+ }
1985
+
1986
+ template <typename _Tp>
1987
+ static inline Rect_<_Tp> operator&(const Rect_<_Tp> &a, const Rect_<_Tp> &b) {
1988
+ Rect_<_Tp> c = a;
1989
+ return c &= b;
1990
+ }
1991
+
1992
+ template <typename _Tp>
1993
+ static inline Rect_<_Tp> operator|(const Rect_<_Tp> &a, const Rect_<_Tp> &b) {
1994
+ Rect_<_Tp> c = a;
1995
+ return c |= b;
1996
+ }
1997
+
1998
+ /**
1999
+ * @brief measure dissimilarity between two sample sets
2000
+ *
2001
+ * computes the complement of the Jaccard Index as described in
2002
+ * <https://en.wikipedia.org/wiki/Jaccard_index>. For rectangles this reduces to
2003
+ * computing the intersection over the union.
2004
+ */
2005
+ template <typename _Tp>
2006
+ static inline double jaccardDistance(const Rect_<_Tp> &a, const Rect_<_Tp> &b) {
2007
+ _Tp Aa = a.area();
2008
+ _Tp Ab = b.area();
2009
+
2010
+ if ((Aa + Ab) <= std::numeric_limits<_Tp>::epsilon()) {
2011
+ // jaccard_index = 1 -> distance = 0
2012
+ return 0.0;
2013
+ }
2014
+
2015
+ double Aab = (a & b).area();
2016
+ // distance = 1 - jaccard_index
2017
+ return 1.0 - Aab / (Aa + Ab - Aab);
2018
+ }
2019
+
2020
+ /** @brief Finds out if there is any intersection between two rectangles
2021
+ *
2022
+ * mainly useful for language bindings
2023
+ * @param a First rectangle
2024
+ * @param b Second rectangle
2025
+ * @return the area of the intersection
2026
+ */
2027
+ CV_EXPORTS_W inline double rectangleIntersectionArea(const Rect2d &a,
2028
+ const Rect2d &b) {
2029
+ return (a & b).area();
2030
+ }
2031
+
2032
+ ////////////////////////////// RotatedRect //////////////////////////////
2033
+
2034
+ inline RotatedRect::RotatedRect() : center(), size(), angle(0) {}
2035
+
2036
+ inline RotatedRect::RotatedRect(const Point2f &_center, const Size2f &_size,
2037
+ float _angle)
2038
+ : center(_center), size(_size), angle(_angle) {}
2039
+
2040
+ ///////////////////////////////// Range /////////////////////////////////
2041
+
2042
+ inline Range::Range() : start(0), end(0) {}
2043
+
2044
+ inline Range::Range(int _start, int _end) : start(_start), end(_end) {}
2045
+
2046
+ inline int Range::size() const { return end - start; }
2047
+
2048
+ inline bool Range::empty() const { return start == end; }
2049
+
2050
+ inline Range Range::all() { return Range(INT_MIN, INT_MAX); }
2051
+
2052
+ static inline bool operator==(const Range &r1, const Range &r2) {
2053
+ return r1.start == r2.start && r1.end == r2.end;
2054
+ }
2055
+
2056
+ static inline bool operator!=(const Range &r1, const Range &r2) {
2057
+ return !(r1 == r2);
2058
+ }
2059
+
2060
+ static inline bool operator!(const Range &r) { return r.start == r.end; }
2061
+
2062
+ static inline Range operator&(const Range &r1, const Range &r2) {
2063
+ Range r(std::max(r1.start, r2.start), std::min(r1.end, r2.end));
2064
+ r.end = std::max(r.end, r.start);
2065
+ return r;
2066
+ }
2067
+
2068
+ static inline Range &operator&=(Range &r1, const Range &r2) {
2069
+ r1 = r1 & r2;
2070
+ return r1;
2071
+ }
2072
+
2073
+ static inline Range operator+(const Range &r1, int delta) {
2074
+ return Range(r1.start + delta, r1.end + delta);
2075
+ }
2076
+
2077
+ static inline Range operator+(int delta, const Range &r1) {
2078
+ return Range(r1.start + delta, r1.end + delta);
2079
+ }
2080
+
2081
+ static inline Range operator-(const Range &r1, int delta) {
2082
+ return r1 + (-delta);
2083
+ }
2084
+
2085
+ ///////////////////////////////// Scalar ////////////////////////////////
2086
+
2087
+ template <typename _Tp> inline Scalar_<_Tp>::Scalar_() {
2088
+ this->val[0] = this->val[1] = this->val[2] = this->val[3] = 0;
2089
+ }
2090
+
2091
+ template <typename _Tp>
2092
+ inline Scalar_<_Tp>::Scalar_(_Tp v0, _Tp v1, _Tp v2, _Tp v3) {
2093
+ this->val[0] = v0;
2094
+ this->val[1] = v1;
2095
+ this->val[2] = v2;
2096
+ this->val[3] = v3;
2097
+ }
2098
+
2099
+ template <typename _Tp>
2100
+ inline Scalar_<_Tp>::Scalar_(const Scalar_<_Tp> &s) : Vec<_Tp, 4>(s) {}
2101
+
2102
+ template <typename _Tp>
2103
+ inline Scalar_<_Tp>::Scalar_(Scalar_<_Tp> &&s) CV_NOEXCEPT {
2104
+ this->val[0] = std::move(s.val[0]);
2105
+ this->val[1] = std::move(s.val[1]);
2106
+ this->val[2] = std::move(s.val[2]);
2107
+ this->val[3] = std::move(s.val[3]);
2108
+ }
2109
+
2110
+ template <typename _Tp>
2111
+ inline Scalar_<_Tp> &Scalar_<_Tp>::operator=(const Scalar_<_Tp> &s) {
2112
+ this->val[0] = s.val[0];
2113
+ this->val[1] = s.val[1];
2114
+ this->val[2] = s.val[2];
2115
+ this->val[3] = s.val[3];
2116
+ return *this;
2117
+ }
2118
+
2119
+ template <typename _Tp>
2120
+ inline Scalar_<_Tp> &Scalar_<_Tp>::operator=(Scalar_<_Tp> &&s) CV_NOEXCEPT {
2121
+ this->val[0] = std::move(s.val[0]);
2122
+ this->val[1] = std::move(s.val[1]);
2123
+ this->val[2] = std::move(s.val[2]);
2124
+ this->val[3] = std::move(s.val[3]);
2125
+ return *this;
2126
+ }
2127
+
2128
+ template <typename _Tp>
2129
+ template <typename _Tp2, int cn>
2130
+ inline Scalar_<_Tp>::Scalar_(const Vec<_Tp2, cn> &v) {
2131
+ int i;
2132
+ for (i = 0; i < (cn < 4 ? cn : 4); i++)
2133
+ this->val[i] = cv::saturate_cast<_Tp>(v.val[i]);
2134
+ for (; i < 4; i++)
2135
+ this->val[i] = 0;
2136
+ }
2137
+
2138
+ template <typename _Tp> inline Scalar_<_Tp>::Scalar_(_Tp v0) {
2139
+ this->val[0] = v0;
2140
+ this->val[1] = this->val[2] = this->val[3] = 0;
2141
+ }
2142
+
2143
+ template <typename _Tp> inline Scalar_<_Tp> Scalar_<_Tp>::all(_Tp v0) {
2144
+ return Scalar_<_Tp>(v0, v0, v0, v0);
2145
+ }
2146
+
2147
+ template <typename _Tp>
2148
+ inline Scalar_<_Tp> Scalar_<_Tp>::mul(const Scalar_<_Tp> &a,
2149
+ double scale) const {
2150
+ return Scalar_<_Tp>(saturate_cast<_Tp>(this->val[0] * a.val[0] * scale),
2151
+ saturate_cast<_Tp>(this->val[1] * a.val[1] * scale),
2152
+ saturate_cast<_Tp>(this->val[2] * a.val[2] * scale),
2153
+ saturate_cast<_Tp>(this->val[3] * a.val[3] * scale));
2154
+ }
2155
+
2156
+ template <typename _Tp> inline Scalar_<_Tp> Scalar_<_Tp>::conj() const {
2157
+ return Scalar_<_Tp>(
2158
+ saturate_cast<_Tp>(this->val[0]), saturate_cast<_Tp>(-this->val[1]),
2159
+ saturate_cast<_Tp>(-this->val[2]), saturate_cast<_Tp>(-this->val[3]));
2160
+ }
2161
+
2162
+ template <typename _Tp> inline bool Scalar_<_Tp>::isReal() const {
2163
+ return this->val[1] == 0 && this->val[2] == 0 && this->val[3] == 0;
2164
+ }
2165
+
2166
+ template <typename _Tp>
2167
+ template <typename T2>
2168
+ inline Scalar_<_Tp>::operator Scalar_<T2>() const {
2169
+ return Scalar_<T2>(
2170
+ saturate_cast<T2>(this->val[0]), saturate_cast<T2>(this->val[1]),
2171
+ saturate_cast<T2>(this->val[2]), saturate_cast<T2>(this->val[3]));
2172
+ }
2173
+
2174
+ template <typename _Tp>
2175
+ static inline Scalar_<_Tp> &operator+=(Scalar_<_Tp> &a, const Scalar_<_Tp> &b) {
2176
+ a.val[0] += b.val[0];
2177
+ a.val[1] += b.val[1];
2178
+ a.val[2] += b.val[2];
2179
+ a.val[3] += b.val[3];
2180
+ return a;
2181
+ }
2182
+
2183
+ template <typename _Tp>
2184
+ static inline Scalar_<_Tp> &operator-=(Scalar_<_Tp> &a, const Scalar_<_Tp> &b) {
2185
+ a.val[0] -= b.val[0];
2186
+ a.val[1] -= b.val[1];
2187
+ a.val[2] -= b.val[2];
2188
+ a.val[3] -= b.val[3];
2189
+ return a;
2190
+ }
2191
+
2192
+ template <typename _Tp>
2193
+ static inline Scalar_<_Tp> &operator*=(Scalar_<_Tp> &a, _Tp v) {
2194
+ a.val[0] *= v;
2195
+ a.val[1] *= v;
2196
+ a.val[2] *= v;
2197
+ a.val[3] *= v;
2198
+ return a;
2199
+ }
2200
+
2201
+ template <typename _Tp>
2202
+ static inline bool operator==(const Scalar_<_Tp> &a, const Scalar_<_Tp> &b) {
2203
+ return a.val[0] == b.val[0] && a.val[1] == b.val[1] && a.val[2] == b.val[2] &&
2204
+ a.val[3] == b.val[3];
2205
+ }
2206
+
2207
+ template <typename _Tp>
2208
+ static inline bool operator!=(const Scalar_<_Tp> &a, const Scalar_<_Tp> &b) {
2209
+ return a.val[0] != b.val[0] || a.val[1] != b.val[1] || a.val[2] != b.val[2] ||
2210
+ a.val[3] != b.val[3];
2211
+ }
2212
+
2213
+ template <typename _Tp>
2214
+ static inline Scalar_<_Tp> operator+(const Scalar_<_Tp> &a,
2215
+ const Scalar_<_Tp> &b) {
2216
+ return Scalar_<_Tp>(a.val[0] + b.val[0], a.val[1] + b.val[1],
2217
+ a.val[2] + b.val[2], a.val[3] + b.val[3]);
2218
+ }
2219
+
2220
+ template <typename _Tp>
2221
+ static inline Scalar_<_Tp> operator-(const Scalar_<_Tp> &a,
2222
+ const Scalar_<_Tp> &b) {
2223
+ return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]),
2224
+ saturate_cast<_Tp>(a.val[1] - b.val[1]),
2225
+ saturate_cast<_Tp>(a.val[2] - b.val[2]),
2226
+ saturate_cast<_Tp>(a.val[3] - b.val[3]));
2227
+ }
2228
+
2229
+ template <typename _Tp>
2230
+ static inline Scalar_<_Tp> operator*(const Scalar_<_Tp> &a, _Tp alpha) {
2231
+ return Scalar_<_Tp>(a.val[0] * alpha, a.val[1] * alpha, a.val[2] * alpha,
2232
+ a.val[3] * alpha);
2233
+ }
2234
+
2235
+ template <typename _Tp>
2236
+ static inline Scalar_<_Tp> operator*(_Tp alpha, const Scalar_<_Tp> &a) {
2237
+ return a * alpha;
2238
+ }
2239
+
2240
+ template <typename _Tp>
2241
+ static inline Scalar_<_Tp> operator-(const Scalar_<_Tp> &a) {
2242
+ return Scalar_<_Tp>(
2243
+ saturate_cast<_Tp>(-a.val[0]), saturate_cast<_Tp>(-a.val[1]),
2244
+ saturate_cast<_Tp>(-a.val[2]), saturate_cast<_Tp>(-a.val[3]));
2245
+ }
2246
+
2247
+ template <typename _Tp>
2248
+ static inline Scalar_<_Tp> operator*(const Scalar_<_Tp> &a,
2249
+ const Scalar_<_Tp> &b) {
2250
+ return Scalar_<_Tp>(
2251
+ saturate_cast<_Tp>(a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3]),
2252
+ saturate_cast<_Tp>(a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2]),
2253
+ saturate_cast<_Tp>(a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1]),
2254
+ saturate_cast<_Tp>(a[0] * b[3] + a[1] * b[2] - a[2] * b[1] +
2255
+ a[3] * b[0]));
2256
+ }
2257
+
2258
+ template <typename _Tp>
2259
+ static inline Scalar_<_Tp> &operator*=(Scalar_<_Tp> &a, const Scalar_<_Tp> &b) {
2260
+ a = a * b;
2261
+ return a;
2262
+ }
2263
+
2264
+ template <typename _Tp>
2265
+ static inline Scalar_<_Tp> operator/(const Scalar_<_Tp> &a, _Tp alpha) {
2266
+ return Scalar_<_Tp>(a.val[0] / alpha, a.val[1] / alpha, a.val[2] / alpha,
2267
+ a.val[3] / alpha);
2268
+ }
2269
+
2270
+ template <typename _Tp>
2271
+ static inline Scalar_<float> operator/(const Scalar_<float> &a, float alpha) {
2272
+ float s = 1 / alpha;
2273
+ return Scalar_<float>(a.val[0] * s, a.val[1] * s, a.val[2] * s, a.val[3] * s);
2274
+ }
2275
+
2276
+ template <typename _Tp>
2277
+ static inline Scalar_<double> operator/(const Scalar_<double> &a,
2278
+ double alpha) {
2279
+ double s = 1 / alpha;
2280
+ return Scalar_<double>(a.val[0] * s, a.val[1] * s, a.val[2] * s,
2281
+ a.val[3] * s);
2282
+ }
2283
+
2284
+ template <typename _Tp>
2285
+ static inline Scalar_<_Tp> &operator/=(Scalar_<_Tp> &a, _Tp alpha) {
2286
+ a = a / alpha;
2287
+ return a;
2288
+ }
2289
+
2290
+ template <typename _Tp>
2291
+ static inline Scalar_<_Tp> operator/(_Tp a, const Scalar_<_Tp> &b) {
2292
+ _Tp s = a / (b[0] * b[0] + b[1] * b[1] + b[2] * b[2] + b[3] * b[3]);
2293
+ return b.conj() * s;
2294
+ }
2295
+
2296
+ template <typename _Tp>
2297
+ static inline Scalar_<_Tp> operator/(const Scalar_<_Tp> &a,
2298
+ const Scalar_<_Tp> &b) {
2299
+ return a * ((_Tp)1 / b);
2300
+ }
2301
+
2302
+ template <typename _Tp>
2303
+ static inline Scalar_<_Tp> &operator/=(Scalar_<_Tp> &a, const Scalar_<_Tp> &b) {
2304
+ a = a / b;
2305
+ return a;
2306
+ }
2307
+
2308
+ template <typename _Tp>
2309
+ static inline Scalar operator*(const Matx<_Tp, 4, 4> &a, const Scalar &b) {
2310
+ Matx<double, 4, 1> c((Matx<double, 4, 4>)a, b, Matx_MatMulOp());
2311
+ return reinterpret_cast<const Scalar &>(c);
2312
+ }
2313
+
2314
+ template <>
2315
+ inline Scalar operator*(const Matx<double, 4, 4> &a, const Scalar &b) {
2316
+ Matx<double, 4, 1> c(a, b, Matx_MatMulOp());
2317
+ return reinterpret_cast<const Scalar &>(c);
2318
+ }
2319
+
2320
+ //////////////////////////////// KeyPoint ///////////////////////////////
2321
+
2322
+ inline KeyPoint::KeyPoint()
2323
+ : pt(0, 0), size(0), angle(-1), response(0), octave(0), class_id(-1) {}
2324
+
2325
+ inline KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle,
2326
+ float _response, int _octave, int _class_id)
2327
+ : pt(_pt), size(_size), angle(_angle), response(_response), octave(_octave),
2328
+ class_id(_class_id) {}
2329
+
2330
+ inline KeyPoint::KeyPoint(float x, float y, float _size, float _angle,
2331
+ float _response, int _octave, int _class_id)
2332
+ : pt(x, y), size(_size), angle(_angle), response(_response),
2333
+ octave(_octave), class_id(_class_id) {}
2334
+
2335
+ ///////////////////////////////// DMatch ////////////////////////////////
2336
+
2337
+ inline DMatch::DMatch()
2338
+ : queryIdx(-1), trainIdx(-1), imgIdx(-1), distance(FLT_MAX) {}
2339
+
2340
+ inline DMatch::DMatch(int _queryIdx, int _trainIdx, float _distance)
2341
+ : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1),
2342
+ distance(_distance) {}
2343
+
2344
+ inline DMatch::DMatch(int _queryIdx, int _trainIdx, int _imgIdx,
2345
+ float _distance)
2346
+ : queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx),
2347
+ distance(_distance) {}
2348
+
2349
+ inline bool DMatch::operator<(const DMatch &m) const {
2350
+ return distance < m.distance;
2351
+ }
2352
+
2353
+ ////////////////////////////// TermCriteria /////////////////////////////
2354
+
2355
+ inline TermCriteria::TermCriteria() : type(0), maxCount(0), epsilon(0) {}
2356
+
2357
+ inline TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon)
2358
+ : type(_type), maxCount(_maxCount), epsilon(_epsilon) {}
2359
+
2360
+ //! @endcond
2361
+
2362
+ } // namespace cv
2363
+
2364
+ #ifdef _MSC_VER
2365
+ #pragma warning(pop)
2366
+ #endif
2367
+
2368
+ #endif // OPENCV_CORE_TYPES_HPP