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,3699 @@
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-2015, Intel Corporation, all rights reserved.
15
+ // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
16
+ // Copyright (C) 2015, OpenCV Foundation, all rights reserved.
17
+ // Copyright (C) 2015, Itseez Inc., all rights reserved.
18
+ // Third party copyrights are property of their respective owners.
19
+ //
20
+ // Redistribution and use in source and binary forms, with or without
21
+ modification,
22
+ // are permitted provided that the following conditions are met:
23
+ //
24
+ // * Redistribution's of source code must retain the above copyright notice,
25
+ // this list of conditions and the following disclaimer.
26
+ //
27
+ // * Redistribution's in binary form must reproduce the above copyright
28
+ notice,
29
+ // this list of conditions and the following disclaimer in the documentation
30
+ // and/or other materials provided with the distribution.
31
+ //
32
+ // * The name of the copyright holders may not be used to endorse or promote
33
+ products
34
+ // derived from this software without specific prior written permission.
35
+ //
36
+ // This software is provided by the copyright holders and contributors "as is"
37
+ and
38
+ // any express or implied warranties, including, but not limited to, the implied
39
+ // warranties of merchantability and fitness for a particular purpose are
40
+ disclaimed.
41
+ // In no event shall the Intel Corporation or contributors be liable for any
42
+ direct,
43
+ // indirect, incidental, special, exemplary, or consequential damages
44
+ // (including, but not limited to, procurement of substitute goods or services;
45
+ // loss of use, data, or profits; or business interruption) however caused
46
+ // and on any theory of liability, whether in contract, strict liability,
47
+ // or tort (including negligence or otherwise) arising in any way out of
48
+ // the use of this software, even if advised of the possibility of such damage.
49
+ //
50
+ //M*/
51
+
52
+ #ifndef OPENCV_CORE_HPP
53
+ #define OPENCV_CORE_HPP
54
+
55
+ #ifndef __cplusplus
56
+ #error core.hpp header must be compiled as C++
57
+ #endif
58
+
59
+ #include "opencv2/core/base.hpp"
60
+ #include "opencv2/core/cvdef.h"
61
+ #include "opencv2/core/cvstd.hpp"
62
+ #include "opencv2/core/mat.hpp"
63
+ #include "opencv2/core/matx.hpp"
64
+ #include "opencv2/core/persistence.hpp"
65
+ #include "opencv2/core/traits.hpp"
66
+ #include "opencv2/core/types.hpp"
67
+
68
+ /**
69
+ @defgroup core Core functionality
70
+
71
+ The Core module is the backbone of OpenCV, offering fundamental data structures,
72
+ matrix operations, and utility functions that other modules depend on. It’s
73
+ essential for handling image data, performing mathematical computations, and
74
+ managing memory efficiently within the OpenCV ecosystem.
75
+
76
+ @{
77
+ @defgroup core_basic Basic structures
78
+ @defgroup core_array Operations on arrays
79
+ @defgroup core_async Asynchronous API
80
+ @defgroup core_xml XML/YAML/JSON Persistence
81
+ @defgroup core_cluster Clustering
82
+ @defgroup core_utils Utility and system functions and macros
83
+ @{
84
+ @defgroup core_logging Logging facilities
85
+ @defgroup core_utils_sse SSE utilities
86
+ @defgroup core_utils_neon NEON utilities
87
+ @defgroup core_utils_vsx VSX utilities
88
+ @defgroup core_utils_softfloat Softfloat support
89
+ @defgroup core_utils_samples Utility functions for OpenCV samples
90
+ @}
91
+ @defgroup core_opengl OpenGL interoperability
92
+ @defgroup core_optim Optimization Algorithms
93
+ @defgroup core_directx DirectX interoperability
94
+ @defgroup core_eigen Eigen support
95
+ @defgroup core_opencl OpenCL support
96
+ @defgroup core_va_intel Intel VA-API/OpenCL (CL-VA) interoperability
97
+ @defgroup core_hal Hardware Acceleration Layer
98
+ @{
99
+ @defgroup core_hal_functions Functions
100
+ @defgroup core_hal_interface Interface
101
+ @defgroup core_hal_intrin Universal intrinsics
102
+ @{
103
+ @defgroup core_hal_intrin_impl Private implementation helpers
104
+ @}
105
+ @defgroup core_lowlevel_api Low-level API for external libraries /
106
+ plugins
107
+ @}
108
+ @defgroup core_parallel Parallel Processing
109
+ @{
110
+ @defgroup core_parallel_backend Parallel backends API
111
+ @}
112
+ @defgroup core_quaternion Quaternion
113
+ @}
114
+ */
115
+
116
+ namespace cv {
117
+
118
+ //! @addtogroup core_utils
119
+ //! @{
120
+
121
+ /*! @brief Class passed to an error.
122
+
123
+ This class encapsulates all or almost all necessary
124
+ information about the error happened in the program. The exception is
125
+ usually constructed and thrown implicitly via CV_Error and CV_Error_ macros.
126
+ @see error
127
+ */
128
+ class CV_EXPORTS Exception : public std::exception {
129
+ public:
130
+ /*!
131
+ Default constructor
132
+ */
133
+ Exception();
134
+ /*!
135
+ Full constructor. Normally the constructor is not called explicitly.
136
+ Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
137
+ */
138
+ Exception(int _code, const String &_err, const String &_func,
139
+ const String &_file, int _line);
140
+ virtual ~Exception() CV_NOEXCEPT;
141
+
142
+ /*!
143
+ \return the error description and the context as a text string.
144
+ */
145
+ virtual const char *what() const CV_NOEXCEPT CV_OVERRIDE;
146
+ void formatMessage();
147
+
148
+ String msg; ///< the formatted error message
149
+
150
+ int code; ///< error code @see CVStatus
151
+ String err; ///< error description
152
+ String func; ///< function name. Available only when the compiler supports
153
+ ///< getting it
154
+ String file; ///< source file name where the error has occurred
155
+ int line; ///< line number in the source file where the error has occurred
156
+ };
157
+
158
+ /*! @brief Signals an error and raises the exception.
159
+
160
+ By default the function prints information about the error to stderr,
161
+ then it either stops if cv::setBreakOnError() had been called before or raises
162
+ the exception. It is possible to alternate error processing by using
163
+ #redirectError().
164
+ @param exc the exception raisen.
165
+ @deprecated drop this version
166
+ */
167
+ CV_EXPORTS CV_NORETURN void error(const Exception &exc);
168
+
169
+ enum SortFlags {
170
+ SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
171
+ SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted
172
+ //!< independently; this flag and the previous one are
173
+ //!< mutually exclusive.
174
+ SORT_ASCENDING = 0, //!< each matrix row is sorted in the ascending
175
+ //!< order.
176
+ SORT_DESCENDING = 16 //!< each matrix row is sorted in the
177
+ //!< descending order; this flag and the previous one are
178
+ //!< also mutually exclusive.
179
+ };
180
+
181
+ //! @} core_utils
182
+
183
+ //! @addtogroup core_array
184
+ //! @{
185
+
186
+ //! Covariation flags
187
+ enum CovarFlags {
188
+ /** The output covariance matrix is calculated as:
189
+ \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} ,
190
+ \texttt{vects} [1]- \texttt{mean} ,...]^T \cdot [ \texttt{vects} [0]-
191
+ \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...],\f] The
192
+ covariance matrix will be nsamples x nsamples. Such an unusual covariance
193
+ matrix is used for fast PCA of a set of very large vectors (see, for
194
+ example, the EigenFaces technique for face recognition). Eigenvalues of
195
+ this "scrambled" matrix match the eigenvalues of the true covariance
196
+ matrix. The "true" eigenvectors can be easily calculated from the
197
+ eigenvectors of the "scrambled" covariance matrix. */
198
+ COVAR_SCRAMBLED = 0,
199
+ /**The output covariance matrix is calculated as:
200
+ \f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} ,
201
+ \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]-
202
+ \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\f] covar will
203
+ be a square matrix of the same size as the total number of elements in each
204
+ input vector. One and only one of #COVAR_SCRAMBLED and #COVAR_NORMAL must
205
+ be specified.*/
206
+ COVAR_NORMAL = 1,
207
+ /** If the flag is specified, the function does not calculate mean from
208
+ the input vectors but, instead, uses the passed mean vector. This is
209
+ useful if mean has been pre-calculated or known in advance, or if the
210
+ covariance matrix is calculated by parts. In this case, mean is not a mean
211
+ vector of the input sub-set of vectors but rather the mean vector of the
212
+ whole set.*/
213
+ COVAR_USE_AVG = 2,
214
+ /** If the flag is specified, the covariance matrix is scaled. In the
215
+ "normal" mode, scale is 1./nsamples . In the "scrambled" mode, scale is
216
+ the reciprocal of the total number of elements in each input vector. By
217
+ default (if the flag is not specified), the covariance matrix is not scaled
218
+ ( scale=1 ).*/
219
+ COVAR_SCALE = 4,
220
+ /** If the flag is
221
+ specified, all the input vectors are stored as rows of the samples matrix.
222
+ mean should be a single-row vector in this case.*/
223
+ COVAR_ROWS = 8,
224
+ /** If the flag is
225
+ specified, all the input vectors are stored as columns of the samples
226
+ matrix. mean should be a single-column vector in this case.*/
227
+ COVAR_COLS = 16
228
+ };
229
+
230
+ enum ReduceTypes {
231
+ REDUCE_SUM = 0, //!< the output is the sum of all rows/columns of the matrix.
232
+ REDUCE_AVG =
233
+ 1, //!< the output is the mean vector of all rows/columns of the matrix.
234
+ REDUCE_MAX = 2, //!< the output is the maximum (column/row-wise) of all
235
+ //!< rows/columns of the matrix.
236
+ REDUCE_MIN = 3, //!< the output is the minimum (column/row-wise) of all
237
+ //!< rows/columns of the matrix.
238
+ REDUCE_SUM2 =
239
+ 4 //!< the output is the sum of all squared rows/columns of the matrix.
240
+ };
241
+
242
+ /** @brief Swaps two matrices
243
+ */
244
+ CV_EXPORTS void swap(Mat &a, Mat &b);
245
+
246
+ /** @brief Computes the source location of an extrapolated pixel.
247
+
248
+ The function computes and returns the coordinate of a donor pixel corresponding
249
+ to the specified extrapolated pixel when using the specified extrapolation
250
+ border mode. For example, if you use cv::BORDER_WRAP mode in the horizontal
251
+ direction, cv::BORDER_REFLECT_101 in the vertical direction and want to compute
252
+ value of the "virtual" pixel Point(-5, 100) in a floating-point image img, it
253
+ looks like:
254
+ @code{.cpp}
255
+ float val = img.at<float>(borderInterpolate(100, img.rows,
256
+ cv::BORDER_REFLECT_101), borderInterpolate(-5, img.cols, cv::BORDER_WRAP));
257
+ @endcode
258
+ Normally, the function is not called directly. It is used inside filtering
259
+ functions and also in copyMakeBorder.
260
+ @param p 0-based coordinate of the extrapolated pixel along one of the axes,
261
+ likely \<0 or \>= len
262
+ @param len Length of the array along the corresponding axis.
263
+ @param borderType Border type, one of the #BorderTypes, except for
264
+ #BORDER_TRANSPARENT and #BORDER_ISOLATED. When borderType==#BORDER_CONSTANT, the
265
+ function always returns -1, regardless of p and len.
266
+
267
+ @sa copyMakeBorder
268
+ */
269
+ CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
270
+
271
+ /** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
272
+ An example using copyMakeBorder function.
273
+ Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details
274
+ */
275
+
276
+ /** @brief Forms a border around an image.
277
+
278
+ The function copies the source image into the middle of the destination image.
279
+ The areas to the left, to the right, above and below the copied source image
280
+ will be filled with extrapolated pixels. This is not what filtering functions
281
+ based on it do (they extrapolate pixels on-fly), but what other more complex
282
+ functions, including your own, may do to simplify image boundary handling.
283
+
284
+ The function supports the mode when src is already in the middle of dst . In
285
+ this case, the function does not copy src itself but simply constructs the
286
+ border, for example:
287
+
288
+ @code{.cpp}
289
+ // let border be the same in all directions
290
+ int border=2;
291
+ // constructs a larger image to fit both the image and the border
292
+ Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
293
+ // select the middle part of it w/o copying data
294
+ Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
295
+ // convert image from RGB to grayscale
296
+ cvtColor(rgb, gray, COLOR_RGB2GRAY);
297
+ // form a border in-place
298
+ copyMakeBorder(gray, gray_buf, border, border,
299
+ border, border, BORDER_REPLICATE);
300
+ // now do some custom filtering ...
301
+ ...
302
+ @endcode
303
+ @note When the source image is a part (ROI) of a bigger image, the function will
304
+ try to use the pixels outside of the ROI to form a border. To disable this
305
+ feature and always do extrapolation, as if src was not a ROI, use borderType |
306
+ #BORDER_ISOLATED.
307
+
308
+ @param src Source image.
309
+ @param dst Destination image of the same type as src and the size
310
+ Size(src.cols+left+right, src.rows+top+bottom) .
311
+ @param top the top pixels
312
+ @param bottom the bottom pixels
313
+ @param left the left pixels
314
+ @param right Parameter specifying how many pixels in each direction from the
315
+ source image rectangle to extrapolate. For example, top=1, bottom=1, left=1,
316
+ right=1 mean that 1 pixel-wide border needs to be built.
317
+ @param borderType Border type. See borderInterpolate for details.
318
+ @param value Border value if borderType==BORDER_CONSTANT .
319
+
320
+ @sa borderInterpolate
321
+ */
322
+ CV_EXPORTS_W void copyMakeBorder(InputArray src, OutputArray dst, int top,
323
+ int bottom, int left, int right,
324
+ int borderType,
325
+ const Scalar &value = Scalar());
326
+
327
+ /** @brief Calculates the per-element sum of two arrays or an array and a
328
+ scalar.
329
+
330
+ The function add calculates:
331
+ - Sum of two arrays when both input arrays have the same size and the same
332
+ number of channels:
333
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I))
334
+ \quad \texttt{if mask}(I) \ne0\f]
335
+ - Sum of an array and a scalar when src2 is constructed from Scalar or has the
336
+ same number of elements as `src1.channels()`:
337
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} )
338
+ \quad \texttt{if mask}(I) \ne0\f]
339
+ - Sum of a scalar and an array when src1 is constructed from Scalar or has the
340
+ same number of elements as `src2.channels()`:
341
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) )
342
+ \quad \texttt{if mask}(I) \ne0\f] where `I` is a multi-dimensional index of
343
+ array elements. In case of multi-channel arrays, each channel is processed
344
+ independently.
345
+
346
+ The first function in the list above can be replaced with matrix expressions:
347
+ @code{.cpp}
348
+ dst = src1 + src2;
349
+ dst += src1; // equivalent to add(dst, src1, dst);
350
+ @endcode
351
+ The input arrays and the output array can all have the same or different depths.
352
+ For example, you can add a 16-bit unsigned array to a 8-bit signed array and
353
+ store the sum as a 32-bit floating-point array. Depth of the output array is
354
+ determined by the dtype parameter. In the second and third cases above, as well
355
+ as in the first case, when src1.depth() == src2.depth(), dtype can be set to the
356
+ default -1. In this case, the output array will have the same depth as the input
357
+ array, be it src1, src2 or both.
358
+ @note Saturation is not applied when the output array has the depth CV_32S. You
359
+ may even get result of an incorrect sign in the case of overflow.
360
+ @note (Python) Be careful to difference behaviour between src1/src2 are single
361
+ number and they are tuple/array. `add(src,X)` means `add(src,(X,X,X,X))`.
362
+ `add(src,(X,))` means `add(src,(X,0,0,0))`.
363
+ @param src1 first input array or a scalar.
364
+ @param src2 second input array or a scalar.
365
+ @param dst output array that has the same size and number of channels as the
366
+ input array(s); the depth is defined by dtype or src1/src2.
367
+ @param mask optional operation mask - 8-bit single channel array, that specifies
368
+ elements of the output array to be changed.
369
+ @param dtype optional depth of the output array (see the discussion below).
370
+ @sa subtract, addWeighted, scaleAdd, Mat::convertTo
371
+ */
372
+ CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst,
373
+ InputArray mask = noArray(), int dtype = -1);
374
+
375
+ /** @brief Calculates the per-element difference between two arrays or array and
376
+ a scalar.
377
+
378
+ The function subtract calculates:
379
+ - Difference between two arrays, when both input arrays have the same size and
380
+ the same number of channels:
381
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) -
382
+ \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f]
383
+ - Difference between an array and a scalar, when src2 is constructed from Scalar
384
+ or has the same number of elements as `src1.channels()`:
385
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}
386
+ ) \quad \texttt{if mask}(I) \ne0\f]
387
+ - Difference between a scalar and an array, when src1 is constructed from Scalar
388
+ or has the same number of elements as `src2.channels()`:
389
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I)
390
+ ) \quad \texttt{if mask}(I) \ne0\f]
391
+ - The reverse difference between a scalar and an array in the case of `SubRS`:
392
+ \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I)
393
+ ) \quad \texttt{if mask}(I) \ne0\f] where I is a multi-dimensional index of
394
+ array elements. In case of multi-channel arrays, each channel is processed
395
+ independently.
396
+
397
+ The first function in the list above can be replaced with matrix expressions:
398
+ @code{.cpp}
399
+ dst = src1 - src2;
400
+ dst -= src1; // equivalent to subtract(dst, src1, dst);
401
+ @endcode
402
+ The input arrays and the output array can all have the same or different depths.
403
+ For example, you can subtract to 8-bit unsigned arrays and store the difference
404
+ in a 16-bit signed array. Depth of the output array is determined by dtype
405
+ parameter. In the second and third cases above, as well as in the first case,
406
+ when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
407
+ case the output array will have the same depth as the input array, be it src1,
408
+ src2 or both.
409
+ @note Saturation is not applied when the output array has the depth CV_32S. You
410
+ may even get result of an incorrect sign in the case of overflow.
411
+ @note (Python) Be careful to difference behaviour between src1/src2 are single
412
+ number and they are tuple/array. `subtract(src,X)` means
413
+ `subtract(src,(X,X,X,X))`. `subtract(src,(X,))` means `subtract(src,(X,0,0,0))`.
414
+ @param src1 first input array or a scalar.
415
+ @param src2 second input array or a scalar.
416
+ @param dst output array of the same size and the same number of channels as the
417
+ input array.
418
+ @param mask optional operation mask; this is an 8-bit single channel array that
419
+ specifies elements of the output array to be changed.
420
+ @param dtype optional depth of the output array
421
+ @sa add, addWeighted, scaleAdd, Mat::convertTo
422
+ */
423
+ CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst,
424
+ InputArray mask = noArray(), int dtype = -1);
425
+
426
+ /** @brief Calculates the per-element scaled product of two arrays.
427
+
428
+ The function multiply calculates the per-element product of two arrays:
429
+
430
+ \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I)
431
+ \cdot \texttt{src2} (I))\f]
432
+
433
+ There is also a @ref MatrixExpressions -friendly variant of the first function.
434
+ See Mat::mul .
435
+
436
+ For a not-per-element matrix product, see gemm .
437
+
438
+ @note Saturation is not applied when the output array has the depth
439
+ CV_32S. You may even get result of an incorrect sign in the case of
440
+ overflow.
441
+ @note (Python) Be careful to difference behaviour between src1/src2 are single
442
+ number and they are tuple/array. `multiply(src,X)` means
443
+ `multiply(src,(X,X,X,X))`. `multiply(src,(X,))` means `multiply(src,(X,0,0,0))`.
444
+ @param src1 first input array.
445
+ @param src2 second input array of the same size and the same type as src1.
446
+ @param dst output array of the same size and type as src1.
447
+ @param scale optional scale factor.
448
+ @param dtype optional depth of the output array
449
+ @sa add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct,
450
+ accumulateSquare, Mat::convertTo
451
+ */
452
+ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, OutputArray dst,
453
+ double scale = 1, int dtype = -1);
454
+
455
+ /** @brief Performs per-element division of two arrays or a scalar by an array.
456
+
457
+ The function cv::divide divides one array by another:
458
+ \f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f]
459
+ or a scalar by an array when there is no src1 :
460
+ \f[\texttt{dst(I) = saturate(scale/src2(I))}\f]
461
+
462
+ Different channels of multi-channel arrays are processed independently.
463
+
464
+ For integer types when src2(I) is zero, dst(I) will also be zero.
465
+
466
+ @note In case of floating point data there is no special defined behavior for
467
+ zero src2(I) values. Regular floating-point division is used. Expect correct
468
+ IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
469
+
470
+ @note Saturation is not applied when the output array has the depth CV_32S. You
471
+ may even get result of an incorrect sign in the case of overflow.
472
+ @note (Python) Be careful to difference behaviour between src1/src2 are single
473
+ number and they are tuple/array. `divide(src,X)` means `divide(src,(X,X,X,X))`.
474
+ `divide(src,(X,))` means `divide(src,(X,0,0,0))`.
475
+ @param src1 first input array.
476
+ @param src2 second input array of the same size and type as src1.
477
+ @param scale scalar factor.
478
+ @param dst output array of the same size and type as src2.
479
+ @param dtype optional depth of the output array; if -1, dst will have depth
480
+ src2.depth(), but in case of an array-by-array division, you can only pass -1
481
+ when src1.depth()==src2.depth().
482
+ @sa multiply, add, subtract
483
+ */
484
+ CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst,
485
+ double scale = 1, int dtype = -1);
486
+
487
+ /** @overload */
488
+ CV_EXPORTS_W void divide(double scale, InputArray src2, OutputArray dst,
489
+ int dtype = -1);
490
+
491
+ /** @brief Calculates the sum of a scaled array and another array.
492
+
493
+ The function scaleAdd is one of the classical primitive linear algebra
494
+ operations, known as DAXPY or SAXPY in
495
+ [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It
496
+ calculates the sum of a scaled array and another array:
497
+ \f[\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2}
498
+ (I)\f] The function can also be emulated with a matrix expression, for example:
499
+ @code{.cpp}
500
+ Mat A(3, 3, CV_64F);
501
+ ...
502
+ A.row(0) = A.row(1)*2 + A.row(2);
503
+ @endcode
504
+ @param src1 first input array.
505
+ @param alpha scale factor for the first array.
506
+ @param src2 second input array of the same size and type as src1.
507
+ @param dst output array of the same size and type as src1.
508
+ @sa add, addWeighted, subtract, Mat::dot, Mat::convertTo
509
+ */
510
+ CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2,
511
+ OutputArray dst);
512
+
513
+ /** @brief Calculates the weighted sum of two arrays.
514
+
515
+ The function addWeighted calculates the weighted sum of two arrays as follows:
516
+ \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} +
517
+ \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] where I is a
518
+ multi-dimensional index of array elements. In case of multi-channel arrays, each
519
+ channel is processed independently.
520
+ The function can be replaced with a matrix expression:
521
+ @code{.cpp}
522
+ dst = src1*alpha + src2*beta + gamma;
523
+ @endcode
524
+ @note Saturation is not applied when the output array has the depth CV_32S. You
525
+ may even get result of an incorrect sign in the case of overflow.
526
+ @param src1 first input array.
527
+ @param alpha weight of the first array elements.
528
+ @param src2 second input array of the same size and channel number as src1.
529
+ @param beta weight of the second array elements.
530
+ @param gamma scalar added to each sum.
531
+ @param dst output array that has the same size and number of channels as the
532
+ input arrays.
533
+ @param dtype optional depth of the output array; when both input arrays have the
534
+ same depth, dtype can be set to -1, which will be equivalent to src1.depth().
535
+ @sa add, subtract, scaleAdd, Mat::convertTo
536
+ */
537
+ CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2,
538
+ double beta, double gamma, OutputArray dst,
539
+ int dtype = -1);
540
+
541
+ /** @brief Scales, calculates absolute values, and converts the result to 8-bit.
542
+
543
+ On each element of the input array, the function convertScaleAbs
544
+ performs three operations sequentially: scaling, taking an absolute
545
+ value, conversion to an unsigned 8-bit type:
546
+ \f[\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)*
547
+ \texttt{alpha} + \texttt{beta} |)\f] In case of multi-channel arrays, the
548
+ function processes each channel independently. When the output is not 8-bit, the
549
+ operation can be emulated by calling the Mat::convertTo method (or by using
550
+ matrix expressions) and then by calculating an absolute value of the result. For
551
+ example:
552
+ @code{.cpp}
553
+ Mat_<float> A(30,30);
554
+ randu(A, Scalar(-100), Scalar(100));
555
+ Mat_<float> B = A*5 + 3;
556
+ B = abs(B);
557
+ // Mat_<float> B = abs(A*5+3) will also do the job,
558
+ // but it will allocate a temporary matrix
559
+ @endcode
560
+ @param src input array.
561
+ @param dst output array.
562
+ @param alpha optional scale factor.
563
+ @param beta optional delta added to the scaled values.
564
+ @sa Mat::convertTo, cv::abs(const Mat&)
565
+ */
566
+ CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst,
567
+ double alpha = 1, double beta = 0);
568
+
569
+ /** @brief Converts an array to half precision floating number.
570
+
571
+ This function converts FP32 (single precision floating point) from/to FP16 (half
572
+ precision floating point). CV_16S format is used to represent FP16 data. There
573
+ are two use modes (src -> dst): CV_32F -> CV_16S and CV_16S -> CV_32F. The input
574
+ array has to have type of CV_32F or CV_16S to represent the bit depth. If the
575
+ input array is neither of them, the function will raise an error. The format of
576
+ half precision floating point is defined in IEEE 754-2008.
577
+
578
+ @param src input array.
579
+ @param dst output array.
580
+
581
+ @deprecated Use Mat::convertTo with CV_16F instead.
582
+ */
583
+ CV_EXPORTS_W void convertFp16(InputArray src, OutputArray dst);
584
+
585
+ /** @example
586
+ samples/cpp/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp Check
587
+ @ref tutorial_how_to_scan_images "the corresponding tutorial" for more details
588
+ */
589
+
590
+ /** @brief Performs a look-up table transform of an array.
591
+
592
+ The function LUT fills the output array with values from the look-up table.
593
+ Indices of the entries are taken from the input array. That is, the function
594
+ processes each element of src as follows:
595
+ \f[\texttt{dst} (I) \leftarrow \texttt{lut(src(I) + d)}\f]
596
+ where
597
+ \f[d = \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if
598
+ \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\f]
599
+ @param src input array of 8-bit elements.
600
+ @param lut look-up table of 256 elements; in case of multi-channel input array,
601
+ the table should either have a single channel (in this case the same table is
602
+ used for all channels) or the same number of channels as in the input array.
603
+ @param dst output array of the same size and number of channels as src, and the
604
+ same depth as lut.
605
+ @sa convertScaleAbs, Mat::convertTo
606
+ */
607
+ CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
608
+
609
+ /** @brief Calculates the sum of array elements.
610
+
611
+ The function cv::sum calculates and returns the sum of array elements,
612
+ independently for each channel.
613
+ @param src input array that must have from 1 to 4 channels.
614
+ @sa countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce
615
+ */
616
+ CV_EXPORTS_AS(sumElems) Scalar sum(InputArray src);
617
+
618
+ /** @brief Checks for the presence of at least one non-zero array element.
619
+
620
+ The function returns whether there are non-zero elements in src
621
+
622
+ The function do not work with multi-channel arrays. If you need to check
623
+ non-zero array elements across all the channels, use Mat::reshape first to
624
+ reinterpret the array as single-channel. Or you may extract the particular
625
+ channel using either extractImageCOI, or mixChannels, or split.
626
+
627
+ @note
628
+ - If the location of non-zero array elements is important, @ref findNonZero is
629
+ helpful.
630
+ - If the count of non-zero array elements is important, @ref countNonZero is
631
+ helpful.
632
+ @param src single-channel array.
633
+ @sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
634
+ @sa findNonZero, countNonZero
635
+ */
636
+ CV_EXPORTS_W bool hasNonZero(InputArray src);
637
+
638
+ /** @brief Counts non-zero array elements.
639
+
640
+ The function returns the number of non-zero elements in src :
641
+ \f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f]
642
+
643
+ The function do not work with multi-channel arrays. If you need to count
644
+ non-zero array elements across all the channels, use Mat::reshape first to
645
+ reinterpret the array as single-channel. Or you may extract the particular
646
+ channel using either extractImageCOI, or mixChannels, or split.
647
+
648
+ @note
649
+ - If only whether there are non-zero elements is important, @ref hasNonZero is
650
+ helpful.
651
+ - If the location of non-zero array elements is important, @ref findNonZero is
652
+ helpful.
653
+ @param src single-channel array.
654
+ @sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
655
+ @sa findNonZero, hasNonZero
656
+ */
657
+ CV_EXPORTS_W int countNonZero(InputArray src);
658
+
659
+ /** @brief Returns the list of locations of non-zero pixels
660
+
661
+ Given a binary matrix (likely returned from an operation such
662
+ as threshold(), compare(), >, ==, etc, return all of
663
+ the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
664
+ For example:
665
+ @code{.cpp}
666
+ cv::Mat binaryImage; // input, binary image
667
+ cv::Mat locations; // output, locations of non-zero pixels
668
+ cv::findNonZero(binaryImage, locations);
669
+
670
+ // access pixel coordinates
671
+ Point pnt = locations.at<Point>(i);
672
+ @endcode
673
+ or
674
+ @code{.cpp}
675
+ cv::Mat binaryImage; // input, binary image
676
+ vector<Point> locations; // output, locations of non-zero pixels
677
+ cv::findNonZero(binaryImage, locations);
678
+
679
+ // access pixel coordinates
680
+ Point pnt = locations[i];
681
+ @endcode
682
+
683
+ The function do not work with multi-channel arrays. If you need to find non-zero
684
+ elements across all the channels, use Mat::reshape first to reinterpret the
685
+ array as single-channel. Or you may extract the particular channel using either
686
+ extractImageCOI, or mixChannels, or split.
687
+
688
+ @note
689
+ - If only count of non-zero array elements is important, @ref countNonZero is
690
+ helpful.
691
+ - If only whether there are non-zero elements is important, @ref hasNonZero is
692
+ helpful.
693
+ @param src single-channel array
694
+ @param idx the output array, type of cv::Mat or std::vector<Point>,
695
+ corresponding to non-zero indices in the input
696
+ @sa countNonZero, hasNonZero
697
+ */
698
+ CV_EXPORTS_W void findNonZero(InputArray src, OutputArray idx);
699
+
700
+ /** @brief Calculates an average (mean) of array elements.
701
+
702
+ The function cv::mean calculates the mean value M of array elements,
703
+ independently for each channel, and return it:
704
+ \f[\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left
705
+ ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N
706
+ \end{array}\f] When all the mask elements are 0's, the function returns
707
+ Scalar::all(0)
708
+ @param src input array that should have from 1 to 4 channels so that the result
709
+ can be stored in Scalar_ .
710
+ @param mask optional operation mask.
711
+ @sa countNonZero, meanStdDev, norm, minMaxLoc
712
+ */
713
+ CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray());
714
+
715
+ /** Calculates a mean and standard deviation of array elements.
716
+
717
+ The function cv::meanStdDev calculates the mean and the standard deviation M
718
+ of array elements independently for each channel and returns it via the
719
+ output parameters:
720
+ \f[\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean}
721
+ _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N}
722
+ \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left
723
+ ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\f] When all
724
+ the mask elements are 0's, the function returns mean=stddev=Scalar::all(0).
725
+ @note The calculated standard deviation is only the diagonal of the
726
+ complete normalized covariance matrix. If the full matrix is needed, you
727
+ can reshape the multi-channel array M x N to the single-channel array
728
+ M\*N x mtx.channels() (only possible when the matrix is continuous) and
729
+ then pass the matrix to calcCovarMatrix .
730
+ @param src input array that should have from 1 to 4 channels so that the results
731
+ can be stored in Scalar_ 's.
732
+ @param mean output parameter: calculated mean value.
733
+ @param stddev output parameter: calculated standard deviation.
734
+ @param mask optional operation mask.
735
+ @sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
736
+ */
737
+ CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean,
738
+ OutputArray stddev, InputArray mask = noArray());
739
+
740
+ /** @brief Calculates the absolute norm of an array.
741
+
742
+ This version of #norm calculates the absolute norm of src1. The type of norm to
743
+ calculate is specified using #NormTypes.
744
+
745
+ As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x
746
+ \end{pmatrix}, x \in [-1;1]\f$. The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$
747
+ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$ is
748
+ calculated as follows
749
+ \f{align*}
750
+ \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
751
+ \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
752
+ \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
753
+ \f}
754
+ and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation
755
+ is
756
+ \f{align*}
757
+ \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
758
+ \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
759
+ \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
760
+ \f}
761
+ The following graphic shows all values for the three norm functions \f$\| r(x)
762
+ \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$. It is notable
763
+ that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm
764
+ forms the lower border for the example function \f$ r(x) \f$.
765
+ ![Graphs for the different norm functions from the above
766
+ example](pics/NormTypes_OneArray_1-2-INF.png)
767
+
768
+ When the mask parameter is specified and it is not empty, the norm is
769
+
770
+ If normType is not specified, #NORM_L2 is used.
771
+ calculated only over the region specified by the mask.
772
+
773
+ Multi-channel input arrays are treated as single-channel arrays, that is,
774
+ the results for all channels are combined.
775
+
776
+ Hamming norms can only be calculated with CV_8U depth arrays.
777
+
778
+ @param src1 first input array.
779
+ @param normType type of the norm (see #NormTypes).
780
+ @param mask optional operation mask; it must have the same size as src1 and
781
+ CV_8UC1 type.
782
+ */
783
+ CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2,
784
+ InputArray mask = noArray());
785
+
786
+ /** @brief Calculates an absolute difference norm or a relative difference norm.
787
+
788
+ This version of cv::norm calculates the absolute difference norm
789
+ or the relative difference norm of arrays src1 and src2.
790
+ The type of norm to calculate is specified using #NormTypes.
791
+
792
+ @param src1 first input array.
793
+ @param src2 second input array of the same size and the same type as src1.
794
+ @param normType type of the norm (see #NormTypes).
795
+ @param mask optional operation mask; it must have the same size as src1 and
796
+ CV_8UC1 type.
797
+ */
798
+ CV_EXPORTS_W double norm(InputArray src1, InputArray src2,
799
+ int normType = NORM_L2, InputArray mask = noArray());
800
+ /** @overload
801
+ @param src first input array.
802
+ @param normType type of the norm (see #NormTypes).
803
+ */
804
+ CV_EXPORTS double norm(const SparseMat &src, int normType);
805
+
806
+ /** @brief Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
807
+
808
+ This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality
809
+ metric in decibels (dB), between two input arrays src1 and src2. The arrays must
810
+ have the same type.
811
+
812
+ The PSNR is calculated as follows:
813
+
814
+ \f[
815
+ \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
816
+ \f]
817
+
818
+ where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U
819
+ data) and MSE is the mean squared error between the two arrays.
820
+
821
+ @param src1 first input array.
822
+ @param src2 second input array of the same size as src1.
823
+ @param R the maximum pixel value (255 by default)
824
+
825
+ */
826
+ CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2, double R = 255.);
827
+
828
+ /** @brief naive nearest neighbor finder
829
+
830
+ see http://en.wikipedia.org/wiki/Nearest_neighbor_search
831
+ @todo document
832
+ */
833
+ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2,
834
+ OutputArray dist, int dtype, OutputArray nidx,
835
+ int normType = NORM_L2, int K = 0,
836
+ InputArray mask = noArray(), int update = 0,
837
+ bool crosscheck = false);
838
+
839
+ /** @brief Normalizes the norm or value range of an array.
840
+
841
+ The function cv::normalize normalizes scale and shift the input array elements
842
+ so that
843
+ \f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f]
844
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively;
845
+ or so that
846
+ \f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)=
847
+ \texttt{beta}\f]
848
+
849
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a
850
+ sub-array to be normalized. This means that the norm or min-n-max are calculated
851
+ over the sub-array, and then this sub-array is modified to be normalized. If you
852
+ want to only use the mask to calculate the norm or min-max but modify the whole
853
+ array, you can use norm and Mat::convertTo.
854
+
855
+ In case of sparse matrices, only the non-zero values are analyzed and
856
+ transformed. Because of this, the range transformation for sparse matrices is
857
+ not allowed since it can shift the zero level.
858
+
859
+ Possible usage with some positive example data:
860
+ @code{.cpp}
861
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
862
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf,
863
+ normalizedData_minmax;
864
+
865
+ // Norm to probability (total count)
866
+ // sum(numbers) = 20.0
867
+ // 2.0 0.1 (2.0/20.0)
868
+ // 8.0 0.4 (8.0/20.0)
869
+ // 10.0 0.5 (10.0/20.0)
870
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
871
+
872
+ // Norm to unit vector: ||positiveData|| = 1.0
873
+ // 2.0 0.15
874
+ // 8.0 0.62
875
+ // 10.0 0.77
876
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
877
+
878
+ // Norm to max element
879
+ // 2.0 0.2 (2.0/10.0)
880
+ // 8.0 0.8 (8.0/10.0)
881
+ // 10.0 1.0 (10.0/10.0)
882
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
883
+
884
+ // Norm to range [0.0;1.0]
885
+ // 2.0 0.0 (shift to left border)
886
+ // 8.0 0.75 (6.0/8.0)
887
+ // 10.0 1.0 (shift to right border)
888
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
889
+ @endcode
890
+
891
+ @param src input array.
892
+ @param dst output array of the same size as src .
893
+ @param alpha norm value to normalize to or the lower range boundary in case of
894
+ the range normalization.
895
+ @param beta upper range boundary in case of the range normalization; it is not
896
+ used for the norm normalization.
897
+ @param norm_type normalization type (see cv::NormTypes).
898
+ @param dtype when negative, the output array has the same type as src;
899
+ otherwise, it has the same number of channels as src and the depth
900
+ =CV_MAT_DEPTH(dtype).
901
+ @param mask optional operation mask.
902
+ @sa norm, Mat::convertTo, SparseMat::convertTo
903
+ */
904
+ CV_EXPORTS_W void normalize(InputArray src, InputOutputArray dst,
905
+ double alpha = 1, double beta = 0,
906
+ int norm_type = NORM_L2, int dtype = -1,
907
+ InputArray mask = noArray());
908
+
909
+ /** @overload
910
+ @param src input array.
911
+ @param dst output array of the same size as src .
912
+ @param alpha norm value to normalize to or the lower range boundary in case of
913
+ the range normalization.
914
+ @param normType normalization type (see cv::NormTypes).
915
+ */
916
+ CV_EXPORTS void normalize(const SparseMat &src, SparseMat &dst, double alpha,
917
+ int normType);
918
+
919
+ /** @brief Finds the global minimum and maximum in an array.
920
+
921
+ The function cv::minMaxLoc finds the minimum and maximum element values and
922
+ their positions. The extrema are searched across the whole array or, if mask is
923
+ not an empty array, in the specified array region.
924
+
925
+ In C++, if the input is multi-channel, you should omit the minLoc, maxLoc, and
926
+ mask arguments (i.e. leave them as NULL, NULL, and noArray() respectively).
927
+ These arguments are not supported for multi-channel input arrays. If working
928
+ with multi-channel input and you need the minLoc, maxLoc, or mask arguments,
929
+ then use Mat::reshape first to reinterpret the array as single-channel.
930
+ Alternatively, you can extract the particular channel using either
931
+ extractImageCOI, mixChannels, or split.
932
+
933
+ In Python, multi-channel input is not supported at all due to a limitation in
934
+ the binding generation process (there is no way to set minLoc and maxLoc to
935
+ NULL). A workaround is to operate on each channel individually or to use NumPy
936
+ to achieve the same functionality.
937
+
938
+ @param src input single-channel array.
939
+ @param minVal pointer to the returned minimum value; NULL is used if not
940
+ required.
941
+ @param maxVal pointer to the returned maximum value; NULL is used if not
942
+ required.
943
+ @param minLoc pointer to the returned minimum location (in 2D case); NULL is
944
+ used if not required.
945
+ @param maxLoc pointer to the returned maximum location (in 2D case); NULL is
946
+ used if not required.
947
+ @param mask optional mask used to select a sub-array.
948
+ @sa max, min, reduceArgMin, reduceArgMax, compare, inRange, extractImageCOI,
949
+ mixChannels, split, Mat::reshape
950
+ */
951
+ CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double *minVal,
952
+ CV_OUT double *maxVal = 0, CV_OUT Point *minLoc = 0,
953
+ CV_OUT Point *maxLoc = 0,
954
+ InputArray mask = noArray());
955
+
956
+ /**
957
+ * @brief Finds indices of min elements along provided axis
958
+ *
959
+ * @note
960
+ * - If input or output array is not continuous, this function will create
961
+ * an internal copy.
962
+ * - NaN handling is left unspecified, see patchNaNs().
963
+ * - The returned index is always in bounds of input matrix.
964
+ *
965
+ * @param src input single-channel array.
966
+ * @param dst output array of type CV_32SC1 with the same dimensionality as src,
967
+ * except for axis being reduced - it should be set to 1.
968
+ * @param lastIndex whether to get the index of first or last occurrence of min.
969
+ * @param axis axis to reduce along.
970
+ * @sa reduceArgMax, minMaxLoc, min, max, compare, reduce
971
+ */
972
+ CV_EXPORTS_W void reduceArgMin(InputArray src, OutputArray dst, int axis,
973
+ bool lastIndex = false);
974
+
975
+ /**
976
+ * @brief Finds indices of max elements along provided axis
977
+ *
978
+ * @note
979
+ * - If input or output array is not continuous, this function will create
980
+ * an internal copy.
981
+ * - NaN handling is left unspecified, see patchNaNs().
982
+ * - The returned index is always in bounds of input matrix.
983
+ *
984
+ * @param src input single-channel array.
985
+ * @param dst output array of type CV_32SC1 with the same dimensionality as src,
986
+ * except for axis being reduced - it should be set to 1.
987
+ * @param lastIndex whether to get the index of first or last occurrence of max.
988
+ * @param axis axis to reduce along.
989
+ * @sa reduceArgMin, minMaxLoc, min, max, compare, reduce
990
+ */
991
+ CV_EXPORTS_W void reduceArgMax(InputArray src, OutputArray dst, int axis,
992
+ bool lastIndex = false);
993
+
994
+ /** @brief Finds the global minimum and maximum in an array
995
+
996
+ The function cv::minMaxIdx finds the minimum and maximum element values and
997
+ their positions. The extremums are searched across the whole array or, if mask
998
+ is not an empty array, in the specified array region. In case of a sparse
999
+ matrix, the minimum is found among non-zero elements only. Multi-channel input
1000
+ is supported without mask and extremums indexes (should be nullptr).
1001
+ @note When minIdx is not NULL, it must have at least 2 elements (as well as
1002
+ maxIdx), even if src is a single-row or single-column matrix. In OpenCV
1003
+ (following MATLAB) each array has at least 2 dimensions, i.e. single-column
1004
+ matrix is Mx1 matrix (and therefore minIdx/maxIdx will be (i1,0)/(i2,0)) and
1005
+ single-row matrix is 1xN matrix (and therefore minIdx/maxIdx will be
1006
+ (0,j1)/(0,j2)).
1007
+ @param src input single-channel array.
1008
+ @param minVal pointer to the returned minimum value; NULL is used if not
1009
+ required.
1010
+ @param maxVal pointer to the returned maximum value; NULL is used if not
1011
+ required.
1012
+ @param minIdx pointer to the returned minimum location (in nD case); NULL is
1013
+ used if not required; Otherwise, it must point to an array of src.dims elements,
1014
+ the coordinates of the minimum element in each dimension are stored there
1015
+ sequentially.
1016
+ @param maxIdx pointer to the returned maximum location (in nD case). NULL is
1017
+ used if not required.
1018
+ @param mask specified array region
1019
+ */
1020
+ CV_EXPORTS void minMaxIdx(InputArray src, double *minVal, double *maxVal = 0,
1021
+ int *minIdx = 0, int *maxIdx = 0,
1022
+ InputArray mask = noArray());
1023
+
1024
+ /** @overload
1025
+ @param a input single-channel array.
1026
+ @param minVal pointer to the returned minimum value; NULL is used if not
1027
+ required.
1028
+ @param maxVal pointer to the returned maximum value; NULL is used if not
1029
+ required.
1030
+ @param minIdx pointer to the returned minimum location (in nD case); NULL is
1031
+ used if not required; Otherwise, it must point to an array of src.dims elements,
1032
+ the coordinates of the minimum element in each dimension are stored there
1033
+ sequentially.
1034
+ @param maxIdx pointer to the returned maximum location (in nD case). NULL is
1035
+ used if not required.
1036
+ */
1037
+ CV_EXPORTS void minMaxLoc(const SparseMat &a, double *minVal, double *maxVal,
1038
+ int *minIdx = 0, int *maxIdx = 0);
1039
+
1040
+ /** @brief Reduces a matrix to a vector.
1041
+
1042
+ The function #reduce reduces the matrix to a vector by treating the matrix
1043
+ rows/columns as a set of 1D vectors and performing the specified operation on
1044
+ the vectors until a single row/column is obtained. For example, the function can
1045
+ be used to compute horizontal and vertical projections of a raster image. In
1046
+ case of #REDUCE_MAX and #REDUCE_MIN, the output image should have the same type
1047
+ as the source one. In case of #REDUCE_SUM, #REDUCE_SUM2 and #REDUCE_AVG, the
1048
+ output may have a larger element bit-depth to preserve accuracy. And
1049
+ multi-channel arrays are also supported in these two reduction modes.
1050
+
1051
+ The following code demonstrates its usage for a single channel matrix.
1052
+ @snippet snippets/core_reduce.cpp example
1053
+
1054
+ And the following code demonstrates its usage for a two-channel matrix.
1055
+ @snippet snippets/core_reduce.cpp example2
1056
+
1057
+ @param src input 2D matrix.
1058
+ @param dst output vector. Its size and type is defined by dim and dtype
1059
+ parameters.
1060
+ @param dim dimension index along which the matrix is reduced. 0 means that the
1061
+ matrix is reduced to a single row. 1 means that the matrix is reduced to a
1062
+ single column.
1063
+ @param rtype reduction operation that could be one of #ReduceTypes
1064
+ @param dtype when negative, the output vector will have the same type as the
1065
+ input matrix, otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype),
1066
+ src.channels()).
1067
+ @sa repeat, reduceArgMin, reduceArgMax
1068
+ */
1069
+ CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype,
1070
+ int dtype = -1);
1071
+
1072
+ /** @brief Creates one multi-channel array out of several single-channel ones.
1073
+
1074
+ The function cv::merge merges several arrays to make a single multi-channel
1075
+ array. That is, each element of the output array will be a concatenation of the
1076
+ elements of the input arrays, where elements of i-th input array are treated as
1077
+ mv[i].channels()-element vectors.
1078
+
1079
+ The function cv::split does the reverse operation. If you need to shuffle
1080
+ channels in some other advanced way, use cv::mixChannels.
1081
+
1082
+ The following example shows how to merge 3 single channel matrices into a single
1083
+ 3-channel matrix.
1084
+ @snippet snippets/core_merge.cpp example
1085
+
1086
+ @param mv input array of matrices to be merged; all the matrices in mv must have
1087
+ the same size and the same depth.
1088
+ @param count number of input matrices when mv is a plain C array; it must be
1089
+ greater than zero.
1090
+ @param dst output array of the same size and the same depth as mv[0]; The number
1091
+ of channels will be equal to the parameter count.
1092
+ @sa mixChannels, split, Mat::reshape
1093
+ */
1094
+ CV_EXPORTS void merge(const Mat *mv, size_t count, OutputArray dst);
1095
+
1096
+ /** @overload
1097
+ @param mv input vector of matrices to be merged; all the matrices in mv must
1098
+ have the same size and the same depth.
1099
+ @param dst output array of the same size and the same depth as mv[0]; The number
1100
+ of channels will be the total number of channels in the matrix array.
1101
+ */
1102
+ CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
1103
+
1104
+ /** @brief Divides a multi-channel array into several single-channel arrays.
1105
+
1106
+ The function cv::split splits a multi-channel array into separate single-channel
1107
+ arrays:
1108
+ \f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f]
1109
+ If you need to extract a single channel or do some other sophisticated channel
1110
+ permutation, use mixChannels.
1111
+
1112
+ The following example demonstrates how to split a 3-channel matrix into 3 single
1113
+ channel matrices.
1114
+ @snippet snippets/core_split.cpp example
1115
+
1116
+ @param src input multi-channel array.
1117
+ @param mvbegin output array; the number of arrays must match src.channels(); the
1118
+ arrays themselves are reallocated, if needed.
1119
+ @sa merge, mixChannels, cvtColor
1120
+ */
1121
+ CV_EXPORTS void split(const Mat &src, Mat *mvbegin);
1122
+
1123
+ /** @overload
1124
+ @param m input multi-channel array.
1125
+ @param mv output vector of arrays; the arrays themselves are reallocated, if
1126
+ needed.
1127
+ */
1128
+ CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv);
1129
+
1130
+ /** @brief Copies specified channels from input arrays to the specified channels
1131
+ of output arrays.
1132
+
1133
+ The function cv::mixChannels provides an advanced mechanism for shuffling image
1134
+ channels.
1135
+
1136
+ cv::split,cv::merge,cv::extractChannel,cv::insertChannel and some forms of
1137
+ cv::cvtColor are partial cases of cv::mixChannels.
1138
+
1139
+ In the example below, the code splits a 4-channel BGRA image into a 3-channel
1140
+ BGR (with B and R channels swapped) and a separate alpha-channel image:
1141
+ @code{.cpp}
1142
+ Mat bgra( 100, 100, CV_8UC4, Scalar(255,0,0,255) );
1143
+ Mat bgr( bgra.rows, bgra.cols, CV_8UC3 );
1144
+ Mat alpha( bgra.rows, bgra.cols, CV_8UC1 );
1145
+
1146
+ // forming an array of matrices is a quite efficient operation,
1147
+ // because the matrix data is not copied, only the headers
1148
+ Mat out[] = { bgr, alpha };
1149
+ // bgra[0] -> bgr[2], bgra[1] -> bgr[1],
1150
+ // bgra[2] -> bgr[0], bgra[3] -> alpha[0]
1151
+ int from_to[] = { 0,2, 1,1, 2,0, 3,3 };
1152
+ mixChannels( &bgra, 1, out, 2, from_to, 4 );
1153
+ @endcode
1154
+ @note Unlike many other new-style C++ functions in OpenCV (see the introduction
1155
+ section and Mat::create ), cv::mixChannels requires the output arrays to be
1156
+ pre-allocated before calling the function.
1157
+ @param src input array or vector of matrices; all of the matrices must have the
1158
+ same size and the same depth.
1159
+ @param nsrcs number of matrices in `src`.
1160
+ @param dst output array or vector of matrices; all the matrices **must be
1161
+ allocated**; their size and depth must be the same as in `src[0]`.
1162
+ @param ndsts number of matrices in `dst`.
1163
+ @param fromTo array of index pairs specifying which channels are copied and
1164
+ where; fromTo[k\*2] is a 0-based index of the input channel in src,
1165
+ fromTo[k\*2+1] is an index of the output channel in dst; the continuous channel
1166
+ numbering is used: the first input image channels are indexed from 0 to
1167
+ src[0].channels()-1, the second input image channels are indexed from
1168
+ src[0].channels() to src[0].channels() + src[1].channels()-1, and so on, the
1169
+ same scheme is used for the output image channels; as a special case, when
1170
+ fromTo[k\*2] is negative, the corresponding output channel is filled with zero .
1171
+ @param npairs number of index pairs in `fromTo`.
1172
+ @sa split, merge, extractChannel, insertChannel, cvtColor
1173
+ */
1174
+ CV_EXPORTS void mixChannels(const Mat *src, size_t nsrcs, Mat *dst,
1175
+ size_t ndsts, const int *fromTo, size_t npairs);
1176
+
1177
+ /** @overload
1178
+ @param src input array or vector of matrices; all of the matrices must have the
1179
+ same size and the same depth.
1180
+ @param dst output array or vector of matrices; all the matrices **must be
1181
+ allocated**; their size and depth must be the same as in src[0].
1182
+ @param fromTo array of index pairs specifying which channels are copied and
1183
+ where; fromTo[k\*2] is a 0-based index of the input channel in src,
1184
+ fromTo[k\*2+1] is an index of the output channel in dst; the continuous channel
1185
+ numbering is used: the first input image channels are indexed from 0 to
1186
+ src[0].channels()-1, the second input image channels are indexed from
1187
+ src[0].channels() to src[0].channels() + src[1].channels()-1, and so on, the
1188
+ same scheme is used for the output image channels; as a special case, when
1189
+ fromTo[k\*2] is negative, the corresponding output channel is filled with zero .
1190
+ @param npairs number of index pairs in fromTo.
1191
+ */
1192
+ CV_EXPORTS void mixChannels(InputArrayOfArrays src,
1193
+ InputOutputArrayOfArrays dst, const int *fromTo,
1194
+ size_t npairs);
1195
+
1196
+ /** @overload
1197
+ @param src input array or vector of matrices; all of the matrices must have the
1198
+ same size and the same depth.
1199
+ @param dst output array or vector of matrices; all the matrices **must be
1200
+ allocated**; their size and depth must be the same as in src[0].
1201
+ @param fromTo array of index pairs specifying which channels are copied and
1202
+ where; fromTo[k\*2] is a 0-based index of the input channel in src,
1203
+ fromTo[k\*2+1] is an index of the output channel in dst; the continuous channel
1204
+ numbering is used: the first input image channels are indexed from 0 to
1205
+ src[0].channels()-1, the second input image channels are indexed from
1206
+ src[0].channels() to src[0].channels() + src[1].channels()-1, and so on, the
1207
+ same scheme is used for the output image channels; as a special case, when
1208
+ fromTo[k\*2] is negative, the corresponding output channel is filled with zero .
1209
+ */
1210
+ CV_EXPORTS_W void mixChannels(InputArrayOfArrays src,
1211
+ InputOutputArrayOfArrays dst,
1212
+ const std::vector<int> &fromTo);
1213
+
1214
+ /** @brief Extracts a single channel from src (coi is 0-based index)
1215
+ @param src input array
1216
+ @param dst output array
1217
+ @param coi index of channel to extract
1218
+ @sa mixChannels, split
1219
+ */
1220
+ CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
1221
+
1222
+ /** @brief Inserts a single channel to dst (coi is 0-based index)
1223
+ @param src input array
1224
+ @param dst output array
1225
+ @param coi index of channel for insertion
1226
+ @sa mixChannels, merge
1227
+ */
1228
+ CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi);
1229
+
1230
+ /** @brief Flips a 2D array around vertical, horizontal, or both axes.
1231
+
1232
+ The function cv::flip flips the array in one of three different ways (row
1233
+ and column indices are 0-based):
1234
+ \f[\texttt{dst} _{ij} =
1235
+ \left\{
1236
+ \begin{array}{l l}
1237
+ \texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\
1238
+ \texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\
1239
+ \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\;
1240
+ \texttt{flipCode} < 0 \\
1241
+ \end{array}
1242
+ \right.\f]
1243
+ The example scenarios of using the function are the following:
1244
+ * Vertical flipping of the image (flipCode == 0) to switch between
1245
+ top-left and bottom-left image origin. This is a typical operation
1246
+ in video processing on Microsoft Windows\* OS.
1247
+ * Horizontal flipping of the image with the subsequent horizontal
1248
+ shift and absolute difference calculation to check for a
1249
+ vertical-axis symmetry (flipCode \> 0).
1250
+ * Simultaneous horizontal and vertical flipping of the image with
1251
+ the subsequent shift and absolute difference calculation to check
1252
+ for a central symmetry (flipCode \< 0).
1253
+ * Reversing the order of point arrays (flipCode \> 0 or
1254
+ flipCode == 0).
1255
+ @param src input array.
1256
+ @param dst output array of the same size and type as src.
1257
+ @param flipCode a flag to specify how to flip the array; 0 means
1258
+ flipping around the x-axis and positive value (for example, 1) means
1259
+ flipping around y-axis. Negative value (for example, -1) means flipping
1260
+ around both axes.
1261
+ @sa transpose, repeat, completeSymm
1262
+ */
1263
+ CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode);
1264
+
1265
+ /** @brief Flips a n-dimensional at given axis
1266
+ * @param src input array
1267
+ * @param dst output array that has the same shape of src
1268
+ * @param axis axis that performs a flip on. 0 <= axis < src.dims.
1269
+ */
1270
+ CV_EXPORTS_W void flipND(InputArray src, OutputArray dst, int axis);
1271
+
1272
+ /** @brief Broadcast the given Mat to the given shape.
1273
+ * @param src input array
1274
+ * @param shape target shape. Should be a list of CV_32S numbers. Note that
1275
+ * negative values are not supported.
1276
+ * @param dst output array that has the given shape
1277
+ */
1278
+ CV_EXPORTS_W void broadcast(InputArray src, InputArray shape, OutputArray dst);
1279
+
1280
+ enum RotateFlags {
1281
+ ROTATE_90_CLOCKWISE = 0, //!< Rotate 90 degrees clockwise
1282
+ ROTATE_180 = 1, //!< Rotate 180 degrees clockwise
1283
+ ROTATE_90_COUNTERCLOCKWISE = 2, //!< Rotate 270 degrees clockwise
1284
+ };
1285
+ /** @brief Rotates a 2D array in multiples of 90 degrees.
1286
+ The function cv::rotate rotates the array in one of three different ways:
1287
+ * Rotate by 90 degrees clockwise (rotateCode = ROTATE_90_CLOCKWISE).
1288
+ * Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
1289
+ * Rotate by 270 degrees clockwise (rotateCode = ROTATE_90_COUNTERCLOCKWISE).
1290
+ @param src input array.
1291
+ @param dst output array of the same type as src. The size is the same with
1292
+ ROTATE_180, and the rows and cols are switched for ROTATE_90_CLOCKWISE and
1293
+ ROTATE_90_COUNTERCLOCKWISE.
1294
+ @param rotateCode an enum to specify how to rotate the array; see the enum
1295
+ #RotateFlags
1296
+ @sa transpose, repeat, completeSymm, flip, RotateFlags
1297
+ */
1298
+ CV_EXPORTS_W void rotate(InputArray src, OutputArray dst, int rotateCode);
1299
+
1300
+ /** @brief Fills the output array with repeated copies of the input array.
1301
+
1302
+ The function cv::repeat duplicates the input array one or more times along each
1303
+ of the two axes:
1304
+ \f[\texttt{dst} _{ij}= \texttt{src} _{i\mod src.rows, \; j\mod src.cols }\f]
1305
+ The second variant of the function is more convenient to use with @ref
1306
+ MatrixExpressions.
1307
+ @param src input array to replicate.
1308
+ @param ny Flag to specify how many times the `src` is repeated along the
1309
+ vertical axis.
1310
+ @param nx Flag to specify how many times the `src` is repeated along the
1311
+ horizontal axis.
1312
+ @param dst output array of the same type as `src`.
1313
+ @sa cv::reduce
1314
+ */
1315
+ CV_EXPORTS_W void repeat(InputArray src, int ny, int nx, OutputArray dst);
1316
+
1317
+ /** @overload
1318
+ @param src input array to replicate.
1319
+ @param ny Flag to specify how many times the `src` is repeated along the
1320
+ vertical axis.
1321
+ @param nx Flag to specify how many times the `src` is repeated along the
1322
+ horizontal axis.
1323
+ */
1324
+ CV_EXPORTS Mat repeat(const Mat &src, int ny, int nx);
1325
+
1326
+ /** @brief Applies horizontal concatenation to given matrices.
1327
+
1328
+ The function horizontally concatenates two or more cv::Mat matrices (with the
1329
+ same number of rows).
1330
+ @code{.cpp}
1331
+ cv::Mat matArray[] = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)),
1332
+ cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)),
1333
+ cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),};
1334
+
1335
+ cv::Mat out;
1336
+ cv::hconcat( matArray, 3, out );
1337
+ //out:
1338
+ //[1, 2, 3;
1339
+ // 1, 2, 3;
1340
+ // 1, 2, 3;
1341
+ // 1, 2, 3]
1342
+ @endcode
1343
+ @param src input array or vector of matrices. all of the matrices must have the
1344
+ same number of rows and the same depth.
1345
+ @param nsrc number of matrices in src.
1346
+ @param dst output array. It has the same number of rows and depth as the src,
1347
+ and the sum of cols of the src.
1348
+ @sa cv::vconcat(const Mat*, size_t, OutputArray), @sa
1349
+ cv::vconcat(InputArrayOfArrays, OutputArray) and @sa cv::vconcat(InputArray,
1350
+ InputArray, OutputArray)
1351
+ */
1352
+ CV_EXPORTS void hconcat(const Mat *src, size_t nsrc, OutputArray dst);
1353
+ /** @overload
1354
+ @code{.cpp}
1355
+ cv::Mat_<float> A = (cv::Mat_<float>(3, 2) << 1, 4,
1356
+ 2, 5,
1357
+ 3, 6);
1358
+ cv::Mat_<float> B = (cv::Mat_<float>(3, 2) << 7, 10,
1359
+ 8, 11,
1360
+ 9, 12);
1361
+
1362
+ cv::Mat C;
1363
+ cv::hconcat(A, B, C);
1364
+ //C:
1365
+ //[1, 4, 7, 10;
1366
+ // 2, 5, 8, 11;
1367
+ // 3, 6, 9, 12]
1368
+ @endcode
1369
+ @param src1 first input array to be considered for horizontal concatenation.
1370
+ @param src2 second input array to be considered for horizontal concatenation.
1371
+ @param dst output array. It has the same number of rows and depth as the src1
1372
+ and src2, and the sum of cols of the src1 and src2.
1373
+ */
1374
+ CV_EXPORTS void hconcat(InputArray src1, InputArray src2, OutputArray dst);
1375
+ /** @overload
1376
+ @code{.cpp}
1377
+ std::vector<cv::Mat> matrices = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)),
1378
+ cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)),
1379
+ cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),};
1380
+
1381
+ cv::Mat out;
1382
+ cv::hconcat( matrices, out );
1383
+ //out:
1384
+ //[1, 2, 3;
1385
+ // 1, 2, 3;
1386
+ // 1, 2, 3;
1387
+ // 1, 2, 3]
1388
+ @endcode
1389
+ @param src input array or vector of matrices. all of the matrices must have the
1390
+ same number of rows and the same depth.
1391
+ @param dst output array. It has the same number of rows and depth as the src,
1392
+ and the sum of cols of the src. same depth.
1393
+ */
1394
+ CV_EXPORTS_W void hconcat(InputArrayOfArrays src, OutputArray dst);
1395
+
1396
+ /** @brief Applies vertical concatenation to given matrices.
1397
+
1398
+ The function vertically concatenates two or more cv::Mat matrices (with the same
1399
+ number of cols).
1400
+ @code{.cpp}
1401
+ cv::Mat matArray[] = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)),
1402
+ cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)),
1403
+ cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),};
1404
+
1405
+ cv::Mat out;
1406
+ cv::vconcat( matArray, 3, out );
1407
+ //out:
1408
+ //[1, 1, 1, 1;
1409
+ // 2, 2, 2, 2;
1410
+ // 3, 3, 3, 3]
1411
+ @endcode
1412
+ @param src input array or vector of matrices. all of the matrices must have the
1413
+ same number of cols and the same depth.
1414
+ @param nsrc number of matrices in src.
1415
+ @param dst output array. It has the same number of cols and depth as the src,
1416
+ and the sum of rows of the src.
1417
+ @sa cv::hconcat(const Mat*, size_t, OutputArray), @sa
1418
+ cv::hconcat(InputArrayOfArrays, OutputArray) and @sa cv::hconcat(InputArray,
1419
+ InputArray, OutputArray)
1420
+ */
1421
+ CV_EXPORTS void vconcat(const Mat *src, size_t nsrc, OutputArray dst);
1422
+ /** @overload
1423
+ @code{.cpp}
1424
+ cv::Mat_<float> A = (cv::Mat_<float>(3, 2) << 1, 7,
1425
+ 2, 8,
1426
+ 3, 9);
1427
+ cv::Mat_<float> B = (cv::Mat_<float>(3, 2) << 4, 10,
1428
+ 5, 11,
1429
+ 6, 12);
1430
+
1431
+ cv::Mat C;
1432
+ cv::vconcat(A, B, C);
1433
+ //C:
1434
+ //[1, 7;
1435
+ // 2, 8;
1436
+ // 3, 9;
1437
+ // 4, 10;
1438
+ // 5, 11;
1439
+ // 6, 12]
1440
+ @endcode
1441
+ @param src1 first input array to be considered for vertical concatenation.
1442
+ @param src2 second input array to be considered for vertical concatenation.
1443
+ @param dst output array. It has the same number of cols and depth as the src1
1444
+ and src2, and the sum of rows of the src1 and src2.
1445
+ */
1446
+ CV_EXPORTS void vconcat(InputArray src1, InputArray src2, OutputArray dst);
1447
+ /** @overload
1448
+ @code{.cpp}
1449
+ std::vector<cv::Mat> matrices = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)),
1450
+ cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)),
1451
+ cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),};
1452
+
1453
+ cv::Mat out;
1454
+ cv::vconcat( matrices, out );
1455
+ //out:
1456
+ //[1, 1, 1, 1;
1457
+ // 2, 2, 2, 2;
1458
+ // 3, 3, 3, 3]
1459
+ @endcode
1460
+ @param src input array or vector of matrices. all of the matrices must have the
1461
+ same number of cols and the same depth
1462
+ @param dst output array. It has the same number of cols and depth as the src,
1463
+ and the sum of rows of the src. same depth.
1464
+ */
1465
+ CV_EXPORTS_W void vconcat(InputArrayOfArrays src, OutputArray dst);
1466
+
1467
+ /** @brief computes bitwise conjunction of the two arrays (dst = src1 & src2)
1468
+ Calculates the per-element bit-wise conjunction of two arrays or an
1469
+ array and a scalar.
1470
+
1471
+ The function cv::bitwise_and calculates the per-element bit-wise logical
1472
+ conjunction for:
1473
+ * Two arrays when src1 and src2 have the same size:
1474
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad
1475
+ \texttt{if mask} (I) \ne0\f]
1476
+ * An array and a scalar when src2 is constructed from Scalar or has
1477
+ the same number of elements as `src1.channels()`:
1478
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad
1479
+ \texttt{if mask} (I) \ne0\f]
1480
+ * A scalar and an array when src1 is constructed from Scalar or has
1481
+ the same number of elements as `src2.channels()`:
1482
+ \f[\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad
1483
+ \texttt{if mask} (I) \ne0\f] In case of floating-point arrays, their
1484
+ machine-specific bit representations (usually IEEE754-compliant) are used for
1485
+ the operation. In case of multi-channel arrays, each channel is processed
1486
+ independently. In the second and third cases above, the scalar is first
1487
+ converted to the array type.
1488
+ @param src1 first input array or a scalar.
1489
+ @param src2 second input array or a scalar.
1490
+ @param dst output array that has the same size and type as the input
1491
+ arrays.
1492
+ @param mask optional operation mask, 8-bit single channel array, that
1493
+ specifies elements of the output array to be changed.
1494
+ */
1495
+ CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2, OutputArray dst,
1496
+ InputArray mask = noArray());
1497
+
1498
+ /** @brief Calculates the per-element bit-wise disjunction of two arrays or an
1499
+ array and a scalar.
1500
+
1501
+ The function cv::bitwise_or calculates the per-element bit-wise logical
1502
+ disjunction for:
1503
+ * Two arrays when src1 and src2 have the same size:
1504
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad
1505
+ \texttt{if mask} (I) \ne0\f]
1506
+ * An array and a scalar when src2 is constructed from Scalar or has
1507
+ the same number of elements as `src1.channels()`:
1508
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad
1509
+ \texttt{if mask} (I) \ne0\f]
1510
+ * A scalar and an array when src1 is constructed from Scalar or has
1511
+ the same number of elements as `src2.channels()`:
1512
+ \f[\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad
1513
+ \texttt{if mask} (I) \ne0\f] In case of floating-point arrays, their
1514
+ machine-specific bit representations (usually IEEE754-compliant) are used for
1515
+ the operation. In case of multi-channel arrays, each channel is processed
1516
+ independently. In the second and third cases above, the scalar is first
1517
+ converted to the array type.
1518
+ @param src1 first input array or a scalar.
1519
+ @param src2 second input array or a scalar.
1520
+ @param dst output array that has the same size and type as the input
1521
+ arrays.
1522
+ @param mask optional operation mask, 8-bit single channel array, that
1523
+ specifies elements of the output array to be changed.
1524
+ */
1525
+ CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2, OutputArray dst,
1526
+ InputArray mask = noArray());
1527
+
1528
+ /** @brief Calculates the per-element bit-wise "exclusive or" operation on two
1529
+ arrays or an array and a scalar.
1530
+
1531
+ The function cv::bitwise_xor calculates the per-element bit-wise logical
1532
+ "exclusive-or" operation for:
1533
+ * Two arrays when src1 and src2 have the same size:
1534
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad
1535
+ \texttt{if mask} (I) \ne0\f]
1536
+ * An array and a scalar when src2 is constructed from Scalar or has
1537
+ the same number of elements as `src1.channels()`:
1538
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad
1539
+ \texttt{if mask} (I) \ne0\f]
1540
+ * A scalar and an array when src1 is constructed from Scalar or has
1541
+ the same number of elements as `src2.channels()`:
1542
+ \f[\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad
1543
+ \texttt{if mask} (I) \ne0\f] In case of floating-point arrays, their
1544
+ machine-specific bit representations (usually IEEE754-compliant) are used for
1545
+ the operation. In case of multi-channel arrays, each channel is processed
1546
+ independently. In the 2nd and 3rd cases above, the scalar is first
1547
+ converted to the array type.
1548
+ @param src1 first input array or a scalar.
1549
+ @param src2 second input array or a scalar.
1550
+ @param dst output array that has the same size and type as the input
1551
+ arrays.
1552
+ @param mask optional operation mask, 8-bit single channel array, that
1553
+ specifies elements of the output array to be changed.
1554
+ */
1555
+ CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2, OutputArray dst,
1556
+ InputArray mask = noArray());
1557
+
1558
+ /** @brief Inverts every bit of an array.
1559
+
1560
+ The function cv::bitwise_not calculates per-element bit-wise inversion of the
1561
+ input array:
1562
+ \f[\texttt{dst} (I) = \neg \texttt{src} (I)\f]
1563
+ In case of a floating-point input array, its machine-specific bit
1564
+ representation (usually IEEE754-compliant) is used for the operation. In
1565
+ case of multi-channel arrays, each channel is processed independently.
1566
+ @param src input array.
1567
+ @param dst output array that has the same size and type as the input
1568
+ array.
1569
+ @param mask optional operation mask, 8-bit single channel array, that
1570
+ specifies elements of the output array to be changed.
1571
+ */
1572
+ CV_EXPORTS_W void bitwise_not(InputArray src, OutputArray dst,
1573
+ InputArray mask = noArray());
1574
+
1575
+ /** @brief Calculates the per-element absolute difference between two arrays or
1576
+ between an array and a scalar.
1577
+
1578
+ The function cv::absdiff calculates:
1579
+ * Absolute difference between two arrays when they have the same
1580
+ size and type:
1581
+ \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) -
1582
+ \texttt{src2}(I)|)\f]
1583
+ * Absolute difference between an array and a scalar when the second
1584
+ array is constructed from Scalar or has as many elements as the
1585
+ number of channels in `src1`:
1586
+ \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}
1587
+ |)\f]
1588
+ * Absolute difference between a scalar and an array when the first
1589
+ array is constructed from Scalar or has as many elements as the
1590
+ number of channels in `src2`:
1591
+ \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I)
1592
+ |)\f] where I is a multi-dimensional index of array elements. In case of
1593
+ multi-channel arrays, each channel is processed independently.
1594
+ @note Saturation is not applied when the arrays have the depth CV_32S.
1595
+ You may even get a negative value in the case of overflow.
1596
+ @note (Python) Be careful to difference behaviour between src1/src2 are single
1597
+ number and they are tuple/array. `absdiff(src,X)` means
1598
+ `absdiff(src,(X,X,X,X))`. `absdiff(src,(X,))` means `absdiff(src,(X,0,0,0))`.
1599
+ @param src1 first input array or a scalar.
1600
+ @param src2 second input array or a scalar.
1601
+ @param dst output array that has the same size and type as input arrays.
1602
+ @sa cv::abs(const Mat&)
1603
+ */
1604
+ CV_EXPORTS_W void absdiff(InputArray src1, InputArray src2, OutputArray dst);
1605
+
1606
+ /** @brief This is an overloaded member function, provided for convenience
1607
+ (python) Copies the matrix to another one. When the operation mask is specified,
1608
+ if the Mat::create call shown above reallocates the matrix, the newly allocated
1609
+ matrix is initialized with all zeros before copying the data.
1610
+ @param src source matrix.
1611
+ @param dst Destination matrix. If it does not have a proper size or type before
1612
+ the operation, it is reallocated.
1613
+ @param mask Operation mask of the same size as \*this. Its non-zero elements
1614
+ indicate which matrix elements need to be copied. The mask has to be of type
1615
+ CV_8U and can have 1 or multiple channels.
1616
+ */
1617
+
1618
+ void CV_EXPORTS_W copyTo(InputArray src, OutputArray dst, InputArray mask);
1619
+ /** @brief Checks if array elements lie between the elements of two other
1620
+ arrays.
1621
+
1622
+ The function checks the range as follows:
1623
+ - For every element of a single-channel input array:
1624
+ \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq
1625
+ \texttt{upperb} (I)_0\f]
1626
+ - For two-channel arrays:
1627
+ \f[\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq
1628
+ \texttt{upperb} (I)_0 \land \texttt{lowerb} (I)_1 \leq \texttt{src} (I)_1 \leq
1629
+ \texttt{upperb} (I)_1\f]
1630
+ - and so forth.
1631
+
1632
+ That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the
1633
+ specified 1D, 2D, 3D, ... box and 0 otherwise.
1634
+
1635
+ When the lower and/or upper boundary parameters are scalars, the indexes
1636
+ (I) at lowerb and upperb in the above formulas should be omitted.
1637
+ @param src first input array.
1638
+ @param lowerb inclusive lower boundary array or a scalar.
1639
+ @param upperb inclusive upper boundary array or a scalar.
1640
+ @param dst output array of the same size as src and CV_8U type.
1641
+ */
1642
+ CV_EXPORTS_W void inRange(InputArray src, InputArray lowerb, InputArray upperb,
1643
+ OutputArray dst);
1644
+
1645
+ /** @brief Performs the per-element comparison of two arrays or an array and
1646
+ scalar value.
1647
+
1648
+ The function compares:
1649
+ * Elements of two arrays when src1 and src2 have the same size:
1650
+ \f[\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2}
1651
+ (I)\f]
1652
+ * Elements of src1 with a scalar src2 when src2 is constructed from
1653
+ Scalar or has a single element:
1654
+ \f[\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\f]
1655
+ * src1 with elements of src2 when src1 is constructed from Scalar or
1656
+ has a single element:
1657
+ \f[\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2}
1658
+ (I)\f] When the comparison result is true, the corresponding element of output
1659
+ array is set to 255. The comparison operations can be replaced with the
1660
+ equivalent matrix expressions:
1661
+ @code{.cpp}
1662
+ Mat dst1 = src1 >= src2;
1663
+ Mat dst2 = src1 < 8;
1664
+ ...
1665
+ @endcode
1666
+ @param src1 first input array or a scalar; when it is an array, it must have a
1667
+ single channel.
1668
+ @param src2 second input array or a scalar; when it is an array, it must have a
1669
+ single channel.
1670
+ @param dst output array of type ref CV_8U that has the same size and the same
1671
+ number of channels as the input arrays.
1672
+ @param cmpop a flag, that specifies correspondence between the arrays
1673
+ (cv::CmpTypes)
1674
+ @sa checkRange, min, max, threshold
1675
+ */
1676
+ CV_EXPORTS_W void compare(InputArray src1, InputArray src2, OutputArray dst,
1677
+ int cmpop);
1678
+
1679
+ /** @brief Calculates per-element minimum of two arrays or an array and a
1680
+ scalar.
1681
+
1682
+ The function cv::min calculates the per-element minimum of two arrays:
1683
+ \f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\f]
1684
+ or array and a scalar:
1685
+ \f[\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\f]
1686
+ @param src1 first input array.
1687
+ @param src2 second input array of the same size and type as src1.
1688
+ @param dst output array of the same size and type as src1.
1689
+ @sa max, compare, inRange, minMaxLoc
1690
+ */
1691
+ CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst);
1692
+ /** @overload
1693
+ needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&,
1694
+ _Compare)
1695
+ */
1696
+ CV_EXPORTS void min(const Mat &src1, const Mat &src2, Mat &dst);
1697
+
1698
+ /** @brief Calculates per-element maximum of two arrays or an array and a
1699
+ scalar.
1700
+
1701
+ The function cv::max calculates the per-element maximum of two arrays:
1702
+ \f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\f]
1703
+ or array and a scalar:
1704
+ \f[\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\f]
1705
+ @param src1 first input array.
1706
+ @param src2 second input array of the same size and type as src1 .
1707
+ @param dst output array of the same size and type as src1.
1708
+ @sa min, compare, inRange, minMaxLoc, @ref MatrixExpressions
1709
+ */
1710
+ CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst);
1711
+ /** @overload
1712
+ needed to avoid conflicts with const _Tp& std::min(const _Tp&, const _Tp&,
1713
+ _Compare)
1714
+ */
1715
+ CV_EXPORTS void max(const Mat &src1, const Mat &src2, Mat &dst);
1716
+
1717
+ /** @brief Calculates a square root of array elements.
1718
+
1719
+ The function cv::sqrt calculates a square root of each input array element.
1720
+ In case of multi-channel arrays, each channel is processed
1721
+ independently. The accuracy is approximately the same as of the built-in
1722
+ std::sqrt .
1723
+ @param src input floating-point array.
1724
+ @param dst output array of the same size and type as src.
1725
+ */
1726
+ CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst);
1727
+
1728
+ /** @brief Raises every array element to a power.
1729
+
1730
+ The function cv::pow raises every element of the input array to power :
1731
+ \f[\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is
1732
+ integer}{|\texttt{src}(I)|^{power}}{otherwise}\f]
1733
+
1734
+ So, for a non-integer power exponent, the absolute values of input array
1735
+ elements are used. However, it is possible to get true values for
1736
+ negative values using some extra operations. In the example below,
1737
+ computing the 5th root of array src shows:
1738
+ @code{.cpp}
1739
+ Mat mask = src < 0;
1740
+ pow(src, 1./5, dst);
1741
+ subtract(Scalar::all(0), dst, dst, mask);
1742
+ @endcode
1743
+ For some values of power, such as integer values, 0.5 and -0.5,
1744
+ specialized faster algorithms are used.
1745
+
1746
+ Special values (NaN, Inf) are not handled.
1747
+ @param src input array.
1748
+ @param power exponent of power.
1749
+ @param dst output array of the same size and type as src.
1750
+ @sa sqrt, exp, log, cartToPolar, polarToCart
1751
+ */
1752
+ CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst);
1753
+
1754
+ /** @brief Calculates the exponent of every array element.
1755
+
1756
+ The function cv::exp calculates the exponent of every element of the input
1757
+ array:
1758
+ \f[\texttt{dst} [I] = e^{ src(I) }\f]
1759
+
1760
+ The maximum relative error is about 7e-6 for single-precision input and
1761
+ less than 1e-10 for double-precision input. Currently, the function
1762
+ converts denormalized values to zeros on output. Special values (NaN,
1763
+ Inf) are not handled.
1764
+ @param src input array.
1765
+ @param dst output array of the same size and type as src.
1766
+ @sa log, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
1767
+ */
1768
+ CV_EXPORTS_W void exp(InputArray src, OutputArray dst);
1769
+
1770
+ /** @brief Calculates the natural logarithm of every array element.
1771
+
1772
+ The function cv::log calculates the natural logarithm of every element of the
1773
+ input array:
1774
+ \f[\texttt{dst} (I) = \log (\texttt{src}(I)) \f]
1775
+
1776
+ Output on zero, negative and special (NaN, Inf) values is undefined.
1777
+
1778
+ @param src input array.
1779
+ @param dst output array of the same size and type as src .
1780
+ @sa exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
1781
+ */
1782
+ CV_EXPORTS_W void log(InputArray src, OutputArray dst);
1783
+
1784
+ /** @brief Calculates x and y coordinates of 2D vectors from their magnitude and
1785
+ angle.
1786
+
1787
+ The function cv::polarToCart calculates the Cartesian coordinates of each 2D
1788
+ vector represented by the corresponding elements of magnitude and angle:
1789
+ \f[\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos (
1790
+ \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin (
1791
+ \texttt{angle} (I)) \\ \end{array}\f]
1792
+
1793
+ The relative accuracy of the estimated coordinates is about 1e-6.
1794
+ @param magnitude input floating-point array of magnitudes of 2D vectors;
1795
+ it can be an empty matrix (=Mat()), in this case, the function assumes
1796
+ that all the magnitudes are =1; if it is not empty, it must have the
1797
+ same size and type as angle.
1798
+ @param angle input floating-point array of angles of 2D vectors.
1799
+ @param x output array of x-coordinates of 2D vectors; it has the same
1800
+ size and type as angle.
1801
+ @param y output array of y-coordinates of 2D vectors; it has the same
1802
+ size and type as angle.
1803
+ @param angleInDegrees when true, the input angles are measured in
1804
+ degrees, otherwise, they are measured in radians.
1805
+ @sa cartToPolar, magnitude, phase, exp, log, pow, sqrt
1806
+ */
1807
+ CV_EXPORTS_W void polarToCart(InputArray magnitude, InputArray angle,
1808
+ OutputArray x, OutputArray y,
1809
+ bool angleInDegrees = false);
1810
+
1811
+ /** @brief Calculates the magnitude and angle of 2D vectors.
1812
+
1813
+ The function cv::cartToPolar calculates either the magnitude, angle, or both
1814
+ for every 2D vector (x(I),y(I)):
1815
+ \f[\begin{array}{l} \texttt{magnitude} (I)=
1816
+ \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} (
1817
+ \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\f]
1818
+
1819
+ The angles are calculated with accuracy about 0.3 degrees. For the point
1820
+ (0,0), the angle is set to 0.
1821
+ @param x array of x-coordinates; this must be a single-precision or
1822
+ double-precision floating-point array.
1823
+ @param y array of y-coordinates, that must have the same size and same type as
1824
+ x.
1825
+ @param magnitude output array of magnitudes of the same size and type as x.
1826
+ @param angle output array of angles that has the same size and type as
1827
+ x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360
1828
+ degrees).
1829
+ @param angleInDegrees a flag, indicating whether the angles are measured
1830
+ in radians (which is by default), or in degrees.
1831
+ @sa Sobel, Scharr
1832
+ */
1833
+ CV_EXPORTS_W void cartToPolar(InputArray x, InputArray y, OutputArray magnitude,
1834
+ OutputArray angle, bool angleInDegrees = false);
1835
+
1836
+ /** @brief Calculates the rotation angle of 2D vectors.
1837
+
1838
+ The function cv::phase calculates the rotation angle of each 2D vector that
1839
+ is formed from the corresponding elements of x and y :
1840
+ \f[\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\f]
1841
+
1842
+ The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
1843
+ the corresponding angle(I) is set to 0.
1844
+ @param x input floating-point array of x-coordinates of 2D vectors.
1845
+ @param y input array of y-coordinates of 2D vectors; it must have the
1846
+ same size and the same type as x.
1847
+ @param angle output array of vector angles; it has the same size and
1848
+ same type as x .
1849
+ @param angleInDegrees when true, the function calculates the angle in
1850
+ degrees, otherwise, they are measured in radians.
1851
+ */
1852
+ CV_EXPORTS_W void phase(InputArray x, InputArray y, OutputArray angle,
1853
+ bool angleInDegrees = false);
1854
+
1855
+ /** @brief Calculates the magnitude of 2D vectors.
1856
+
1857
+ The function cv::magnitude calculates the magnitude of 2D vectors formed
1858
+ from the corresponding elements of x and y arrays:
1859
+ \f[\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\f]
1860
+ @param x floating-point array of x-coordinates of the vectors.
1861
+ @param y floating-point array of y-coordinates of the vectors; it must
1862
+ have the same size as x.
1863
+ @param magnitude output array of the same size and type as x.
1864
+ @sa cartToPolar, polarToCart, phase, sqrt
1865
+ */
1866
+ CV_EXPORTS_W void magnitude(InputArray x, InputArray y, OutputArray magnitude);
1867
+
1868
+ /** @brief Checks every element of an input array for invalid values.
1869
+
1870
+ The function cv::checkRange checks that every array element is neither NaN nor
1871
+ infinite. When minVal \> -DBL_MAX and maxVal \< DBL_MAX, the function also
1872
+ checks that each value is between minVal and maxVal. In case of multi-channel
1873
+ arrays, each channel is processed independently. If some values are out of
1874
+ range, position of the first outlier is stored in pos (when pos != NULL). Then,
1875
+ the function either returns false (when quiet=true) or throws an exception.
1876
+ @param a input array.
1877
+ @param quiet a flag, indicating whether the functions quietly return false when
1878
+ the array elements are out of range or they throw an exception.
1879
+ @param pos optional output parameter, when not NULL, must be a pointer to array
1880
+ of src.dims elements.
1881
+ @param minVal inclusive lower boundary of valid values range.
1882
+ @param maxVal exclusive upper boundary of valid values range.
1883
+ */
1884
+ CV_EXPORTS_W bool checkRange(InputArray a, bool quiet = true,
1885
+ CV_OUT Point *pos = 0, double minVal = -DBL_MAX,
1886
+ double maxVal = DBL_MAX);
1887
+
1888
+ /** @brief Replaces NaNs by given number
1889
+ @param a input/output matrix (CV_32F type).
1890
+ @param val value to convert the NaNs
1891
+ */
1892
+ CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0);
1893
+
1894
+ /** @brief Performs generalized matrix multiplication.
1895
+
1896
+ The function cv::gemm performs generalized matrix multiplication similar to the
1897
+ gemm functions in BLAS level 3. For example,
1898
+ `gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`
1899
+ corresponds to
1900
+ \f[\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} +
1901
+ \texttt{beta} \cdot \texttt{src3} ^T\f]
1902
+
1903
+ In case of complex (two-channel) data, performed a complex matrix
1904
+ multiplication.
1905
+
1906
+ The function can be replaced with a matrix expression. For example, the
1907
+ above call can be replaced with:
1908
+ @code{.cpp}
1909
+ dst = alpha*src1.t()*src2 + beta*src3.t();
1910
+ @endcode
1911
+ @param src1 first multiplied input matrix that could be real(CV_32FC1,
1912
+ CV_64FC1) or complex(CV_32FC2, CV_64FC2).
1913
+ @param src2 second multiplied input matrix of the same type as src1.
1914
+ @param alpha weight of the matrix product.
1915
+ @param src3 third optional delta matrix added to the matrix product; it
1916
+ should have the same type as src1 and src2.
1917
+ @param beta weight of src3.
1918
+ @param dst output matrix; it has the proper size and the same type as
1919
+ input matrices.
1920
+ @param flags operation flags (cv::GemmFlags)
1921
+ @sa mulTransposed, transform
1922
+ */
1923
+ CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha,
1924
+ InputArray src3, double beta, OutputArray dst,
1925
+ int flags = 0);
1926
+
1927
+ /** @brief Calculates the product of a matrix and its transposition.
1928
+
1929
+ The function cv::mulTransposed calculates the product of src and its
1930
+ transposition:
1931
+ \f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T (
1932
+ \texttt{src} - \texttt{delta} )\f] if aTa=true, and
1933
+ \f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) (
1934
+ \texttt{src} - \texttt{delta} )^T\f] otherwise. The function is used to
1935
+ calculate the covariance matrix. With zero delta, it can be used as a faster
1936
+ substitute for general matrix product A\*B when B=A'
1937
+ @param src input single-channel matrix. Note that unlike gemm, the
1938
+ function can multiply not only floating-point matrices.
1939
+ @param dst output square matrix.
1940
+ @param aTa Flag specifying the multiplication ordering. See the
1941
+ description below.
1942
+ @param delta Optional delta matrix subtracted from src before the
1943
+ multiplication. When the matrix is empty ( delta=noArray() ), it is
1944
+ assumed to be zero, that is, nothing is subtracted. If it has the same
1945
+ size as src, it is simply subtracted. Otherwise, it is "repeated" (see
1946
+ repeat ) to cover the full src and then subtracted. Type of the delta
1947
+ matrix, when it is not empty, must be the same as the type of created
1948
+ output matrix. See the dtype parameter description below.
1949
+ @param scale Optional scale factor for the matrix product.
1950
+ @param dtype Optional type of the output matrix. When it is negative,
1951
+ the output matrix will have the same type as src . Otherwise, it will be
1952
+ type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
1953
+ @sa calcCovarMatrix, gemm, repeat, reduce
1954
+ */
1955
+ CV_EXPORTS_W void mulTransposed(InputArray src, OutputArray dst, bool aTa,
1956
+ InputArray delta = noArray(), double scale = 1,
1957
+ int dtype = -1);
1958
+
1959
+ /** @brief Transposes a matrix.
1960
+
1961
+ The function cv::transpose transposes the matrix src :
1962
+ \f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f]
1963
+ @note No complex conjugation is done in case of a complex matrix. It
1964
+ should be done separately if needed.
1965
+ @param src input array.
1966
+ @param dst output array of the same type as src.
1967
+ */
1968
+ CV_EXPORTS_W void transpose(InputArray src, OutputArray dst);
1969
+
1970
+ /** @brief Transpose for n-dimensional matrices.
1971
+ *
1972
+ * @note Input should be continuous single-channel matrix.
1973
+ * @param src input array.
1974
+ * @param order a permutation of [0,1,..,N-1] where N is the number of axes of
1975
+ * src. The i'th axis of dst will correspond to the axis numbered order[i] of
1976
+ * the input.
1977
+ * @param dst output array of the same type as src.
1978
+ */
1979
+ CV_EXPORTS_W void transposeND(InputArray src, const std::vector<int> &order,
1980
+ OutputArray dst);
1981
+
1982
+ /** @brief Performs the matrix transformation of every array element.
1983
+
1984
+ The function cv::transform performs the matrix transformation of every
1985
+ element of the array src and stores the results in dst :
1986
+ \f[\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\f]
1987
+ (when m.cols=src.channels() ), or
1988
+ \f[\texttt{dst} (I) = \texttt{m} \cdot [ \texttt{src} (I); 1]\f]
1989
+ (when m.cols=src.channels()+1 )
1990
+
1991
+ Every element of the N -channel array src is interpreted as N -element
1992
+ vector that is transformed using the M x N or M x (N+1) matrix m to
1993
+ M-element vector - the corresponding element of the output array dst .
1994
+
1995
+ The function may be used for geometrical transformation of
1996
+ N -dimensional points, arbitrary linear color space transformation (such
1997
+ as various kinds of RGB to YUV transforms), shuffling the image
1998
+ channels, and so forth.
1999
+ @param src input array that must have as many channels (1 to 4) as
2000
+ m.cols or m.cols-1.
2001
+ @param dst output array of the same size and depth as src; it has as
2002
+ many channels as m.rows.
2003
+ @param m transformation 2x2 or 2x3 floating-point matrix.
2004
+ @sa perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine,
2005
+ warpPerspective
2006
+ */
2007
+ CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m);
2008
+
2009
+ /** @brief Performs the perspective matrix transformation of vectors.
2010
+
2011
+ The function cv::perspectiveTransform transforms every element of src by
2012
+ treating it as a 2D or 3D vector, in the following way:
2013
+ \f[(x, y, z) \rightarrow (x'/w, y'/w, z'/w)\f]
2014
+ where
2015
+ \f[(x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1
2016
+ \end{bmatrix}\f] and
2017
+ \f[w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\f]
2018
+
2019
+ Here a 3D vector transformation is shown. In case of a 2D vector
2020
+ transformation, the z component is omitted.
2021
+
2022
+ @note The function transforms a sparse set of 2D or 3D vectors. If you
2023
+ want to transform an image using perspective transformation, use
2024
+ warpPerspective . If you have an inverse problem, that is, you want to
2025
+ compute the most probable perspective transformation out of several
2026
+ pairs of corresponding points, you can use getPerspectiveTransform or
2027
+ findHomography .
2028
+ @param src input two-channel or three-channel floating-point array; each
2029
+ element is a 2D/3D vector to be transformed.
2030
+ @param dst output array of the same size and type as src.
2031
+ @param m 3x3 or 4x4 floating-point transformation matrix.
2032
+ @sa transform, warpPerspective, getPerspectiveTransform, findHomography
2033
+ */
2034
+ CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst,
2035
+ InputArray m);
2036
+
2037
+ /** @brief Copies the lower or the upper half of a square matrix to its another
2038
+ half.
2039
+
2040
+ The function cv::completeSymm copies the lower or the upper half of a square
2041
+ matrix to its another half. The matrix diagonal remains unchanged:
2042
+ - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i > j\f$ if
2043
+ lowerToUpper=false
2044
+ - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i < j\f$ if
2045
+ lowerToUpper=true
2046
+
2047
+ @param m input-output floating-point square matrix.
2048
+ @param lowerToUpper operation flag; if true, the lower half is copied to
2049
+ the upper half. Otherwise, the upper half is copied to the lower half.
2050
+ @sa flip, transpose
2051
+ */
2052
+ CV_EXPORTS_W void completeSymm(InputOutputArray m, bool lowerToUpper = false);
2053
+
2054
+ /** @brief Initializes a scaled identity matrix.
2055
+
2056
+ The function cv::setIdentity initializes a scaled identity matrix:
2057
+ \f[\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\f]
2058
+
2059
+ The function can also be emulated using the matrix initializers and the
2060
+ matrix expressions:
2061
+ @code
2062
+ Mat A = Mat::eye(4, 3, CV_32F)*5;
2063
+ // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
2064
+ @endcode
2065
+ @param mtx matrix to initialize (not necessarily square).
2066
+ @param s value to assign to diagonal elements.
2067
+ @sa Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
2068
+ */
2069
+ CV_EXPORTS_W void setIdentity(InputOutputArray mtx,
2070
+ const Scalar &s = Scalar(1));
2071
+
2072
+ /** @brief Returns the determinant of a square floating-point matrix.
2073
+
2074
+ The function cv::determinant calculates and returns the determinant of the
2075
+ specified matrix. For small matrices ( mtx.cols=mtx.rows\<=3 ), the
2076
+ direct method is used. For larger matrices, the function uses LU
2077
+ factorization with partial pivoting.
2078
+
2079
+ For symmetric positively-determined matrices, it is also possible to use
2080
+ eigen decomposition to calculate the determinant.
2081
+ @param mtx input matrix that must have CV_32FC1 or CV_64FC1 type and
2082
+ square size.
2083
+ @sa trace, invert, solve, eigen, @ref MatrixExpressions
2084
+ */
2085
+ CV_EXPORTS_W double determinant(InputArray mtx);
2086
+
2087
+ /** @brief Returns the trace of a matrix.
2088
+
2089
+ The function cv::trace returns the sum of the diagonal elements of the
2090
+ matrix mtx .
2091
+ \f[\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\f]
2092
+ @param mtx input matrix.
2093
+ */
2094
+ CV_EXPORTS_W Scalar trace(InputArray mtx);
2095
+
2096
+ /** @brief Finds the inverse or pseudo-inverse of a matrix.
2097
+
2098
+ The function cv::invert inverts the matrix src and stores the result in dst
2099
+ . When the matrix src is singular or non-square, the function calculates
2100
+ the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
2101
+ minimal, where I is an identity matrix.
2102
+
2103
+ In case of the #DECOMP_LU method, the function returns non-zero value if
2104
+ the inverse has been successfully calculated and 0 if src is singular.
2105
+
2106
+ In case of the #DECOMP_SVD method, the function returns the inverse
2107
+ condition number of src (the ratio of the smallest singular value to the
2108
+ largest singular value) and 0 if src is singular. The SVD method
2109
+ calculates a pseudo-inverse matrix if src is singular.
2110
+
2111
+ Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
2112
+ non-singular square matrices that should also be symmetrical and
2113
+ positively defined. In this case, the function stores the inverted
2114
+ matrix in dst and returns non-zero. Otherwise, it returns 0.
2115
+
2116
+ @param src input floating-point M x N matrix.
2117
+ @param dst output matrix of N x M size and the same type as src.
2118
+ @param flags inversion method (cv::DecompTypes)
2119
+ @sa solve, SVD
2120
+ */
2121
+ CV_EXPORTS_W double invert(InputArray src, OutputArray dst,
2122
+ int flags = DECOMP_LU);
2123
+
2124
+ /** @brief Solves one or more linear systems or least-squares problems.
2125
+
2126
+ The function cv::solve solves a linear system or least-squares problem (the
2127
+ latter is possible with SVD or QR methods, or by specifying the flag
2128
+ #DECOMP_NORMAL ):
2129
+ \f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} -
2130
+ \texttt{src2} \|\f]
2131
+
2132
+ If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
2133
+ if src1 (or \f$\texttt{src1}^T\texttt{src1}\f$ ) is non-singular. Otherwise,
2134
+ it returns 0. In the latter case, dst is not valid. Other methods find a
2135
+ pseudo-solution in case of a singular left-hand side part.
2136
+
2137
+ @note If you want to find a unity-norm solution of an under-defined
2138
+ singular system \f$\texttt{src1}\cdot\texttt{dst}=0\f$ , the function solve
2139
+ will not do the work. Use SVD::solveZ instead.
2140
+
2141
+ @param src1 input matrix on the left-hand side of the system.
2142
+ @param src2 input matrix on the right-hand side of the system.
2143
+ @param dst output solution.
2144
+ @param flags solution (matrix inversion) method (#DecompTypes)
2145
+ @sa invert, SVD, eigen
2146
+ */
2147
+ CV_EXPORTS_W bool solve(InputArray src1, InputArray src2, OutputArray dst,
2148
+ int flags = DECOMP_LU);
2149
+
2150
+ /** @brief Sorts each row or each column of a matrix.
2151
+
2152
+ The function cv::sort sorts each matrix row or each matrix column in
2153
+ ascending or descending order. So you should pass two operation flags to
2154
+ get desired behaviour. If you want to sort matrix rows or columns
2155
+ lexicographically, you can use STL std::sort generic function with the
2156
+ proper comparison predicate.
2157
+
2158
+ @param src input single-channel array.
2159
+ @param dst output array of the same size and type as src.
2160
+ @param flags operation flags, a combination of #SortFlags
2161
+ @sa sortIdx, randShuffle
2162
+ */
2163
+ CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags);
2164
+
2165
+ /** @brief Sorts each row or each column of a matrix.
2166
+
2167
+ The function cv::sortIdx sorts each matrix row or each matrix column in the
2168
+ ascending or descending order. So you should pass two operation flags to
2169
+ get desired behaviour. Instead of reordering the elements themselves, it
2170
+ stores the indices of sorted elements in the output array. For example:
2171
+ @code
2172
+ Mat A = Mat::eye(3,3,CV_32F), B;
2173
+ sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
2174
+ // B will probably contain
2175
+ // (because of equal elements in A some permutations are possible):
2176
+ // [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
2177
+ @endcode
2178
+ @param src input single-channel array.
2179
+ @param dst output integer array of the same size as src.
2180
+ @param flags operation flags that could be a combination of cv::SortFlags
2181
+ @sa sort, randShuffle
2182
+ */
2183
+ CV_EXPORTS_W void sortIdx(InputArray src, OutputArray dst, int flags);
2184
+
2185
+ /** @brief Finds the real roots of a cubic equation.
2186
+
2187
+ The function solveCubic finds the real roots of a cubic equation:
2188
+ - if coeffs is a 4-element vector:
2189
+ \f[\texttt{coeffs} [0] x^3 + \texttt{coeffs} [1] x^2 + \texttt{coeffs} [2] x +
2190
+ \texttt{coeffs} [3] = 0\f]
2191
+ - if coeffs is a 3-element vector:
2192
+ \f[x^3 + \texttt{coeffs} [0] x^2 + \texttt{coeffs} [1] x + \texttt{coeffs}
2193
+ [2] = 0\f]
2194
+
2195
+ The roots are stored in the roots array.
2196
+ @param coeffs equation coefficients, an array of 3 or 4 elements.
2197
+ @param roots output array of real roots that has 1 or 3 elements.
2198
+ @return number of real roots. It can be 0, 1 or 2.
2199
+ */
2200
+ CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots);
2201
+
2202
+ /** @brief Finds the real or complex roots of a polynomial equation.
2203
+
2204
+ The function cv::solvePoly finds real and complex roots of a polynomial
2205
+ equation:
2206
+ \f[\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... +
2207
+ \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\f]
2208
+ @param coeffs array of polynomial coefficients.
2209
+ @param roots output (complex) array of roots.
2210
+ @param maxIters maximum number of iterations the algorithm does.
2211
+ */
2212
+ CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots,
2213
+ int maxIters = 300);
2214
+
2215
+ /** @brief Calculates eigenvalues and eigenvectors of a symmetric matrix.
2216
+
2217
+ The function cv::eigen calculates just eigenvalues, or eigenvalues and
2218
+ eigenvectors of the symmetric matrix src:
2219
+ @code
2220
+ src*eigenvectors.row(i).t() =
2221
+ eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
2222
+ @endcode
2223
+
2224
+ @note Use cv::eigenNonSymmetric for calculation of real eigenvalues and
2225
+ eigenvectors of non-symmetric matrix.
2226
+
2227
+ @param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size
2228
+ and be symmetrical (src ^T^ == src).
2229
+ @param eigenvalues output vector of eigenvalues of the same type as src; the
2230
+ eigenvalues are stored in the descending order.
2231
+ @param eigenvectors output matrix of eigenvectors; it has the same size and type
2232
+ as src; the eigenvectors are stored as subsequent matrix rows, in the same order
2233
+ as the corresponding eigenvalues.
2234
+ @sa eigenNonSymmetric, completeSymm, PCA
2235
+ */
2236
+ CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues,
2237
+ OutputArray eigenvectors = noArray());
2238
+
2239
+ /** @brief Calculates eigenvalues and eigenvectors of a non-symmetric matrix
2240
+ (real eigenvalues only).
2241
+
2242
+ @note Assumes real eigenvalues.
2243
+
2244
+ The function calculates eigenvalues and eigenvectors (optional) of the square
2245
+ matrix src:
2246
+ @code
2247
+ src*eigenvectors.row(i).t() =
2248
+ eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
2249
+ @endcode
2250
+
2251
+ @param src input matrix (CV_32FC1 or CV_64FC1 type).
2252
+ @param eigenvalues output vector of eigenvalues (type is the same type as src).
2253
+ @param eigenvectors output matrix of eigenvectors (type is the same type as
2254
+ src). The eigenvectors are stored as subsequent matrix rows, in the same order
2255
+ as the corresponding eigenvalues.
2256
+ @sa eigen
2257
+ */
2258
+ CV_EXPORTS_W void eigenNonSymmetric(InputArray src, OutputArray eigenvalues,
2259
+ OutputArray eigenvectors);
2260
+
2261
+ /** @brief Calculates the covariance matrix of a set of vectors.
2262
+
2263
+ The function cv::calcCovarMatrix calculates the covariance matrix and,
2264
+ optionally, the mean vector of the set of input vectors.
2265
+ @param samples samples stored as separate matrices
2266
+ @param nsamples number of samples
2267
+ @param covar output covariance matrix of the type ctype and square size.
2268
+ @param mean input or output (depending on the flags) array as the average value
2269
+ of the input vectors.
2270
+ @param flags operation flags as a combination of #CovarFlags
2271
+ @param ctype type of the matrixl; it equals 'CV_64F' by default.
2272
+ @sa PCA, mulTransposed, Mahalanobis
2273
+ @todo InputArrayOfArrays
2274
+ */
2275
+ CV_EXPORTS void calcCovarMatrix(const Mat *samples, int nsamples, Mat &covar,
2276
+ Mat &mean, int flags, int ctype = CV_64F);
2277
+
2278
+ /** @overload
2279
+ @note use #COVAR_ROWS or #COVAR_COLS flag
2280
+ @param samples samples stored as rows/columns of a single matrix.
2281
+ @param covar output covariance matrix of the type ctype and square size.
2282
+ @param mean input or output (depending on the flags) array as the average value
2283
+ of the input vectors.
2284
+ @param flags operation flags as a combination of #CovarFlags
2285
+ @param ctype type of the matrixl; it equals 'CV_64F' by default.
2286
+ */
2287
+ CV_EXPORTS_W void calcCovarMatrix(InputArray samples, OutputArray covar,
2288
+ InputOutputArray mean, int flags,
2289
+ int ctype = CV_64F);
2290
+
2291
+ /** wrap PCA::operator() */
2292
+ CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
2293
+ OutputArray eigenvectors, int maxComponents = 0);
2294
+
2295
+ /** wrap PCA::operator() and add eigenvalues output parameter */
2296
+ CV_EXPORTS_AS(PCACompute2)
2297
+ void PCACompute(InputArray data, InputOutputArray mean,
2298
+ OutputArray eigenvectors, OutputArray eigenvalues,
2299
+ int maxComponents = 0);
2300
+
2301
+ /** wrap PCA::operator() */
2302
+ CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
2303
+ OutputArray eigenvectors, double retainedVariance);
2304
+
2305
+ /** wrap PCA::operator() and add eigenvalues output parameter */
2306
+ CV_EXPORTS_AS(PCACompute2)
2307
+ void PCACompute(InputArray data, InputOutputArray mean,
2308
+ OutputArray eigenvectors, OutputArray eigenvalues,
2309
+ double retainedVariance);
2310
+
2311
+ /** wrap PCA::project */
2312
+ CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean,
2313
+ InputArray eigenvectors, OutputArray result);
2314
+
2315
+ /** wrap PCA::backProject */
2316
+ CV_EXPORTS_W void PCABackProject(InputArray data, InputArray mean,
2317
+ InputArray eigenvectors, OutputArray result);
2318
+
2319
+ /** wrap SVD::compute */
2320
+ CV_EXPORTS_W void SVDecomp(InputArray src, OutputArray w, OutputArray u,
2321
+ OutputArray vt, int flags = 0);
2322
+
2323
+ /** wrap SVD::backSubst */
2324
+ CV_EXPORTS_W void SVBackSubst(InputArray w, InputArray u, InputArray vt,
2325
+ InputArray rhs, OutputArray dst);
2326
+
2327
+ /** @brief Calculates the Mahalanobis distance between two vectors.
2328
+
2329
+ The function cv::Mahalanobis calculates and returns the weighted distance
2330
+ between two vectors:
2331
+ \f[d( \texttt{vec1} , \texttt{vec2} )=
2332
+ \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})}
2333
+ }\f] The covariance matrix may be calculated using the #calcCovarMatrix function
2334
+ and then inverted using the invert function (preferably using the #DECOMP_SVD
2335
+ method, as the most accurate).
2336
+ @param v1 first 1D input vector.
2337
+ @param v2 second 1D input vector.
2338
+ @param icovar inverse covariance matrix.
2339
+ */
2340
+ CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2,
2341
+ InputArray icovar);
2342
+
2343
+ /** @brief Performs a forward or inverse Discrete Fourier transform of a 1D or
2344
+ 2D floating-point array.
2345
+
2346
+ The function cv::dft performs one of the following:
2347
+ - Forward the Fourier transform of a 1D vector of N elements:
2348
+ \f[Y = F^{(N)} \cdot X,\f]
2349
+ where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$
2350
+ - Inverse the Fourier transform of a 1D vector of N elements:
2351
+ \f[\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left
2352
+ (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\f] where
2353
+ \f$F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\f$
2354
+ - Forward the 2D Fourier transform of a M x N matrix:
2355
+ \f[Y = F^{(M)} \cdot X \cdot F^{(N)}\f]
2356
+ - Inverse the 2D Fourier transform of a M x N matrix:
2357
+ \f[\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left
2358
+ (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\f]
2359
+
2360
+ In case of real (single-channel) data, the output spectrum of the forward
2361
+ Fourier transform or input spectrum of the inverse Fourier transform can be
2362
+ represented in a packed format called *CCS* (complex-conjugate-symmetrical). It
2363
+ was borrowed from IPL (Intel\* Image Processing Library). Here is how 2D *CCS*
2364
+ spectrum looks:
2365
+ \f[\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im
2366
+ Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re
2367
+ Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re
2368
+ Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im
2369
+ Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} &
2370
+ Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1}
2371
+ & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im
2372
+ Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} &
2373
+ Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im
2374
+ Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2}
2375
+ \end{bmatrix}\f]
2376
+
2377
+ In case of 1D transform of a real vector, the output looks like the first row of
2378
+ the matrix above.
2379
+
2380
+ So, the function chooses an operation mode depending on the flags and size of
2381
+ the input array:
2382
+ - If #DFT_ROWS is set or the input array has a single row or single column,
2383
+ the function performs a 1D forward or inverse transform of each row of a matrix
2384
+ when #DFT_ROWS is set. Otherwise, it performs a 2D transform.
2385
+ - If the input array is real and #DFT_INVERSE is not set, the function
2386
+ performs a forward 1D or 2D transform:
2387
+ - When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the
2388
+ same size as input.
2389
+ - When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the
2390
+ same size as input. In case of 2D transform, it uses the packed format as shown
2391
+ above. In case of a single 1D transform, it looks like the first row of the
2392
+ matrix above. In case of multiple 1D transforms (when using the #DFT_ROWS flag),
2393
+ each row of the output matrix looks like the first row of the matrix above.
2394
+ - If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT
2395
+ are not set, the output is a complex array of the same size as input. The
2396
+ function performs a forward or inverse 1D or 2D transform of the whole input
2397
+ array or each row of the input array independently, depending on the flags
2398
+ DFT_INVERSE and DFT_ROWS.
2399
+ - When #DFT_INVERSE is set and the input array is real, or it is complex but
2400
+ #DFT_REAL_OUTPUT is set, the output is a real array of the same size as input.
2401
+ The function performs a 1D or 2D inverse transformation of the whole input array
2402
+ or each individual row, depending on the flags #DFT_INVERSE and #DFT_ROWS.
2403
+
2404
+ If #DFT_SCALE is set, the scaling is done after the transformation.
2405
+
2406
+ Unlike dct, the function supports arrays of arbitrary size. But only those
2407
+ arrays are processed efficiently, whose sizes can be factorized in a product of
2408
+ small prime numbers (2, 3, and 5 in the current implementation). Such an
2409
+ efficient DFT size can be calculated using the getOptimalDFTSize method.
2410
+
2411
+ The sample below illustrates how to calculate a DFT-based convolution of two 2D
2412
+ real arrays:
2413
+ @code
2414
+ void convolveDFT(InputArray A, InputArray B, OutputArray C)
2415
+ {
2416
+ // reallocate the output array if needed
2417
+ C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
2418
+ Size dftSize;
2419
+ // calculate the size of DFT transform
2420
+ dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
2421
+ dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
2422
+
2423
+ // allocate temporary buffers and initialize them with 0's
2424
+ Mat tempA(dftSize, A.type(), Scalar::all(0));
2425
+ Mat tempB(dftSize, B.type(), Scalar::all(0));
2426
+
2427
+ // copy A and B to the top-left corners of tempA and tempB, respectively
2428
+ Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
2429
+ A.copyTo(roiA);
2430
+ Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
2431
+ B.copyTo(roiB);
2432
+
2433
+ // now transform the padded A & B in-place;
2434
+ // use "nonzeroRows" hint for faster processing
2435
+ dft(tempA, tempA, 0, A.rows);
2436
+ dft(tempB, tempB, 0, B.rows);
2437
+
2438
+ // multiply the spectrums;
2439
+ // the function handles packed spectrum representations well
2440
+ mulSpectrums(tempA, tempB, tempA);
2441
+
2442
+ // transform the product back from the frequency domain.
2443
+ // Even though all the result rows will be non-zero,
2444
+ // you need only the first C.rows of them, and thus you
2445
+ // pass nonzeroRows == C.rows
2446
+ dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
2447
+
2448
+ // now copy the result back to C.
2449
+ tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
2450
+
2451
+ // all the temporary buffers will be deallocated automatically
2452
+ }
2453
+ @endcode
2454
+ To optimize this sample, consider the following approaches:
2455
+ - Since nonzeroRows != 0 is passed to the forward transform calls and since A
2456
+ and B are copied to the top-left corners of tempA and tempB, respectively, it is
2457
+ not necessary to clear the whole tempA and tempB. It is only necessary to clear
2458
+ the tempA.cols - A.cols ( tempB.cols - B.cols) rightmost columns of the
2459
+ matrices.
2460
+ - This DFT-based convolution does not have to be applied to the whole big
2461
+ arrays, especially if B is significantly smaller than A or vice versa. Instead,
2462
+ you can calculate convolution by parts. To do this, you need to split the output
2463
+ array C into multiple tiles. For each tile, estimate which parts of A and B are
2464
+ required to calculate convolution in this tile. If the tiles in C are too small,
2465
+ the speed will decrease a lot because of repeated work. In the ultimate case,
2466
+ when each tile in C is a single pixel, the algorithm becomes equivalent to the
2467
+ naive convolution algorithm. If the tiles are too big, the temporary arrays
2468
+ tempA and tempB become too big and there is also a slowdown because of bad cache
2469
+ locality. So, there is an optimal tile size somewhere in the middle.
2470
+ - If different tiles in C can be calculated in parallel and, thus, the
2471
+ convolution is done by parts, the loop can be threaded.
2472
+
2473
+ All of the above improvements have been implemented in #matchTemplate and
2474
+ #filter2D . Therefore, by using them, you can get the performance even better
2475
+ than with the above theoretically optimal implementation. Though, those two
2476
+ functions actually calculate cross-correlation, not convolution, so you need to
2477
+ "flip" the second convolution operand B vertically and horizontally using flip .
2478
+ @note
2479
+ - An example using the discrete fourier transform can be found at
2480
+ opencv_source_code/samples/cpp/dft.cpp
2481
+ - (Python) An example using the dft functionality to perform Wiener
2482
+ deconvolution can be found at opencv_source/samples/python/deconvolution.py
2483
+ - (Python) An example rearranging the quadrants of a Fourier image can be
2484
+ found at opencv_source/samples/python/dft.py
2485
+ @param src input array that could be real or complex.
2486
+ @param dst output array whose size and type depends on the flags .
2487
+ @param flags transformation flags, representing a combination of the #DftFlags
2488
+ @param nonzeroRows when the parameter is not zero, the function assumes that
2489
+ only the first nonzeroRows rows of the input array (#DFT_INVERSE is not set) or
2490
+ only the first nonzeroRows of the output array (#DFT_INVERSE is set) contain
2491
+ non-zeros, thus, the function can handle the rest of the rows more efficiently
2492
+ and save some time; this technique is very useful for calculating array
2493
+ cross-correlation or convolution using DFT.
2494
+ @sa dct, getOptimalDFTSize, mulSpectrums, filter2D, matchTemplate, flip,
2495
+ cartToPolar, magnitude, phase
2496
+ */
2497
+ CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0,
2498
+ int nonzeroRows = 0);
2499
+
2500
+ /** @brief Calculates the inverse Discrete Fourier Transform of a 1D or 2D
2501
+ array.
2502
+
2503
+ idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
2504
+ @note None of dft and idft scales the result by default. So, you should pass
2505
+ #DFT_SCALE to one of dft or idft explicitly to make these transforms mutually
2506
+ inverse.
2507
+ @sa dft, dct, idct, mulSpectrums, getOptimalDFTSize
2508
+ @param src input floating-point real or complex array.
2509
+ @param dst output array whose size and type depend on the flags.
2510
+ @param flags operation flags (see dft and #DftFlags).
2511
+ @param nonzeroRows number of dst rows to process; the rest of the rows have
2512
+ undefined content (see the convolution sample in dft description.
2513
+ */
2514
+ CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags = 0,
2515
+ int nonzeroRows = 0);
2516
+
2517
+ /** @brief Performs a forward or inverse discrete Cosine transform of 1D or 2D
2518
+ array.
2519
+
2520
+ The function cv::dct performs a forward or inverse discrete Cosine transform
2521
+ (DCT) of a 1D or 2D floating-point array:
2522
+ - Forward Cosine transform of a 1D vector of N elements:
2523
+ \f[Y = C^{(N)} \cdot X\f]
2524
+ where
2525
+ \f[C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right
2526
+ )\f] and
2527
+ \f$\alpha_0=1\f$, \f$\alpha_j=2\f$ for *j \> 0*.
2528
+ - Inverse Cosine transform of a 1D vector of N elements:
2529
+ \f[X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T
2530
+ \cdot Y\f] (since \f$C^{(N)}\f$ is an orthogonal matrix, \f$C^{(N)} \cdot
2531
+ \left(C^{(N)}\right)^T = I\f$ )
2532
+ - Forward 2D Cosine transform of M x N matrix:
2533
+ \f[Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\f]
2534
+ - Inverse 2D Cosine transform of M x N matrix:
2535
+ \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f]
2536
+
2537
+ The function chooses the mode of operation by looking at the flags and size of
2538
+ the input array:
2539
+ - If (flags & #DCT_INVERSE) == 0, the function does a forward 1D or 2D
2540
+ transform. Otherwise, it is an inverse 1D or 2D transform.
2541
+ - If (flags & #DCT_ROWS) != 0, the function performs a 1D transform of each
2542
+ row.
2543
+ - If the array is a single column or a single row, the function performs a 1D
2544
+ transform.
2545
+ - If none of the above is true, the function performs a 2D transform.
2546
+
2547
+ @note Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis
2548
+ and approximation, you can pad the array when necessary. Also, the function
2549
+ performance depends very much, and not monotonically, on the array size (see
2550
+ getOptimalDFTSize ). In the current implementation DCT of a vector of size N is
2551
+ calculated via DFT of a vector of size N/2 . Thus, the optimal DCT size N1 \>= N
2552
+ can be calculated as:
2553
+ @code
2554
+ size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
2555
+ N1 = getOptimalDCTSize(N);
2556
+ @endcode
2557
+ @param src input floating-point array.
2558
+ @param dst output array of the same size and type as src .
2559
+ @param flags transformation flags as a combination of cv::DftFlags (DCT_*)
2560
+ @sa dft, getOptimalDFTSize, idct
2561
+ */
2562
+ CV_EXPORTS_W void dct(InputArray src, OutputArray dst, int flags = 0);
2563
+
2564
+ /** @brief Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.
2565
+
2566
+ idct(src, dst, flags) is equivalent to dct(src, dst, flags | DCT_INVERSE).
2567
+ @param src input floating-point single-channel array.
2568
+ @param dst output array of the same size and type as src.
2569
+ @param flags operation flags.
2570
+ @sa dct, dft, idft, getOptimalDFTSize
2571
+ */
2572
+ CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags = 0);
2573
+
2574
+ /** @brief Performs the per-element multiplication of two Fourier spectrums.
2575
+
2576
+ The function cv::mulSpectrums performs the per-element multiplication of the two
2577
+ CCS-packed or complex matrices that are results of a real or complex Fourier
2578
+ transform.
2579
+
2580
+ The function, together with dft and idft, may be used to calculate convolution
2581
+ (pass conjB=false ) or correlation (pass conjB=true ) of two arrays rapidly.
2582
+ When the arrays are complex, they are simply multiplied (per element) with an
2583
+ optional conjugation of the second-array elements. When the arrays are real,
2584
+ they are assumed to be CCS-packed (see dft for details).
2585
+ @param a first input array.
2586
+ @param b second input array of the same size and type as src1 .
2587
+ @param c output array of the same size and type as src1 .
2588
+ @param flags operation flags; currently, the only supported flag is
2589
+ cv::DFT_ROWS, which indicates that each row of src1 and src2 is an independent
2590
+ 1D Fourier spectrum. If you do not want to use this flag, then simply add a `0`
2591
+ as value.
2592
+ @param conjB optional flag that conjugates the second input array before the
2593
+ multiplication (true) or not (false).
2594
+ */
2595
+ CV_EXPORTS_W void mulSpectrums(InputArray a, InputArray b, OutputArray c,
2596
+ int flags, bool conjB = false);
2597
+
2598
+ /** @brief Returns the optimal DFT size for a given vector size.
2599
+
2600
+ DFT performance is not a monotonic function of a vector size. Therefore, when
2601
+ you calculate convolution of two arrays or perform the spectral analysis of an
2602
+ array, it usually makes sense to pad the input data with zeros to get a bit
2603
+ larger array that can be transformed much faster than the original one. Arrays
2604
+ whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the fastest to process.
2605
+ Though, the arrays whose size is a product of 2's, 3's, and 5's (for example,
2606
+ 300 = 5\*5\*3\*2\*2) are also processed quite efficiently.
2607
+
2608
+ The function cv::getOptimalDFTSize returns the minimum number N that is greater
2609
+ than or equal to vecsize so that the DFT of a vector of size N can be processed
2610
+ efficiently. In the current implementation N = 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some
2611
+ integer p, q, r.
2612
+
2613
+ The function returns a negative number if vecsize is too large (very close to
2614
+ INT_MAX ).
2615
+
2616
+ While the function cannot be used directly to estimate the optimal vector size
2617
+ for DCT transform (since the current DCT implementation supports only even-size
2618
+ vectors), it can be easily processed as getOptimalDFTSize((vecsize+1)/2)\*2.
2619
+ @param vecsize vector size.
2620
+ @sa dft, dct, idft, idct, mulSpectrums
2621
+ */
2622
+ CV_EXPORTS_W int getOptimalDFTSize(int vecsize);
2623
+
2624
+ /** @brief Returns the default random number generator.
2625
+
2626
+ The function cv::theRNG returns the default random number generator. For each
2627
+ thread, there is a separate random number generator, so you can use the function
2628
+ safely in multi-thread environments. If you just need to get a single random
2629
+ number using this generator or initialize an array, you can use randu or randn
2630
+ instead. But if you are going to generate many random numbers inside a loop, it
2631
+ is much faster to use this function to retrieve the generator and then use
2632
+ RNG::operator _Tp() .
2633
+ @sa RNG, randu, randn
2634
+ */
2635
+ CV_EXPORTS RNG &theRNG();
2636
+
2637
+ /** @brief Sets state of default random number generator.
2638
+
2639
+ The function cv::setRNGSeed sets state of default random number generator to
2640
+ custom value.
2641
+ @param seed new state for default random number generator
2642
+ @sa RNG, randu, randn
2643
+ */
2644
+ CV_EXPORTS_W void setRNGSeed(int seed);
2645
+
2646
+ /** @brief Generates a single uniformly-distributed random number or an array of
2647
+ random numbers.
2648
+
2649
+ Non-template variant of the function fills the matrix dst with
2650
+ uniformly-distributed random numbers from the specified range:
2651
+ \f[\texttt{low} _c \leq \texttt{dst} (I)_c < \texttt{high} _c\f]
2652
+ @param dst output array of random numbers; the array must be pre-allocated.
2653
+ @param low inclusive lower boundary of the generated random numbers.
2654
+ @param high exclusive upper boundary of the generated random numbers.
2655
+ @sa RNG, randn, theRNG
2656
+ */
2657
+ CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high);
2658
+
2659
+ /** @brief Fills the array with normally distributed random numbers.
2660
+
2661
+ The function cv::randn fills the matrix dst with normally distributed random
2662
+ numbers with the specified mean vector and the standard deviation matrix. The
2663
+ generated random numbers are clipped to fit the value range of the output array
2664
+ data type.
2665
+ @param dst output array of random numbers; the array must be pre-allocated and
2666
+ have 1 to 4 channels.
2667
+ @param mean mean value (expectation) of the generated random numbers.
2668
+ @param stddev standard deviation of the generated random numbers; it can be
2669
+ either a vector (in which case a diagonal standard deviation matrix is assumed)
2670
+ or a square matrix.
2671
+ @sa RNG, randu
2672
+ */
2673
+ CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean,
2674
+ InputArray stddev);
2675
+
2676
+ /** @brief Shuffles the array elements randomly.
2677
+
2678
+ The function cv::randShuffle shuffles the specified 1D array by randomly
2679
+ choosing pairs of elements and swapping them. The number of such swap operations
2680
+ will be dst.rows\*dst.cols\*iterFactor .
2681
+ @param dst input/output numerical 1D array.
2682
+ @param iterFactor scale factor that determines the number of random swap
2683
+ operations (see the details below).
2684
+ @param rng optional random number generator used for shuffling; if it is zero,
2685
+ theRNG () is used instead.
2686
+ @sa RNG, sort
2687
+ */
2688
+ CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1.,
2689
+ RNG *rng = 0);
2690
+
2691
+ /** @brief Principal Component Analysis
2692
+
2693
+ The class is used to calculate a special basis for a set of vectors. The
2694
+ basis will consist of eigenvectors of the covariance matrix calculated
2695
+ from the input set of vectors. The class %PCA can also transform
2696
+ vectors to/from the new coordinate space defined by the basis. Usually,
2697
+ in this new coordinate system, each vector from the original set (and
2698
+ any linear combination of such vectors) can be quite accurately
2699
+ approximated by taking its first few components, corresponding to the
2700
+ eigenvectors of the largest eigenvalues of the covariance matrix.
2701
+ Geometrically it means that you calculate a projection of the vector to
2702
+ a subspace formed by a few eigenvectors corresponding to the dominant
2703
+ eigenvalues of the covariance matrix. And usually such a projection is
2704
+ very close to the original vector. So, you can represent the original
2705
+ vector from a high-dimensional space with a much shorter vector
2706
+ consisting of the projected vector's coordinates in the subspace. Such a
2707
+ transformation is also known as Karhunen-Loeve Transform, or KLT.
2708
+ See http://en.wikipedia.org/wiki/Principal_component_analysis
2709
+
2710
+ The sample below is the function that takes two matrices. The first
2711
+ function stores a set of vectors (a row per vector) that is used to
2712
+ calculate PCA. The second function stores another "test" set of vectors
2713
+ (a row per vector). First, these vectors are compressed with PCA, then
2714
+ reconstructed back, and then the reconstruction error norm is computed
2715
+ and printed for each vector. :
2716
+
2717
+ @code{.cpp}
2718
+ using namespace cv;
2719
+
2720
+ PCA compressPCA(const Mat& pcaset, int maxComponents,
2721
+ const Mat& testset, Mat& compressed)
2722
+ {
2723
+ PCA pca(pcaset, // pass the data
2724
+ Mat(), // we do not have a pre-computed mean vector,
2725
+ // so let the PCA engine to compute it
2726
+ PCA::DATA_AS_ROW, // indicate that the vectors
2727
+ // are stored as matrix rows
2728
+ // (use PCA::DATA_AS_COL if the vectors are
2729
+ // the matrix columns)
2730
+ maxComponents // specify, how many principal components to retain
2731
+ );
2732
+ // if there is no test data, just return the computed basis, ready-to-use
2733
+ if( !testset.data )
2734
+ return pca;
2735
+ CV_Assert( testset.cols == pcaset.cols );
2736
+
2737
+ compressed.create(testset.rows, maxComponents, testset.type());
2738
+
2739
+ Mat reconstructed;
2740
+ for( int i = 0; i < testset.rows; i++ )
2741
+ {
2742
+ Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed;
2743
+ // compress the vector, the result will be stored
2744
+ // in the i-th row of the output matrix
2745
+ pca.project(vec, coeffs);
2746
+ // and then reconstruct it
2747
+ pca.backProject(coeffs, reconstructed);
2748
+ // and measure the error
2749
+ printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2));
2750
+ }
2751
+ return pca;
2752
+ }
2753
+ @endcode
2754
+ @sa calcCovarMatrix, mulTransposed, SVD, dft, dct
2755
+ */
2756
+ class CV_EXPORTS PCA {
2757
+ public:
2758
+ enum Flags {
2759
+ DATA_AS_ROW =
2760
+ 0, //!< indicates that the input samples are stored as matrix rows
2761
+ DATA_AS_COL =
2762
+ 1, //!< indicates that the input samples are stored as matrix columns
2763
+ USE_AVG = 2 //!
2764
+ };
2765
+
2766
+ /** @brief default constructor
2767
+
2768
+ The default constructor initializes an empty %PCA structure. The other
2769
+ constructors initialize the structure and call PCA::operator()().
2770
+ */
2771
+ PCA();
2772
+
2773
+ /** @overload
2774
+ @param data input samples stored as matrix rows or matrix columns.
2775
+ @param mean optional mean value; if the matrix is empty (@c noArray()),
2776
+ the mean is computed from the data.
2777
+ @param flags operation flags; currently the parameter is only used to
2778
+ specify the data layout (PCA::Flags)
2779
+ @param maxComponents maximum number of components that %PCA should
2780
+ retain; by default, all the components are retained.
2781
+ */
2782
+ PCA(InputArray data, InputArray mean, int flags, int maxComponents = 0);
2783
+
2784
+ /** @overload
2785
+ @param data input samples stored as matrix rows or matrix columns.
2786
+ @param mean optional mean value; if the matrix is empty (noArray()),
2787
+ the mean is computed from the data.
2788
+ @param flags operation flags; currently the parameter is only used to
2789
+ specify the data layout (PCA::Flags)
2790
+ @param retainedVariance Percentage of variance that PCA should retain.
2791
+ Using this parameter will let the PCA decided how many components to
2792
+ retain but it will always keep at least 2.
2793
+ */
2794
+ PCA(InputArray data, InputArray mean, int flags, double retainedVariance);
2795
+
2796
+ /** @brief performs %PCA
2797
+
2798
+ The operator performs %PCA of the supplied dataset. It is safe to reuse
2799
+ the same PCA structure for multiple datasets. That is, if the structure
2800
+ has been previously used with another dataset, the existing internal
2801
+ data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref
2802
+ mean are allocated and computed.
2803
+
2804
+ The computed @ref eigenvalues are sorted from the largest to the smallest and
2805
+ the corresponding @ref eigenvectors are stored as eigenvectors rows.
2806
+
2807
+ @param data input samples stored as the matrix rows or as the matrix
2808
+ columns.
2809
+ @param mean optional mean value; if the matrix is empty (noArray()),
2810
+ the mean is computed from the data.
2811
+ @param flags operation flags; currently the parameter is only used to
2812
+ specify the data layout. (Flags)
2813
+ @param maxComponents maximum number of components that PCA should
2814
+ retain; by default, all the components are retained.
2815
+ */
2816
+ PCA &operator()(InputArray data, InputArray mean, int flags,
2817
+ int maxComponents = 0);
2818
+
2819
+ /** @overload
2820
+ @param data input samples stored as the matrix rows or as the matrix
2821
+ columns.
2822
+ @param mean optional mean value; if the matrix is empty (noArray()),
2823
+ the mean is computed from the data.
2824
+ @param flags operation flags; currently the parameter is only used to
2825
+ specify the data layout. (PCA::Flags)
2826
+ @param retainedVariance Percentage of variance that %PCA should retain.
2827
+ Using this parameter will let the %PCA decided how many components to
2828
+ retain but it will always keep at least 2.
2829
+ */
2830
+ PCA &operator()(InputArray data, InputArray mean, int flags,
2831
+ double retainedVariance);
2832
+
2833
+ /** @brief Projects vector(s) to the principal component subspace.
2834
+
2835
+ The methods project one or more vectors to the principal component
2836
+ subspace, where each vector projection is represented by coefficients in
2837
+ the principal component basis. The first form of the method returns the
2838
+ matrix that the second form writes to the result. So the first form can
2839
+ be used as a part of expression while the second form can be more
2840
+ efficient in a processing loop.
2841
+ @param vec input vector(s); must have the same dimensionality and the
2842
+ same layout as the input data used at %PCA phase, that is, if
2843
+ DATA_AS_ROW are specified, then `vec.cols==data.cols`
2844
+ (vector dimensionality) and `vec.rows` is the number of vectors to
2845
+ project, and the same is true for the PCA::DATA_AS_COL case.
2846
+ */
2847
+ Mat project(InputArray vec) const;
2848
+
2849
+ /** @overload
2850
+ @param vec input vector(s); must have the same dimensionality and the
2851
+ same layout as the input data used at PCA phase, that is, if
2852
+ DATA_AS_ROW are specified, then `vec.cols==data.cols`
2853
+ (vector dimensionality) and `vec.rows` is the number of vectors to
2854
+ project, and the same is true for the PCA::DATA_AS_COL case.
2855
+ @param result output vectors; in case of PCA::DATA_AS_COL, the
2856
+ output matrix has as many columns as the number of input vectors, this
2857
+ means that `result.cols==vec.cols` and the number of rows match the
2858
+ number of principal components (for example, `maxComponents` parameter
2859
+ passed to the constructor).
2860
+ */
2861
+ void project(InputArray vec, OutputArray result) const;
2862
+
2863
+ /** @brief Reconstructs vectors from their PC projections.
2864
+
2865
+ The methods are inverse operations to PCA::project. They take PC
2866
+ coordinates of projected vectors and reconstruct the original vectors.
2867
+ Unless all the principal components have been retained, the
2868
+ reconstructed vectors are different from the originals. But typically,
2869
+ the difference is small if the number of components is large enough (but
2870
+ still much smaller than the original vector dimensionality). As a
2871
+ result, PCA is used.
2872
+ @param vec coordinates of the vectors in the principal component
2873
+ subspace, the layout and size are the same as of PCA::project output
2874
+ vectors.
2875
+ */
2876
+ Mat backProject(InputArray vec) const;
2877
+
2878
+ /** @overload
2879
+ @param vec coordinates of the vectors in the principal component
2880
+ subspace, the layout and size are the same as of PCA::project output
2881
+ vectors.
2882
+ @param result reconstructed vectors; the layout and size are the same as
2883
+ of PCA::project input vectors.
2884
+ */
2885
+ void backProject(InputArray vec, OutputArray result) const;
2886
+
2887
+ /** @brief write PCA objects
2888
+
2889
+ Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified
2890
+ FileStorage
2891
+ */
2892
+ void write(FileStorage &fs) const;
2893
+
2894
+ /** @brief load PCA objects
2895
+
2896
+ Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode
2897
+ */
2898
+ void read(const FileNode &fn);
2899
+
2900
+ Mat eigenvectors; //!< eigenvectors of the covariation matrix
2901
+ Mat eigenvalues; //!< eigenvalues of the covariation matrix
2902
+ Mat mean; //!< mean value subtracted before the projection and added after the
2903
+ //!< back projection
2904
+ };
2905
+
2906
+ /** @example samples/cpp/pca.cpp
2907
+ An example using %PCA for dimensionality reduction while maintaining an amount
2908
+ of variance
2909
+ */
2910
+
2911
+ /** @example
2912
+ samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp Check
2913
+ @ref tutorial_introduction_to_pca "the corresponding tutorial" for more details
2914
+ */
2915
+
2916
+ /**
2917
+ @brief Linear Discriminant Analysis
2918
+ @todo document this class
2919
+ */
2920
+ class CV_EXPORTS LDA {
2921
+ public:
2922
+ /** @brief constructor
2923
+ Initializes a LDA with num_components (default 0).
2924
+ */
2925
+ explicit LDA(int num_components = 0);
2926
+
2927
+ /** Initializes and performs a Discriminant Analysis with Fisher's
2928
+ Optimization Criterion on given data in src and corresponding labels
2929
+ in labels. If 0 (or less) number of components are given, they are
2930
+ automatically determined for given data in computation.
2931
+ */
2932
+ LDA(InputArrayOfArrays src, InputArray labels, int num_components = 0);
2933
+
2934
+ /** Serializes this object to a given filename.
2935
+ */
2936
+ void save(const String &filename) const;
2937
+
2938
+ /** Deserializes this object from a given filename.
2939
+ */
2940
+ void load(const String &filename);
2941
+
2942
+ /** Serializes this object to a given cv::FileStorage.
2943
+ */
2944
+ void save(FileStorage &fs) const;
2945
+
2946
+ /** Deserializes this object from a given cv::FileStorage.
2947
+ */
2948
+ void load(const FileStorage &node);
2949
+
2950
+ /** destructor
2951
+ */
2952
+ ~LDA();
2953
+
2954
+ /** Compute the discriminants for data in src (row aligned) and labels.
2955
+ */
2956
+ void compute(InputArrayOfArrays src, InputArray labels);
2957
+
2958
+ /** Projects samples into the LDA subspace.
2959
+ src may be one or more row aligned samples.
2960
+ */
2961
+ Mat project(InputArray src);
2962
+
2963
+ /** Reconstructs projections from the LDA subspace.
2964
+ src may be one or more row aligned projections.
2965
+ */
2966
+ Mat reconstruct(InputArray src);
2967
+
2968
+ /** Returns the eigenvectors of this LDA.
2969
+ */
2970
+ Mat eigenvectors() const { return _eigenvectors; }
2971
+
2972
+ /** Returns the eigenvalues of this LDA.
2973
+ */
2974
+ Mat eigenvalues() const { return _eigenvalues; }
2975
+
2976
+ static Mat subspaceProject(InputArray W, InputArray mean, InputArray src);
2977
+ static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src);
2978
+
2979
+ protected:
2980
+ int _num_components;
2981
+ Mat _eigenvectors;
2982
+ Mat _eigenvalues;
2983
+ void lda(InputArrayOfArrays src, InputArray labels);
2984
+ };
2985
+
2986
+ /** @brief Singular Value Decomposition
2987
+
2988
+ Class for computing Singular Value Decomposition of a floating-point
2989
+ matrix. The Singular Value Decomposition is used to solve least-square
2990
+ problems, under-determined linear systems, invert matrices, compute
2991
+ condition numbers, and so on.
2992
+
2993
+ If you want to compute a condition number of a matrix or an absolute value of
2994
+ its determinant, you do not need `u` and `vt`. You can pass
2995
+ flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that full-size u
2996
+ and vt must be computed, which is not necessary most of the time.
2997
+
2998
+ @sa invert, solve, eigen, determinant
2999
+ */
3000
+ class CV_EXPORTS SVD {
3001
+ public:
3002
+ enum Flags {
3003
+ /** allow the algorithm to modify the decomposed matrix; it can save space
3004
+ and speed up processing. currently ignored. */
3005
+ MODIFY_A = 1,
3006
+ /** indicates that only a vector of singular values `w` is to be processed,
3007
+ while u and vt will be set to empty matrices */
3008
+ NO_UV = 2,
3009
+ /** when the matrix is not square, by default the algorithm produces u and
3010
+ vt matrices of sufficiently large size for the further A reconstruction;
3011
+ if, however, FULL_UV flag is specified, u and vt will be full-size square
3012
+ orthogonal matrices.*/
3013
+ FULL_UV = 4
3014
+ };
3015
+
3016
+ /** @brief the default constructor
3017
+
3018
+ initializes an empty SVD structure
3019
+ */
3020
+ SVD();
3021
+
3022
+ /** @overload
3023
+ initializes an empty SVD structure and then calls SVD::operator()
3024
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
3025
+ @param flags operation flags (SVD::Flags)
3026
+ */
3027
+ SVD(InputArray src, int flags = 0);
3028
+
3029
+ /** @brief the operator that performs SVD. The previously allocated u, w and
3030
+ vt are released.
3031
+
3032
+ The operator performs the singular value decomposition of the supplied
3033
+ matrix. The u,`vt` , and the vector of singular values w are stored in
3034
+ the structure. The same SVD structure can be reused many times with
3035
+ different matrices. Each time, if needed, the previous u,`vt` , and w
3036
+ are reclaimed and the new matrices are created, which is all handled by
3037
+ Mat::create.
3038
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
3039
+ @param flags operation flags (SVD::Flags)
3040
+ */
3041
+ SVD &operator()(InputArray src, int flags = 0);
3042
+
3043
+ /** @brief decomposes matrix and stores the results to user-provided matrices
3044
+
3045
+ The methods/functions perform SVD of matrix. Unlike SVD::SVD constructor
3046
+ and SVD::operator(), they store the results to the user-provided
3047
+ matrices:
3048
+
3049
+ @code{.cpp}
3050
+ Mat A, w, u, vt;
3051
+ SVD::compute(A, w, u, vt);
3052
+ @endcode
3053
+
3054
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
3055
+ @param w calculated singular values
3056
+ @param u calculated left singular vectors
3057
+ @param vt transposed matrix of right singular vectors
3058
+ @param flags operation flags - see SVD::Flags.
3059
+ */
3060
+ static void compute(InputArray src, OutputArray w, OutputArray u,
3061
+ OutputArray vt, int flags = 0);
3062
+
3063
+ /** @overload
3064
+ computes singular values of a matrix
3065
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
3066
+ @param w calculated singular values
3067
+ @param flags operation flags - see SVD::Flags.
3068
+ */
3069
+ static void compute(InputArray src, OutputArray w, int flags = 0);
3070
+
3071
+ /** @brief performs back substitution
3072
+ */
3073
+ static void backSubst(InputArray w, InputArray u, InputArray vt,
3074
+ InputArray rhs, OutputArray dst);
3075
+
3076
+ /** @brief solves an under-determined singular linear system
3077
+
3078
+ The method finds a unit-length solution x of a singular linear system
3079
+ A\*x = 0. Depending on the rank of A, there can be no solutions, a
3080
+ single solution or an infinite number of solutions. In general, the
3081
+ algorithm solves the following problem:
3082
+ \f[dst = \arg \min _{x: \| x \| =1} \| src \cdot x \|\f]
3083
+ @param src left-hand-side matrix.
3084
+ @param dst found solution.
3085
+ */
3086
+ static void solveZ(InputArray src, OutputArray dst);
3087
+
3088
+ /** @brief performs a singular value back substitution.
3089
+
3090
+ The method calculates a back substitution for the specified right-hand
3091
+ side:
3092
+
3093
+ \f[\texttt{x} = \texttt{vt} ^T \cdot diag( \texttt{w} )^{-1} \cdot
3094
+ \texttt{u} ^T \cdot \texttt{rhs} \sim \texttt{A} ^{-1} \cdot \texttt{rhs}\f]
3095
+
3096
+ Using this technique you can either get a very accurate solution of the
3097
+ convenient linear system, or the best (in the least-squares terms)
3098
+ pseudo-solution of an overdetermined linear system.
3099
+
3100
+ @param rhs right-hand side of a linear system (u\*w\*v')\*dst = rhs to
3101
+ be solved, where A has been previously decomposed.
3102
+
3103
+ @param dst found solution of the system.
3104
+
3105
+ @note Explicit SVD with the further back substitution only makes sense
3106
+ if you need to solve many linear systems with the same left-hand side
3107
+ (for example, src ). If all you need is to solve a single system
3108
+ (possibly with multiple rhs immediately available), simply call solve
3109
+ add pass #DECOMP_SVD there. It does absolutely the same thing.
3110
+ */
3111
+ void backSubst(InputArray rhs, OutputArray dst) const;
3112
+
3113
+ /** @todo document */
3114
+ template <typename _Tp, int m, int n, int nm>
3115
+ static void compute(const Matx<_Tp, m, n> &a, Matx<_Tp, nm, 1> &w,
3116
+ Matx<_Tp, m, nm> &u, Matx<_Tp, n, nm> &vt);
3117
+
3118
+ /** @todo document */
3119
+ template <typename _Tp, int m, int n, int nm>
3120
+ static void compute(const Matx<_Tp, m, n> &a, Matx<_Tp, nm, 1> &w);
3121
+
3122
+ /** @todo document */
3123
+ template <typename _Tp, int m, int n, int nm, int nb>
3124
+ static void backSubst(const Matx<_Tp, nm, 1> &w, const Matx<_Tp, m, nm> &u,
3125
+ const Matx<_Tp, n, nm> &vt, const Matx<_Tp, m, nb> &rhs,
3126
+ Matx<_Tp, n, nb> &dst);
3127
+
3128
+ Mat u, w, vt;
3129
+ };
3130
+
3131
+ /** @brief Random Number Generator
3132
+
3133
+ Random number generator. It encapsulates the state (currently, a 64-bit
3134
+ integer) and has methods to return scalar random values and to fill
3135
+ arrays with random values. Currently it supports uniform and Gaussian
3136
+ (normal) distributions. The generator uses Multiply-With-Carry
3137
+ algorithm, introduced by G. Marsaglia (
3138
+ <http://en.wikipedia.org/wiki/Multiply-with-carry> ).
3139
+ Gaussian-distribution random numbers are generated using the Ziggurat
3140
+ algorithm ( <http://en.wikipedia.org/wiki/Ziggurat_algorithm> ),
3141
+ introduced by G. Marsaglia and W. W. Tsang.
3142
+ */
3143
+ class CV_EXPORTS RNG {
3144
+ public:
3145
+ enum { UNIFORM = 0, NORMAL = 1 };
3146
+
3147
+ /** @brief constructor
3148
+
3149
+ These are the RNG constructors. The first form sets the state to some
3150
+ pre-defined value, equal to 2\*\*32-1 in the current implementation. The
3151
+ second form sets the state to the specified value. If you passed state=0
3152
+ , the constructor uses the above default value instead to avoid the
3153
+ singular random number sequence, consisting of all zeros.
3154
+ */
3155
+ RNG();
3156
+ /** @overload
3157
+ @param state 64-bit value used to initialize the RNG.
3158
+ */
3159
+ RNG(uint64 state);
3160
+ /**The method updates the state using the MWC algorithm and returns the
3161
+ next 32-bit random number.*/
3162
+ unsigned next();
3163
+
3164
+ /**Each of the methods updates the state using the MWC algorithm and
3165
+ returns the next random number of the specified type. In case of integer
3166
+ types, the returned number is from the available value range for the
3167
+ specified type. In case of floating-point types, the returned value is
3168
+ from [0,1) range.
3169
+ */
3170
+ operator uchar();
3171
+ /** @overload */
3172
+ operator schar();
3173
+ /** @overload */
3174
+ operator ushort();
3175
+ /** @overload */
3176
+ operator short();
3177
+ /** @overload */
3178
+ operator unsigned();
3179
+ /** @overload */
3180
+ operator int();
3181
+ /** @overload */
3182
+ operator float();
3183
+ /** @overload */
3184
+ operator double();
3185
+
3186
+ /** @brief returns a random integer sampled uniformly from [0, N).
3187
+
3188
+ The methods transform the state using the MWC algorithm and return the
3189
+ next random number. The first form is equivalent to RNG::next . The
3190
+ second form returns the random number modulo N, which means that the
3191
+ result is in the range [0, N) .
3192
+ */
3193
+ unsigned operator()();
3194
+ /** @overload
3195
+ @param N upper non-inclusive boundary of the returned random number.
3196
+ */
3197
+ unsigned operator()(unsigned N);
3198
+
3199
+ /** @brief returns uniformly distributed integer random number from [a,b)
3200
+ range
3201
+
3202
+ The methods transform the state using the MWC algorithm and return the
3203
+ next uniformly-distributed random number of the specified type, deduced
3204
+ from the input parameter type, from the range [a, b) . There is a nuance
3205
+ illustrated by the following sample:
3206
+
3207
+ @code{.cpp}
3208
+ RNG rng;
3209
+
3210
+ // always produces 0
3211
+ double a = rng.uniform(0, 1);
3212
+
3213
+ // produces double from [0, 1)
3214
+ double a1 = rng.uniform((double)0, (double)1);
3215
+
3216
+ // produces float from [0, 1)
3217
+ float b = rng.uniform(0.f, 1.f);
3218
+
3219
+ // produces double from [0, 1)
3220
+ double c = rng.uniform(0., 1.);
3221
+
3222
+ // may cause compiler error because of ambiguity:
3223
+ // RNG::uniform(0, (int)0.999999)? or RNG::uniform((double)0, 0.99999)?
3224
+ double d = rng.uniform(0, 0.999999);
3225
+ @endcode
3226
+
3227
+ The compiler does not take into account the type of the variable to
3228
+ which you assign the result of RNG::uniform . The only thing that
3229
+ matters to the compiler is the type of a and b parameters. So, if you
3230
+ want a floating-point random number, but the range boundaries are
3231
+ integer numbers, either put dots in the end, if they are constants, or
3232
+ use explicit type cast operators, as in the a1 initialization above.
3233
+ @param a lower inclusive boundary of the returned random number.
3234
+ @param b upper non-inclusive boundary of the returned random number.
3235
+ */
3236
+ int uniform(int a, int b);
3237
+ /** @overload */
3238
+ float uniform(float a, float b);
3239
+ /** @overload */
3240
+ double uniform(double a, double b);
3241
+
3242
+ /** @brief Fills arrays with random numbers.
3243
+
3244
+ @param mat 2D or N-dimensional matrix; currently matrices with more than
3245
+ 4 channels are not supported by the methods, use Mat::reshape as a
3246
+ possible workaround.
3247
+ @param distType distribution type, RNG::UNIFORM or RNG::NORMAL.
3248
+ @param a first distribution parameter; in case of the uniform
3249
+ distribution, this is an inclusive lower boundary, in case of the normal
3250
+ distribution, this is a mean value.
3251
+ @param b second distribution parameter; in case of the uniform
3252
+ distribution, this is a non-inclusive upper boundary, in case of the
3253
+ normal distribution, this is a standard deviation (diagonal of the
3254
+ standard deviation matrix or the full standard deviation matrix).
3255
+ @param saturateRange pre-saturation flag; for uniform distribution only;
3256
+ if true, the method will first convert a and b to the acceptable value
3257
+ range (according to the mat datatype) and then will generate uniformly
3258
+ distributed random numbers within the range [saturate(a), saturate(b)),
3259
+ if saturateRange=false, the method will generate uniformly distributed
3260
+ random numbers in the original range [a, b) and then will saturate them,
3261
+ it means, for example, that
3262
+ <tt>theRNG().fill(mat_8u, RNG::UNIFORM, -DBL_MAX, DBL_MAX)</tt> will likely
3263
+ produce array mostly filled with 0's and 255's, since the range (0, 255)
3264
+ is significantly smaller than [-DBL_MAX, DBL_MAX).
3265
+
3266
+ Each of the methods fills the matrix with the random values from the
3267
+ specified distribution. As the new numbers are generated, the RNG state
3268
+ is updated accordingly. In case of multiple-channel images, every
3269
+ channel is filled independently, which means that RNG cannot generate
3270
+ samples from the multi-dimensional Gaussian distribution with
3271
+ non-diagonal covariance matrix directly. To do that, the method
3272
+ generates samples from multi-dimensional standard Gaussian distribution
3273
+ with zero mean and identity covariation matrix, and then transforms them
3274
+ using transform to get samples from the specified Gaussian distribution.
3275
+ */
3276
+ void fill(InputOutputArray mat, int distType, InputArray a, InputArray b,
3277
+ bool saturateRange = false);
3278
+
3279
+ /** @brief Returns the next random number sampled from the Gaussian
3280
+ distribution
3281
+ @param sigma standard deviation of the distribution.
3282
+
3283
+ The method transforms the state using the MWC algorithm and returns the
3284
+ next random number from the Gaussian distribution N(0,sigma) . That is,
3285
+ the mean value of the returned random numbers is zero and the standard
3286
+ deviation is the specified sigma .
3287
+ */
3288
+ double gaussian(double sigma);
3289
+
3290
+ uint64 state;
3291
+
3292
+ bool operator==(const RNG &other) const;
3293
+ };
3294
+
3295
+ /** @brief Mersenne Twister random number generator
3296
+
3297
+ Inspired by
3298
+ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
3299
+ @todo document
3300
+ */
3301
+ class CV_EXPORTS RNG_MT19937 {
3302
+ public:
3303
+ RNG_MT19937();
3304
+ RNG_MT19937(unsigned s);
3305
+ void seed(unsigned s);
3306
+
3307
+ unsigned next();
3308
+
3309
+ operator int();
3310
+ operator unsigned();
3311
+ operator float();
3312
+ operator double();
3313
+
3314
+ unsigned operator()(unsigned N);
3315
+ unsigned operator()();
3316
+
3317
+ /** @brief returns uniformly distributed integer random number from [a,b)
3318
+ * range*/
3319
+ int uniform(int a, int b);
3320
+ /** @brief returns uniformly distributed floating-point random number from
3321
+ * [a,b) range*/
3322
+ float uniform(float a, float b);
3323
+ /** @brief returns uniformly distributed double-precision floating-point
3324
+ * random number from [a,b) range*/
3325
+ double uniform(double a, double b);
3326
+
3327
+ private:
3328
+ enum PeriodParameters { N = 624, M = 397 };
3329
+ unsigned state[N];
3330
+ int mti;
3331
+ };
3332
+
3333
+ //! @} core_array
3334
+
3335
+ //! @addtogroup core_cluster
3336
+ //! @{
3337
+
3338
+ //! k-means flags
3339
+ enum KmeansFlags {
3340
+ /** Select random initial centers in each attempt.*/
3341
+ KMEANS_RANDOM_CENTERS = 0,
3342
+ /** Use kmeans++ center initialization by Arthur and Vassilvitskii
3343
+ [Arthur2007].*/
3344
+ KMEANS_PP_CENTERS = 2,
3345
+ /** During the first (and possibly the only) attempt, use the
3346
+ user-supplied labels instead of computing them from the initial centers.
3347
+ For the second and further attempts, use the random or semi-random centers.
3348
+ Use one of KMEANS_\*_CENTERS flag to specify the exact method.*/
3349
+ KMEANS_USE_INITIAL_LABELS = 1
3350
+ };
3351
+
3352
+ /** @example samples/cpp/kmeans.cpp
3353
+ An example on k-means clustering
3354
+ */
3355
+
3356
+ /** @brief Finds centers of clusters and groups input samples around the
3357
+ clusters.
3358
+
3359
+ The function kmeans implements a k-means algorithm that finds the centers of
3360
+ cluster_count clusters and groups the input samples around the clusters. As an
3361
+ output, \f$\texttt{bestLabels}_i\f$ contains a 0-based cluster index for the
3362
+ sample stored in the \f$i^{th}\f$ row of the samples matrix.
3363
+
3364
+ @note
3365
+ - (Python) An example on k-means clustering can be found at
3366
+ opencv_source_code/samples/python/kmeans.py
3367
+ @param data Data for clustering. An array of N-Dimensional points with float
3368
+ coordinates is needed. Examples of this array can be:
3369
+ - Mat points(count, 2, CV_32F);
3370
+ - Mat points(count, 1, CV_32FC2);
3371
+ - Mat points(1, count, CV_32FC2);
3372
+ - std::vector\<cv::Point2f\> points(sampleCount);
3373
+ @param K Number of clusters to split the set by.
3374
+ @param bestLabels Input/output integer array that stores the cluster indices for
3375
+ every sample.
3376
+ @param criteria The algorithm termination criteria, that is, the maximum number
3377
+ of iterations and/or the desired accuracy. The accuracy is specified as
3378
+ criteria.epsilon. As soon as each of the cluster centers moves by less than
3379
+ criteria.epsilon on some iteration, the algorithm stops.
3380
+ @param attempts Flag to specify the number of times the algorithm is executed
3381
+ using different initial labellings. The algorithm returns the labels that yield
3382
+ the best compactness (see the last function parameter).
3383
+ @param flags Flag that can take values of cv::KmeansFlags
3384
+ @param centers Output matrix of the cluster centers, one row per each cluster
3385
+ center.
3386
+ @return The function returns the compactness measure that is computed as
3387
+ \f[\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \|
3388
+ ^2\f] after every attempt. The best (minimum) value is chosen and the
3389
+ corresponding labels and the compactness value are returned by the function.
3390
+ Basically, you can use only the core of the function, set the number of attempts
3391
+ to 1, initialize labels each time using a custom algorithm, pass them with the (
3392
+ flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
3393
+ (most-compact) clustering.
3394
+ */
3395
+ CV_EXPORTS_W double kmeans(InputArray data, int K, InputOutputArray bestLabels,
3396
+ TermCriteria criteria, int attempts, int flags,
3397
+ OutputArray centers = noArray());
3398
+
3399
+ //! @} core_cluster
3400
+
3401
+ //! @addtogroup core_basic
3402
+ //! @{
3403
+
3404
+ /////////////////////////////// Formatted output of cv::Mat
3405
+ //////////////////////////////
3406
+
3407
+ /** @todo document */
3408
+ class CV_EXPORTS Formatted {
3409
+ public:
3410
+ virtual const char *next() = 0;
3411
+ virtual void reset() = 0;
3412
+ virtual ~Formatted();
3413
+ };
3414
+
3415
+ /** @todo document */
3416
+ class CV_EXPORTS Formatter {
3417
+ public:
3418
+ enum FormatType {
3419
+ FMT_DEFAULT = 0,
3420
+ FMT_MATLAB = 1,
3421
+ FMT_CSV = 2,
3422
+ FMT_PYTHON = 3,
3423
+ FMT_NUMPY = 4,
3424
+ FMT_C = 5
3425
+ };
3426
+
3427
+ virtual ~Formatter();
3428
+
3429
+ virtual Ptr<Formatted> format(const Mat &mtx) const = 0;
3430
+
3431
+ virtual void set16fPrecision(int p = 4) = 0;
3432
+ virtual void set32fPrecision(int p = 8) = 0;
3433
+ virtual void set64fPrecision(int p = 16) = 0;
3434
+ virtual void setMultiline(bool ml = true) = 0;
3435
+
3436
+ static Ptr<Formatter> get(Formatter::FormatType fmt = FMT_DEFAULT);
3437
+ };
3438
+
3439
+ static inline String &operator<<(String &out, Ptr<Formatted> fmtd) {
3440
+ fmtd->reset();
3441
+ for (const char *str = fmtd->next(); str; str = fmtd->next())
3442
+ out += cv::String(str);
3443
+ return out;
3444
+ }
3445
+
3446
+ static inline String &operator<<(String &out, const Mat &mtx) {
3447
+ return out << Formatter::get()->format(mtx);
3448
+ }
3449
+
3450
+ //////////////////////////////////////// Algorithm
3451
+ ///////////////////////////////////////
3452
+
3453
+ class CV_EXPORTS Algorithm;
3454
+
3455
+ template <typename _Tp, typename _EnumTp = void> struct ParamType {};
3456
+
3457
+ /** @brief This is a base class for all more or less complex algorithms in
3458
+ OpenCV
3459
+
3460
+ especially for classes of algorithms, for which there can be multiple
3461
+ implementations. The examples are stereo correspondence (for which there are
3462
+ algorithms like block matching, semi-global block matching, graph-cut etc.),
3463
+ background subtraction (which can be done using mixture-of-gaussians models,
3464
+ codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade,
3465
+ Horn-Schunck etc.).
3466
+
3467
+ Here is example of SimpleBlobDetector use in your application via Algorithm
3468
+ interface:
3469
+ @snippet snippets/core_various.cpp Algorithm
3470
+ */
3471
+ class CV_EXPORTS_W Algorithm {
3472
+ public:
3473
+ Algorithm();
3474
+ virtual ~Algorithm();
3475
+
3476
+ /** @brief Clears the algorithm state
3477
+ */
3478
+ CV_WRAP virtual void clear() {}
3479
+
3480
+ /** @brief Stores algorithm parameters in a file storage
3481
+ */
3482
+ CV_WRAP virtual void write(FileStorage &fs) const { CV_UNUSED(fs); }
3483
+
3484
+ /**
3485
+ * @overload
3486
+ */
3487
+ CV_WRAP void write(FileStorage &fs, const String &name) const;
3488
+ #if CV_VERSION_MAJOR < 5
3489
+ /** @deprecated */
3490
+ void write(const Ptr<FileStorage> &fs, const String &name = String()) const;
3491
+ #endif
3492
+
3493
+ /** @brief Reads algorithm parameters from a file storage
3494
+ */
3495
+ CV_WRAP virtual void read(const FileNode &fn) { CV_UNUSED(fn); }
3496
+
3497
+ /** @brief Returns true if the Algorithm is empty (e.g. in the very beginning
3498
+ * or after unsuccessful read
3499
+ */
3500
+ CV_WRAP virtual bool empty() const { return false; }
3501
+
3502
+ /** @brief Reads algorithm from the file node
3503
+
3504
+ This is static template method of Algorithm. It's usage is following (in the
3505
+ case of SVM):
3506
+ @code
3507
+ cv::FileStorage fsRead("example.xml", FileStorage::READ);
3508
+ Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
3509
+ @endcode
3510
+ In order to make this method work, the derived class must overwrite
3511
+ Algorithm::read(const FileNode& fn) and also have static create() method
3512
+ without parameters (or with all the optional parameters)
3513
+ */
3514
+ template <typename _Tp> static Ptr<_Tp> read(const FileNode &fn) {
3515
+ Ptr<_Tp> obj = _Tp::create();
3516
+ obj->read(fn);
3517
+ return !obj->empty() ? obj : Ptr<_Tp>();
3518
+ }
3519
+
3520
+ /** @brief Loads algorithm from the file
3521
+
3522
+ @param filename Name of the file to read.
3523
+ @param objname The optional name of the node to read (if empty, the first
3524
+ top-level node will be used)
3525
+
3526
+ This is static template method of Algorithm. It's usage is following (in the
3527
+ case of SVM):
3528
+ @code
3529
+ Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
3530
+ @endcode
3531
+ In order to make this method work, the derived class must overwrite
3532
+ Algorithm::read(const FileNode& fn).
3533
+ */
3534
+ template <typename _Tp>
3535
+ static Ptr<_Tp> load(const String &filename,
3536
+ const String &objname = String()) {
3537
+ FileStorage fs(filename, FileStorage::READ);
3538
+ CV_Assert(fs.isOpened());
3539
+ FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
3540
+ if (fn.empty())
3541
+ return Ptr<_Tp>();
3542
+ Ptr<_Tp> obj = _Tp::create();
3543
+ obj->read(fn);
3544
+ return !obj->empty() ? obj : Ptr<_Tp>();
3545
+ }
3546
+
3547
+ /** @brief Loads algorithm from a String
3548
+
3549
+ @param strModel The string variable containing the model you want to load.
3550
+ @param objname The optional name of the node to read (if empty, the first
3551
+ top-level node will be used)
3552
+
3553
+ This is static template method of Algorithm. It's usage is following (in the
3554
+ case of SVM):
3555
+ @code
3556
+ Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
3557
+ @endcode
3558
+ */
3559
+ template <typename _Tp>
3560
+ static Ptr<_Tp> loadFromString(const String &strModel,
3561
+ const String &objname = String()) {
3562
+ FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
3563
+ FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
3564
+ Ptr<_Tp> obj = _Tp::create();
3565
+ obj->read(fn);
3566
+ return !obj->empty() ? obj : Ptr<_Tp>();
3567
+ }
3568
+
3569
+ /** Saves the algorithm to a file.
3570
+ In order to make this method work, the derived class must implement
3571
+ Algorithm::write(FileStorage& fs). */
3572
+ CV_WRAP virtual void save(const String &filename) const;
3573
+
3574
+ /** Returns the algorithm string identifier.
3575
+ This string is used as top level xml/yml node tag when the object is saved to
3576
+ a file or string. */
3577
+ CV_WRAP virtual String getDefaultName() const;
3578
+
3579
+ protected:
3580
+ void writeFormat(FileStorage &fs) const;
3581
+ };
3582
+
3583
+ enum struct Param {
3584
+ INT = 0,
3585
+ BOOLEAN = 1,
3586
+ REAL = 2,
3587
+ STRING = 3,
3588
+ MAT = 4,
3589
+ MAT_VECTOR = 5,
3590
+ ALGORITHM = 6,
3591
+ FLOAT = 7,
3592
+ UNSIGNED_INT = 8,
3593
+ UINT64 = 9,
3594
+ UCHAR = 11,
3595
+ SCALAR = 12
3596
+ };
3597
+
3598
+ template <> struct ParamType<bool> {
3599
+ typedef bool const_param_type;
3600
+ typedef bool member_type;
3601
+
3602
+ static const Param type = Param::BOOLEAN;
3603
+ };
3604
+
3605
+ template <> struct ParamType<int> {
3606
+ typedef int const_param_type;
3607
+ typedef int member_type;
3608
+
3609
+ static const Param type = Param::INT;
3610
+ };
3611
+
3612
+ template <> struct ParamType<double> {
3613
+ typedef double const_param_type;
3614
+ typedef double member_type;
3615
+
3616
+ static const Param type = Param::REAL;
3617
+ };
3618
+
3619
+ template <> struct ParamType<String> {
3620
+ typedef const String &const_param_type;
3621
+ typedef String member_type;
3622
+
3623
+ static const Param type = Param::STRING;
3624
+ };
3625
+
3626
+ template <> struct ParamType<Mat> {
3627
+ typedef const Mat &const_param_type;
3628
+ typedef Mat member_type;
3629
+
3630
+ static const Param type = Param::MAT;
3631
+ };
3632
+
3633
+ template <> struct ParamType<std::vector<Mat>> {
3634
+ typedef const std::vector<Mat> &const_param_type;
3635
+ typedef std::vector<Mat> member_type;
3636
+
3637
+ static const Param type = Param::MAT_VECTOR;
3638
+ };
3639
+
3640
+ template <> struct ParamType<Algorithm> {
3641
+ typedef const Ptr<Algorithm> &const_param_type;
3642
+ typedef Ptr<Algorithm> member_type;
3643
+
3644
+ static const Param type = Param::ALGORITHM;
3645
+ };
3646
+
3647
+ template <> struct ParamType<float> {
3648
+ typedef float const_param_type;
3649
+ typedef float member_type;
3650
+
3651
+ static const Param type = Param::FLOAT;
3652
+ };
3653
+
3654
+ template <> struct ParamType<unsigned> {
3655
+ typedef unsigned const_param_type;
3656
+ typedef unsigned member_type;
3657
+
3658
+ static const Param type = Param::UNSIGNED_INT;
3659
+ };
3660
+
3661
+ template <> struct ParamType<uint64> {
3662
+ typedef uint64 const_param_type;
3663
+ typedef uint64 member_type;
3664
+
3665
+ static const Param type = Param::UINT64;
3666
+ };
3667
+
3668
+ template <> struct ParamType<uchar> {
3669
+ typedef uchar const_param_type;
3670
+ typedef uchar member_type;
3671
+
3672
+ static const Param type = Param::UCHAR;
3673
+ };
3674
+
3675
+ template <> struct ParamType<Scalar> {
3676
+ typedef const Scalar &const_param_type;
3677
+ typedef Scalar member_type;
3678
+
3679
+ static const Param type = Param::SCALAR;
3680
+ };
3681
+
3682
+ template <typename _Tp>
3683
+ struct ParamType<_Tp, typename std::enable_if<std::is_enum<_Tp>::value>::type> {
3684
+ typedef typename std::underlying_type<_Tp>::type const_param_type;
3685
+ typedef typename std::underlying_type<_Tp>::type member_type;
3686
+
3687
+ static const Param type = Param::INT;
3688
+ };
3689
+
3690
+ //! @} core_basic
3691
+
3692
+ } // namespace cv
3693
+
3694
+ #include "opencv2/core/cvstd.inl.hpp"
3695
+ #include "opencv2/core/operations.hpp"
3696
+ #include "opencv2/core/optim.hpp"
3697
+ #include "opencv2/core/utility.hpp"
3698
+
3699
+ #endif /*OPENCV_CORE_HPP*/