react-native-executorch 0.4.8 → 0.5.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 (1013) 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/SpeechToText.cpp +64 -0
  85. package/common/rnexecutorch/models/speech_to_text/SpeechToText.h +31 -0
  86. package/common/rnexecutorch/models/speech_to_text/SpeechToTextStrategy.h +27 -0
  87. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.cpp +50 -0
  88. package/common/rnexecutorch/models/speech_to_text/WhisperStrategy.h +25 -0
  89. package/common/rnexecutorch/models/style_transfer/StyleTransfer.cpp +55 -0
  90. package/common/rnexecutorch/models/style_transfer/StyleTransfer.h +29 -0
  91. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.cpp +92 -0
  92. package/common/rnexecutorch/models/vertical_ocr/VerticalDetector.h +49 -0
  93. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.cpp +180 -0
  94. package/common/rnexecutorch/models/vertical_ocr/VerticalOCR.h +78 -0
  95. package/common/rnexecutorch/tests/LogTest.cpp +530 -0
  96. package/common/rnexecutorch/tests/README.md +20 -0
  97. package/common/rnexecutorch/tests/run_all_tests.sh +14 -0
  98. package/common/rnexecutorch/tests/run_test.sh +18 -0
  99. package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
  100. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  101. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  102. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  103. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  104. package/ios/RnExecutorch/ETInstaller.h +8 -0
  105. package/ios/RnExecutorch/ETInstaller.mm +56 -0
  106. package/ios/RnExecutorch/utils/Conversions.h +8 -9
  107. package/ios/RnExecutorch/utils/Numerical.h +2 -0
  108. package/ios/RnExecutorch.xcodeproj/project.pbxproj +73 -0
  109. package/lib/module/Error.js +2 -0
  110. package/lib/module/Error.js.map +1 -1
  111. package/lib/module/common/Logger.js +23 -0
  112. package/lib/module/common/Logger.js.map +1 -0
  113. package/lib/module/constants/llmDefaults.js +8 -0
  114. package/lib/module/constants/llmDefaults.js.map +1 -1
  115. package/lib/module/constants/modelUrls.js +328 -84
  116. package/lib/module/constants/modelUrls.js.map +1 -1
  117. package/lib/module/constants/ocr/models.js +181 -286
  118. package/lib/module/constants/ocr/models.js.map +1 -1
  119. package/lib/module/constants/ocr/symbols.js +63 -63
  120. package/lib/module/controllers/LLMController.js +17 -11
  121. package/lib/module/controllers/LLMController.js.map +1 -1
  122. package/lib/module/controllers/OCRController.js +16 -9
  123. package/lib/module/controllers/OCRController.js.map +1 -1
  124. package/lib/module/controllers/VerticalOCRController.js +16 -9
  125. package/lib/module/controllers/VerticalOCRController.js.map +1 -1
  126. package/lib/module/hooks/computer_vision/useClassification.js +5 -5
  127. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  128. package/lib/module/hooks/computer_vision/useImageEmbeddings.js +13 -0
  129. package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -0
  130. package/lib/module/hooks/computer_vision/useImageSegmentation.js +4 -4
  131. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
  132. package/lib/module/hooks/computer_vision/useOCR.js +14 -15
  133. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  134. package/lib/module/hooks/computer_vision/useObjectDetection.js +5 -5
  135. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  136. package/lib/module/hooks/computer_vision/useStyleTransfer.js +5 -5
  137. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  138. package/lib/module/hooks/computer_vision/useVerticalOCR.js +16 -17
  139. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  140. package/lib/module/hooks/general/useExecutorchModule.js +5 -3
  141. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  142. package/lib/module/hooks/natural_language_processing/useLLM.js +22 -25
  143. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  144. package/lib/module/hooks/natural_language_processing/useSpeechToText.js +72 -33
  145. package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
  146. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +4 -5
  147. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
  148. package/lib/module/hooks/natural_language_processing/useTokenizer.js +20 -19
  149. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
  150. package/lib/module/hooks/useNonStaticModule.js +52 -0
  151. package/lib/module/hooks/useNonStaticModule.js.map +1 -0
  152. package/lib/module/index.js +15 -4
  153. package/lib/module/index.js.map +1 -1
  154. package/lib/module/modules/BaseModule.js +6 -3
  155. package/lib/module/modules/BaseModule.js.map +1 -1
  156. package/lib/module/modules/BaseNonStaticModule.js +17 -0
  157. package/lib/module/modules/BaseNonStaticModule.js.map +1 -0
  158. package/lib/module/modules/computer_vision/ClassificationModule.js +13 -8
  159. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  160. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +19 -0
  161. package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -0
  162. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +21 -19
  163. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
  164. package/lib/module/modules/computer_vision/OCRModule.js +13 -10
  165. package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
  166. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +13 -8
  167. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  168. package/lib/module/modules/computer_vision/StyleTransferModule.js +13 -8
  169. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  170. package/lib/module/modules/computer_vision/VerticalOCRModule.js +15 -10
  171. package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
  172. package/lib/module/modules/general/ExecutorchModule.js +10 -36
  173. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  174. package/lib/module/modules/natural_language_processing/LLMModule.js +18 -22
  175. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  176. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +79 -27
  177. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  178. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +15 -8
  179. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
  180. package/lib/module/modules/natural_language_processing/TokenizerModule.js +20 -14
  181. package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -1
  182. package/lib/module/native/NativeETInstaller.js +5 -0
  183. package/lib/module/native/NativeETInstaller.js.map +1 -0
  184. package/lib/module/native/RnExecutorchModules.js +2 -11
  185. package/lib/module/native/RnExecutorchModules.js.map +1 -1
  186. package/lib/module/types/common.js +25 -8
  187. package/lib/module/types/common.js.map +1 -1
  188. package/lib/module/types/stt.js +1 -79
  189. package/lib/module/types/stt.js.map +1 -1
  190. package/lib/module/utils/ResourceFetcher.js +276 -114
  191. package/lib/module/utils/ResourceFetcher.js.map +1 -1
  192. package/lib/module/utils/ResourceFetcherUtils.js +155 -0
  193. package/lib/module/utils/ResourceFetcherUtils.js.map +1 -0
  194. package/lib/module/utils/SpeechToTextModule/ASR.js +191 -0
  195. package/lib/module/utils/SpeechToTextModule/ASR.js.map +1 -0
  196. package/lib/module/utils/SpeechToTextModule/OnlineProcessor.js +73 -0
  197. package/lib/module/utils/SpeechToTextModule/OnlineProcessor.js.map +1 -0
  198. package/lib/module/utils/SpeechToTextModule/hypothesisBuffer.js +56 -0
  199. package/lib/module/utils/SpeechToTextModule/hypothesisBuffer.js.map +1 -0
  200. package/lib/module/utils/llm.js +41 -1
  201. package/lib/module/utils/llm.js.map +1 -1
  202. package/lib/typescript/Error.d.ts +2 -0
  203. package/lib/typescript/Error.d.ts.map +1 -1
  204. package/lib/typescript/common/Logger.d.ts +9 -0
  205. package/lib/typescript/common/Logger.d.ts.map +1 -0
  206. package/lib/typescript/constants/llmDefaults.d.ts +1 -0
  207. package/lib/typescript/constants/llmDefaults.d.ts.map +1 -1
  208. package/lib/typescript/constants/modelUrls.d.ts +240 -79
  209. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  210. package/lib/typescript/constants/ocr/models.d.ts +882 -284
  211. package/lib/typescript/constants/ocr/models.d.ts.map +1 -1
  212. package/lib/typescript/controllers/LLMController.d.ts +3 -4
  213. package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
  214. package/lib/typescript/controllers/OCRController.d.ts +5 -6
  215. package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
  216. package/lib/typescript/controllers/VerticalOCRController.d.ts +5 -6
  217. package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
  218. package/lib/typescript/hooks/computer_vision/useClassification.d.ts +8 -6
  219. package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
  220. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts +16 -0
  221. package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts.map +1 -0
  222. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +5 -3
  223. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -1
  224. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +4 -4
  225. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  226. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -3
  227. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
  228. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +5 -3
  229. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
  230. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +3 -5
  231. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  232. package/lib/typescript/hooks/general/useExecutorchModule.d.ts +1 -1
  233. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -4
  234. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  235. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +15 -22
  236. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
  237. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +9 -5
  238. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -1
  239. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +6 -4
  240. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -1
  241. package/lib/typescript/hooks/useNonStaticModule.d.ts +21 -0
  242. package/lib/typescript/hooks/useNonStaticModule.d.ts.map +1 -0
  243. package/lib/typescript/index.d.ts +17 -4
  244. package/lib/typescript/index.d.ts.map +1 -1
  245. package/lib/typescript/modules/BaseModule.d.ts +1 -1
  246. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  247. package/lib/typescript/modules/BaseNonStaticModule.d.ts +10 -0
  248. package/lib/typescript/modules/BaseNonStaticModule.d.ts.map +1 -0
  249. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +6 -6
  250. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  251. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +9 -0
  252. package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -0
  253. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +8 -28
  254. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
  255. package/lib/typescript/modules/computer_vision/OCRModule.d.ts +8 -7
  256. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  257. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +7 -5
  258. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  259. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
  260. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  261. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +7 -8
  262. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  263. package/lib/typescript/modules/general/ExecutorchModule.d.ts +5 -8
  264. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  265. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +16 -16
  266. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  267. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +20 -13
  268. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  269. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +7 -5
  270. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
  271. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +10 -9
  272. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -1
  273. package/lib/typescript/native/{NativeStyleTransfer.d.ts → NativeETInstaller.d.ts} +2 -3
  274. package/lib/typescript/native/NativeETInstaller.d.ts.map +1 -0
  275. package/lib/typescript/native/RnExecutorchModules.d.ts +3 -21
  276. package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
  277. package/lib/typescript/types/common.d.ts +30 -2
  278. package/lib/typescript/types/common.d.ts.map +1 -1
  279. package/lib/typescript/types/stt.d.ts +18 -88
  280. package/lib/typescript/types/stt.d.ts.map +1 -1
  281. package/lib/typescript/utils/ResourceFetcher.d.ts +18 -10
  282. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
  283. package/lib/typescript/utils/ResourceFetcherUtils.d.ts +55 -0
  284. package/lib/typescript/utils/ResourceFetcherUtils.d.ts.map +1 -0
  285. package/lib/typescript/utils/SpeechToTextModule/ASR.d.ts +27 -0
  286. package/lib/typescript/utils/SpeechToTextModule/ASR.d.ts.map +1 -0
  287. package/lib/typescript/utils/SpeechToTextModule/OnlineProcessor.d.ts +23 -0
  288. package/lib/typescript/utils/SpeechToTextModule/OnlineProcessor.d.ts.map +1 -0
  289. package/lib/typescript/utils/SpeechToTextModule/hypothesisBuffer.d.ts +13 -0
  290. package/lib/typescript/utils/SpeechToTextModule/hypothesisBuffer.d.ts.map +1 -0
  291. package/lib/typescript/utils/llm.d.ts +4 -0
  292. package/lib/typescript/utils/llm.d.ts.map +1 -1
  293. package/package.json +23 -65
  294. package/react-native-executorch.podspec +75 -3
  295. package/src/Error.ts +2 -0
  296. package/src/common/Logger.ts +25 -0
  297. package/src/constants/llmDefaults.ts +11 -0
  298. package/src/constants/modelUrls.ts +401 -168
  299. package/src/constants/ocr/models.ts +826 -395
  300. package/src/constants/ocr/symbols.ts +63 -63
  301. package/src/controllers/LLMController.ts +28 -18
  302. package/src/controllers/OCRController.ts +24 -15
  303. package/src/controllers/VerticalOCRController.ts +24 -14
  304. package/src/hooks/computer_vision/useClassification.ts +10 -11
  305. package/src/hooks/computer_vision/useImageEmbeddings.ts +15 -0
  306. package/src/hooks/computer_vision/useImageSegmentation.ts +5 -8
  307. package/src/hooks/computer_vision/useOCR.ts +29 -21
  308. package/src/hooks/computer_vision/useObjectDetection.ts +6 -9
  309. package/src/hooks/computer_vision/useStyleTransfer.ts +6 -6
  310. package/src/hooks/computer_vision/useVerticalOCR.ts +30 -27
  311. package/src/hooks/general/useExecutorchModule.ts +3 -3
  312. package/src/hooks/natural_language_processing/useLLM.ts +38 -28
  313. package/src/hooks/natural_language_processing/useSpeechToText.ts +91 -88
  314. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +11 -11
  315. package/src/hooks/natural_language_processing/useTokenizer.ts +22 -22
  316. package/src/hooks/useNonStaticModule.ts +74 -0
  317. package/src/index.ts +100 -0
  318. package/src/modules/BaseModule.ts +9 -3
  319. package/src/modules/BaseNonStaticModule.ts +26 -0
  320. package/src/modules/computer_vision/ClassificationModule.ts +20 -11
  321. package/src/modules/computer_vision/ImageEmbeddingsModule.ts +26 -0
  322. package/src/modules/computer_vision/ImageSegmentationModule.ts +35 -27
  323. package/src/modules/computer_vision/OCRModule.ts +23 -15
  324. package/src/modules/computer_vision/ObjectDetectionModule.ts +24 -11
  325. package/src/modules/computer_vision/StyleTransferModule.ts +20 -11
  326. package/src/modules/computer_vision/VerticalOCRModule.ts +25 -21
  327. package/src/modules/general/ExecutorchModule.ts +18 -48
  328. package/src/modules/natural_language_processing/LLMModule.ts +27 -30
  329. package/src/modules/natural_language_processing/SpeechToTextModule.ts +85 -68
  330. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +27 -12
  331. package/src/modules/natural_language_processing/TokenizerModule.ts +27 -17
  332. package/src/native/NativeETInstaller.ts +8 -0
  333. package/src/native/RnExecutorchModules.ts +4 -46
  334. package/src/types/common.ts +40 -12
  335. package/src/types/stt.ts +98 -89
  336. package/src/utils/ResourceFetcher.ts +338 -119
  337. package/src/utils/ResourceFetcherUtils.ts +186 -0
  338. package/src/utils/SpeechToTextModule/ASR.ts +303 -0
  339. package/src/utils/SpeechToTextModule/OnlineProcessor.ts +87 -0
  340. package/src/utils/SpeechToTextModule/hypothesisBuffer.ts +79 -0
  341. package/src/utils/llm.ts +65 -1
  342. package/third-party/android/libs/executorch/arm64-v8a/libexecutorch.so +0 -0
  343. package/third-party/android/libs/executorch/x86_64/libexecutorch.so +0 -0
  344. package/third-party/android/libs/opencv/arm64-v8a/libopencv_core.a +0 -0
  345. package/third-party/android/libs/opencv/arm64-v8a/libopencv_features2d.a +0 -0
  346. package/third-party/android/libs/opencv/arm64-v8a/libopencv_highgui.a +0 -0
  347. package/third-party/android/libs/opencv/arm64-v8a/libopencv_imgproc.a +0 -0
  348. package/third-party/android/libs/opencv/arm64-v8a/libopencv_photo.a +0 -0
  349. package/third-party/android/libs/opencv/arm64-v8a/libopencv_video.a +0 -0
  350. package/third-party/android/libs/opencv/x86_64/libopencv_core.a +0 -0
  351. package/third-party/android/libs/opencv/x86_64/libopencv_features2d.a +0 -0
  352. package/third-party/android/libs/opencv/x86_64/libopencv_highgui.a +0 -0
  353. package/third-party/android/libs/opencv/x86_64/libopencv_imgproc.a +0 -0
  354. package/third-party/android/libs/opencv/x86_64/libopencv_photo.a +0 -0
  355. package/third-party/android/libs/opencv/x86_64/libopencv_video.a +0 -0
  356. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv.a +0 -0
  357. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv_hal.a +0 -0
  358. package/third-party/android/libs/opencv-third-party/arm64-v8a/libkleidicv_thread.a +0 -0
  359. package/third-party/include/c10/macros/Export.h +163 -0
  360. package/third-party/include/c10/macros/Macros.h +497 -0
  361. package/third-party/include/c10/util/BFloat16-inl.h +342 -0
  362. package/third-party/include/c10/util/BFloat16-math.h +266 -0
  363. package/third-party/include/c10/util/BFloat16.h +125 -0
  364. package/third-party/include/c10/util/Half-inl.h +347 -0
  365. package/third-party/include/c10/util/Half.h +416 -0
  366. package/third-party/include/c10/util/TypeSafeSignMath.h +133 -0
  367. package/third-party/include/c10/util/bit_cast.h +43 -0
  368. package/third-party/include/c10/util/floating_point_utils.h +33 -0
  369. package/third-party/include/c10/util/irange.h +107 -0
  370. package/third-party/include/executorch/ExecuTorch.h +13 -0
  371. package/third-party/include/executorch/ExecuTorchError.h +16 -0
  372. package/third-party/include/executorch/ExecuTorchLog.h +76 -0
  373. package/third-party/include/executorch/ExecuTorchModule.h +286 -0
  374. package/third-party/include/executorch/ExecuTorchTensor.h +742 -0
  375. package/third-party/include/executorch/ExecuTorchValue.h +219 -0
  376. package/third-party/include/executorch/extension/module/module.h +492 -0
  377. package/third-party/include/executorch/extension/tensor/tensor.h +13 -0
  378. package/third-party/include/executorch/extension/tensor/tensor_accessor.h +190 -0
  379. package/third-party/include/executorch/extension/tensor/tensor_ptr.h +347 -0
  380. package/third-party/include/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  381. package/third-party/include/executorch/runtime/backend/backend_execution_context.h +71 -0
  382. package/third-party/include/executorch/runtime/backend/backend_init_context.h +72 -0
  383. package/third-party/include/executorch/runtime/backend/interface.h +166 -0
  384. package/third-party/include/executorch/runtime/core/array_ref.h +235 -0
  385. package/third-party/include/executorch/runtime/core/data_loader.h +136 -0
  386. package/third-party/include/executorch/runtime/core/defines.h +20 -0
  387. package/third-party/include/executorch/runtime/core/error.h +229 -0
  388. package/third-party/include/executorch/runtime/core/evalue.h +521 -0
  389. package/third-party/include/executorch/runtime/core/event_tracer.h +565 -0
  390. package/third-party/include/executorch/runtime/core/event_tracer_hooks.h +323 -0
  391. package/third-party/include/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  392. package/third-party/include/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  393. package/third-party/include/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  394. package/third-party/include/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  395. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  396. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_shape_to_c_string.h +69 -0
  397. package/third-party/include/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  398. package/third-party/include/executorch/runtime/core/freeable_buffer.h +107 -0
  399. package/third-party/include/executorch/runtime/core/hierarchical_allocator.h +107 -0
  400. package/third-party/include/executorch/runtime/core/memory_allocator.h +198 -0
  401. package/third-party/include/executorch/runtime/core/named_data_map.h +86 -0
  402. package/third-party/include/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  403. package/third-party/include/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  404. package/third-party/include/executorch/runtime/core/portable_type/bits_types.h +83 -0
  405. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  406. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  407. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  408. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  409. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  410. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  411. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  412. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  413. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  414. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/floating_point_utils.h +33 -0
  415. package/third-party/include/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  416. package/third-party/include/executorch/runtime/core/portable_type/complex.h +44 -0
  417. package/third-party/include/executorch/runtime/core/portable_type/device.h +70 -0
  418. package/third-party/include/executorch/runtime/core/portable_type/half.h +27 -0
  419. package/third-party/include/executorch/runtime/core/portable_type/optional.h +36 -0
  420. package/third-party/include/executorch/runtime/core/portable_type/qint_types.h +83 -0
  421. package/third-party/include/executorch/runtime/core/portable_type/scalar.h +110 -0
  422. package/third-party/include/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  423. package/third-party/include/executorch/runtime/core/portable_type/string_view.h +29 -0
  424. package/third-party/include/executorch/runtime/core/portable_type/tensor.h +142 -0
  425. package/third-party/include/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  426. package/third-party/include/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  427. package/third-party/include/executorch/runtime/core/result.h +258 -0
  428. package/third-party/include/executorch/runtime/core/span.h +93 -0
  429. package/third-party/include/executorch/runtime/core/tag.h +71 -0
  430. package/third-party/include/executorch/runtime/core/tensor_layout.h +79 -0
  431. package/third-party/include/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  432. package/third-party/include/executorch/runtime/executor/memory_manager.h +113 -0
  433. package/third-party/include/executorch/runtime/executor/method.h +387 -0
  434. package/third-party/include/executorch/runtime/executor/method_meta.h +251 -0
  435. package/third-party/include/executorch/runtime/executor/program.h +320 -0
  436. package/third-party/include/executorch/runtime/executor/pte_data_map.h +144 -0
  437. package/third-party/include/executorch/runtime/executor/tensor_parser.h +156 -0
  438. package/third-party/include/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  439. package/third-party/include/executorch/runtime/kernel/operator_registry.h +278 -0
  440. package/third-party/include/executorch/runtime/platform/abort.h +36 -0
  441. package/third-party/include/executorch/runtime/platform/assert.h +119 -0
  442. package/third-party/include/executorch/runtime/platform/clock.h +43 -0
  443. package/third-party/include/executorch/runtime/platform/compat_unistd.h +75 -0
  444. package/third-party/include/executorch/runtime/platform/compiler.h +191 -0
  445. package/third-party/include/executorch/runtime/platform/log.h +177 -0
  446. package/third-party/include/executorch/runtime/platform/platform.h +133 -0
  447. package/third-party/include/executorch/runtime/platform/profiler.h +292 -0
  448. package/third-party/include/executorch/runtime/platform/runtime.h +35 -0
  449. package/third-party/include/executorch/runtime/platform/system.h +49 -0
  450. package/third-party/include/executorch/runtime/platform/types.h +24 -0
  451. package/third-party/include/executorch/schema/extended_header.h +76 -0
  452. package/third-party/include/opencv2/core/affine.hpp +676 -0
  453. package/third-party/include/opencv2/core/async.hpp +107 -0
  454. package/third-party/include/opencv2/core/base.hpp +735 -0
  455. package/third-party/include/opencv2/core/bindings_utils.hpp +279 -0
  456. package/third-party/include/opencv2/core/bufferpool.hpp +39 -0
  457. package/third-party/include/opencv2/core/check.hpp +231 -0
  458. package/third-party/include/opencv2/core/core.hpp +55 -0
  459. package/third-party/include/opencv2/core/core_c.h +3261 -0
  460. package/third-party/include/opencv2/core/cv_cpu_dispatch.h +404 -0
  461. package/third-party/include/opencv2/core/cv_cpu_helper.h +856 -0
  462. package/third-party/include/opencv2/core/cvdef.h +1003 -0
  463. package/third-party/include/opencv2/core/cvstd.hpp +196 -0
  464. package/third-party/include/opencv2/core/cvstd.inl.hpp +188 -0
  465. package/third-party/include/opencv2/core/cvstd_wrapper.hpp +187 -0
  466. package/third-party/include/opencv2/core/detail/async_promise.hpp +73 -0
  467. package/third-party/include/opencv2/core/detail/dispatch_helper.impl.hpp +48 -0
  468. package/third-party/include/opencv2/core/detail/exception_ptr.hpp +24 -0
  469. package/third-party/include/opencv2/core/dualquaternion.hpp +1054 -0
  470. package/third-party/include/opencv2/core/dualquaternion.inl.hpp +464 -0
  471. package/third-party/include/opencv2/core/eigen.hpp +405 -0
  472. package/third-party/include/opencv2/core/fast_math.hpp +433 -0
  473. package/third-party/include/opencv2/core/hal/hal.hpp +451 -0
  474. package/third-party/include/opencv2/core/hal/interface.h +191 -0
  475. package/third-party/include/opencv2/core/hal/intrin.hpp +1222 -0
  476. package/third-party/include/opencv2/core/hal/intrin_avx.hpp +3378 -0
  477. package/third-party/include/opencv2/core/hal/intrin_avx512.hpp +3688 -0
  478. package/third-party/include/opencv2/core/hal/intrin_cpp.hpp +3446 -0
  479. package/third-party/include/opencv2/core/hal/intrin_forward.hpp +195 -0
  480. package/third-party/include/opencv2/core/hal/intrin_lasx.hpp +3243 -0
  481. package/third-party/include/opencv2/core/hal/intrin_lsx.hpp +2671 -0
  482. package/third-party/include/opencv2/core/hal/intrin_math.hpp +772 -0
  483. package/third-party/include/opencv2/core/hal/intrin_msa.hpp +1973 -0
  484. package/third-party/include/opencv2/core/hal/intrin_neon.hpp +2710 -0
  485. package/third-party/include/opencv2/core/hal/intrin_rvv071.hpp +3452 -0
  486. package/third-party/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2559 -0
  487. package/third-party/include/opencv2/core/hal/intrin_sse.hpp +3528 -0
  488. package/third-party/include/opencv2/core/hal/intrin_sse_em.hpp +175 -0
  489. package/third-party/include/opencv2/core/hal/intrin_vsx.hpp +1756 -0
  490. package/third-party/include/opencv2/core/hal/intrin_wasm.hpp +2911 -0
  491. package/third-party/include/opencv2/core/hal/msa_macros.h +2079 -0
  492. package/third-party/include/opencv2/core/hal/simd_utils.impl.hpp +313 -0
  493. package/third-party/include/opencv2/core/mat.hpp +3842 -0
  494. package/third-party/include/opencv2/core/mat.inl.hpp +2753 -0
  495. package/third-party/include/opencv2/core/matx.hpp +603 -0
  496. package/third-party/include/opencv2/core/matx.inl.hpp +1132 -0
  497. package/third-party/include/opencv2/core/neon_utils.hpp +127 -0
  498. package/third-party/include/opencv2/core/operations.hpp +610 -0
  499. package/third-party/include/opencv2/core/optim.hpp +362 -0
  500. package/third-party/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +66 -0
  501. package/third-party/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +148 -0
  502. package/third-party/include/opencv2/core/parallel/parallel_backend.hpp +108 -0
  503. package/third-party/include/opencv2/core/persistence.hpp +1321 -0
  504. package/third-party/include/opencv2/core/quaternion.hpp +1889 -0
  505. package/third-party/include/opencv2/core/quaternion.inl.hpp +907 -0
  506. package/third-party/include/opencv2/core/saturate.hpp +347 -0
  507. package/third-party/include/opencv2/core/simd_intrinsics.hpp +90 -0
  508. package/third-party/include/opencv2/core/softfloat.hpp +657 -0
  509. package/third-party/include/opencv2/core/sse_utils.hpp +861 -0
  510. package/third-party/include/opencv2/core/traits.hpp +417 -0
  511. package/third-party/include/opencv2/core/types.hpp +2368 -0
  512. package/third-party/include/opencv2/core/types_c.h +2064 -0
  513. package/third-party/include/opencv2/core/utility.hpp +1296 -0
  514. package/third-party/include/opencv2/core/utils/allocator_stats.hpp +31 -0
  515. package/third-party/include/opencv2/core/utils/allocator_stats.impl.hpp +111 -0
  516. package/third-party/include/opencv2/core/utils/filesystem.hpp +91 -0
  517. package/third-party/include/opencv2/core/utils/fp_control_utils.hpp +70 -0
  518. package/third-party/include/opencv2/core/utils/instrumentation.hpp +127 -0
  519. package/third-party/include/opencv2/core/utils/logger.defines.hpp +50 -0
  520. package/third-party/include/opencv2/core/utils/logger.hpp +258 -0
  521. package/third-party/include/opencv2/core/utils/logtag.hpp +27 -0
  522. package/third-party/include/opencv2/core/utils/tls.hpp +230 -0
  523. package/third-party/include/opencv2/core/utils/trace.hpp +281 -0
  524. package/third-party/include/opencv2/core/version.hpp +29 -0
  525. package/third-party/include/opencv2/core/vsx_utils.hpp +1115 -0
  526. package/third-party/include/opencv2/core.hpp +3699 -0
  527. package/third-party/include/opencv2/cvconfig.h +155 -0
  528. package/third-party/include/opencv2/dnn/dnn.hpp +51 -0
  529. package/third-party/include/opencv2/dnn.hpp +17 -0
  530. package/third-party/include/opencv2/features2d/features2d.hpp +55 -0
  531. package/third-party/include/opencv2/features2d/hal/interface.h +32 -0
  532. package/third-party/include/opencv2/features2d.hpp +1756 -0
  533. package/third-party/include/opencv2/highgui/highgui.hpp +113 -0
  534. package/third-party/include/opencv2/highgui.hpp +17 -0
  535. package/third-party/include/opencv2/imgproc/bindings.hpp +34 -0
  536. package/third-party/include/opencv2/imgproc/detail/gcgraph.hpp +355 -0
  537. package/third-party/include/opencv2/imgproc/detail/legacy.hpp +35 -0
  538. package/third-party/include/opencv2/imgproc/hal/hal.hpp +246 -0
  539. package/third-party/include/opencv2/imgproc/hal/interface.h +52 -0
  540. package/third-party/include/opencv2/imgproc/imgproc.hpp +55 -0
  541. package/third-party/include/opencv2/imgproc/imgproc_c.h +1261 -0
  542. package/third-party/include/opencv2/imgproc/segmentation.hpp +168 -0
  543. package/third-party/include/opencv2/imgproc/types_c.h +632 -0
  544. package/third-party/include/opencv2/imgproc.hpp +5956 -0
  545. package/third-party/include/opencv2/opencv.hpp +102 -0
  546. package/third-party/include/opencv2/opencv_modules.hpp +19 -0
  547. package/third-party/include/opencv2/photo/legacy/constants_c.h +10 -0
  548. package/third-party/include/opencv2/photo/photo.hpp +55 -0
  549. package/third-party/include/opencv2/photo.hpp +975 -0
  550. package/third-party/include/opencv2/video/background_segm.hpp +341 -0
  551. package/third-party/include/opencv2/video/detail/tracking.detail.hpp +435 -0
  552. package/third-party/include/opencv2/video/legacy/constants_c.h +15 -0
  553. package/third-party/include/opencv2/video/tracking.hpp +1014 -0
  554. package/third-party/include/opencv2/video/video.hpp +55 -0
  555. package/third-party/include/opencv2/video.hpp +65 -0
  556. package/third-party/include/tokenizers-cpp/tokenizers_c.h +61 -0
  557. package/third-party/include/tokenizers-cpp/tokenizers_cpp.h +118 -0
  558. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.h +27 -0
  559. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/ETModel.mm +249 -0
  560. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.h +14 -0
  561. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/HuggingFaceTokenizer.mm +80 -0
  562. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.h +32 -0
  563. package/third-party/ios/ExecutorchLib/ExecutorchLib/Exported/LLaMARunner.mm +95 -0
  564. package/third-party/ios/ExecutorchLib/ExecutorchLib/InputType.h +12 -0
  565. package/third-party/ios/ExecutorchLib/ExecutorchLib/Utils.hpp +217 -0
  566. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.cpp +11 -0
  567. package/third-party/ios/ExecutorchLib/ExecutorchLib/model/Model.h +11 -0
  568. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/irunner.h +48 -0
  569. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/runner.cpp +278 -0
  570. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/runner.h +67 -0
  571. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/stats.h +164 -0
  572. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_decoder_runner.cpp +65 -0
  573. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_decoder_runner.h +105 -0
  574. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_prefiller.cpp +91 -0
  575. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_prefiller.h +51 -0
  576. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/text_token_generator.h +162 -0
  577. package/third-party/ios/ExecutorchLib/ExecutorchLib/runner/util.h +108 -0
  578. package/third-party/ios/ExecutorchLib/ExecutorchLib/sampler/sampler.cpp +193 -0
  579. package/third-party/ios/ExecutorchLib/ExecutorchLib/sampler/sampler.h +64 -0
  580. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/base64.h +202 -0
  581. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.cpp +313 -0
  582. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/bpe_tokenizer.h +57 -0
  583. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.cpp +78 -0
  584. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/llama_tiktoken.h +23 -0
  585. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.cpp +427 -0
  586. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tiktoken.h +87 -0
  587. package/third-party/ios/ExecutorchLib/ExecutorchLib/tokenizer/tokenizer.h +76 -0
  588. package/third-party/ios/ExecutorchLib/ExecutorchLib.xcodeproj/project.pbxproj +683 -0
  589. package/third-party/ios/ExecutorchLib/build.sh +44 -0
  590. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/Info.plist +43 -0
  591. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64/libbackend_coreml_ios.a +0 -0
  592. package/third-party/ios/ExecutorchLib/frameworks/backend_coreml.xcframework/ios-arm64-simulator/libbackend_coreml_simulator.a +0 -0
  593. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/Info.plist +43 -0
  594. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64/libbackend_mps_ios.a +0 -0
  595. package/third-party/ios/ExecutorchLib/frameworks/backend_mps.xcframework/ios-arm64-simulator/libbackend_mps_simulator.a +0 -0
  596. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/Info.plist +43 -0
  597. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64/libbackend_xnnpack_ios.a +0 -0
  598. package/third-party/ios/ExecutorchLib/frameworks/backend_xnnpack.xcframework/ios-arm64-simulator/libbackend_xnnpack_simulator.a +0 -0
  599. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/Info.plist +47 -0
  600. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Export.h +163 -0
  601. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/macros/Macros.h +497 -0
  602. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-inl.h +342 -0
  603. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16-math.h +266 -0
  604. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/BFloat16.h +125 -0
  605. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half-inl.h +347 -0
  606. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/Half.h +416 -0
  607. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/TypeSafeSignMath.h +133 -0
  608. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/bit_cast.h +43 -0
  609. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/floating_point_utils.h +33 -0
  610. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/c10/util/irange.h +107 -0
  611. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorch.h +13 -0
  612. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchError.h +16 -0
  613. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchLog.h +76 -0
  614. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchModule.h +286 -0
  615. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchTensor.h +742 -0
  616. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/ExecuTorchValue.h +219 -0
  617. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/module/module.h +492 -0
  618. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor.h +13 -0
  619. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_accessor.h +190 -0
  620. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr.h +347 -0
  621. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  622. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_execution_context.h +71 -0
  623. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/backend_init_context.h +72 -0
  624. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/backend/interface.h +166 -0
  625. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/array_ref.h +235 -0
  626. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/data_loader.h +136 -0
  627. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/defines.h +20 -0
  628. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/error.h +229 -0
  629. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/evalue.h +521 -0
  630. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer.h +565 -0
  631. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks.h +323 -0
  632. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  633. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  634. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  635. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  636. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  637. 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
  638. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  639. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/freeable_buffer.h +107 -0
  640. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/hierarchical_allocator.h +107 -0
  641. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/memory_allocator.h +198 -0
  642. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/named_data_map.h +86 -0
  643. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  644. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  645. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/bits_types.h +83 -0
  646. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  647. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  648. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-inl.h +342 -0
  649. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16-math.h +266 -0
  650. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  651. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half-inl.h +347 -0
  652. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  653. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  654. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/bit_cast.h +43 -0
  655. 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
  656. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  657. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/complex.h +44 -0
  658. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/device.h +70 -0
  659. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/half.h +27 -0
  660. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/optional.h +36 -0
  661. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/qint_types.h +83 -0
  662. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar.h +110 -0
  663. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  664. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/string_view.h +29 -0
  665. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor.h +142 -0
  666. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  667. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  668. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/result.h +258 -0
  669. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/span.h +93 -0
  670. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tag.h +71 -0
  671. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_layout.h +79 -0
  672. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  673. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/memory_manager.h +113 -0
  674. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method.h +387 -0
  675. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/method_meta.h +251 -0
  676. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/program.h +320 -0
  677. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/pte_data_map.h +144 -0
  678. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/executor/tensor_parser.h +156 -0
  679. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  680. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/kernel/operator_registry.h +278 -0
  681. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/abort.h +36 -0
  682. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/assert.h +119 -0
  683. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/clock.h +43 -0
  684. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compat_unistd.h +75 -0
  685. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/compiler.h +191 -0
  686. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/log.h +177 -0
  687. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/platform.h +133 -0
  688. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/profiler.h +292 -0
  689. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/runtime.h +35 -0
  690. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/system.h +49 -0
  691. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/runtime/platform/types.h +24 -0
  692. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/executorch/schema/extended_header.h +76 -0
  693. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/Headers/module.modulemap +5 -0
  694. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64/libexecutorch_ios.a +0 -0
  695. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Export.h +163 -0
  696. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/macros/Macros.h +497 -0
  697. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-inl.h +342 -0
  698. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16-math.h +266 -0
  699. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/BFloat16.h +125 -0
  700. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half-inl.h +347 -0
  701. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/Half.h +416 -0
  702. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/TypeSafeSignMath.h +133 -0
  703. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/bit_cast.h +43 -0
  704. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/floating_point_utils.h +33 -0
  705. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/c10/util/irange.h +107 -0
  706. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorch.h +13 -0
  707. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchError.h +16 -0
  708. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchLog.h +76 -0
  709. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchModule.h +286 -0
  710. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchTensor.h +742 -0
  711. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/ExecuTorchValue.h +219 -0
  712. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/module/module.h +492 -0
  713. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor.h +13 -0
  714. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_accessor.h +190 -0
  715. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr.h +347 -0
  716. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/extension/tensor/tensor_ptr_maker.h +653 -0
  717. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_execution_context.h +71 -0
  718. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/backend_init_context.h +72 -0
  719. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/backend/interface.h +166 -0
  720. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/array_ref.h +235 -0
  721. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/data_loader.h +136 -0
  722. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/defines.h +20 -0
  723. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/error.h +229 -0
  724. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/evalue.h +521 -0
  725. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer.h +565 -0
  726. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks.h +323 -0
  727. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/event_tracer_hooks_delegate.h +197 -0
  728. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/exec_aten.h +147 -0
  729. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/dim_order_util.h +263 -0
  730. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/scalar_type_util.h +1331 -0
  731. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_dimension_limit.h +21 -0
  732. 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
  733. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/exec_aten/util/tensor_util.h +1250 -0
  734. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/freeable_buffer.h +107 -0
  735. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/hierarchical_allocator.h +107 -0
  736. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/memory_allocator.h +198 -0
  737. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/named_data_map.h +86 -0
  738. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16.h +27 -0
  739. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bfloat16_math.h +14 -0
  740. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/bits_types.h +83 -0
  741. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Export.h +163 -0
  742. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/macros/Macros.h +497 -0
  743. 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
  744. 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
  745. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/BFloat16.h +125 -0
  746. 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
  747. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/Half.h +416 -0
  748. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/TypeSafeSignMath.h +133 -0
  749. 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
  750. 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
  751. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/c10/c10/util/irange.h +107 -0
  752. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/complex.h +44 -0
  753. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/device.h +70 -0
  754. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/half.h +27 -0
  755. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/optional.h +36 -0
  756. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/qint_types.h +83 -0
  757. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar.h +110 -0
  758. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/scalar_type.h +154 -0
  759. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/string_view.h +29 -0
  760. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor.h +142 -0
  761. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_impl.h +261 -0
  762. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/portable_type/tensor_options.h +60 -0
  763. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/result.h +258 -0
  764. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/span.h +93 -0
  765. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tag.h +71 -0
  766. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_layout.h +79 -0
  767. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/core/tensor_shape_dynamism.h +39 -0
  768. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/memory_manager.h +113 -0
  769. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method.h +387 -0
  770. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/method_meta.h +251 -0
  771. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/program.h +320 -0
  772. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/pte_data_map.h +144 -0
  773. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/executor/tensor_parser.h +156 -0
  774. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/kernel_runtime_context.h +122 -0
  775. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/kernel/operator_registry.h +278 -0
  776. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/abort.h +36 -0
  777. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/assert.h +119 -0
  778. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/clock.h +43 -0
  779. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compat_unistd.h +75 -0
  780. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/compiler.h +191 -0
  781. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/log.h +177 -0
  782. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/platform.h +133 -0
  783. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/profiler.h +292 -0
  784. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/runtime.h +35 -0
  785. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/system.h +49 -0
  786. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/runtime/platform/types.h +24 -0
  787. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/executorch/schema/extended_header.h +76 -0
  788. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/Headers/module.modulemap +5 -0
  789. package/third-party/ios/ExecutorchLib/frameworks/executorch.xcframework/ios-arm64-simulator/libexecutorch_simulator.a +0 -0
  790. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/Info.plist +43 -0
  791. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64/libkernels_custom_ios.a +0 -0
  792. package/third-party/ios/ExecutorchLib/frameworks/kernels_custom.xcframework/ios-arm64-simulator/libkernels_custom_simulator.a +0 -0
  793. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/Info.plist +43 -0
  794. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64/libkernels_optimized_ios.a +0 -0
  795. package/third-party/ios/ExecutorchLib/frameworks/kernels_optimized.xcframework/ios-arm64-simulator/libkernels_optimized_simulator.a +0 -0
  796. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/Info.plist +43 -0
  797. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64/libkernels_portable_ios.a +0 -0
  798. package/third-party/ios/ExecutorchLib/frameworks/kernels_portable.xcframework/ios-arm64-simulator/libkernels_portable_simulator.a +0 -0
  799. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/Info.plist +43 -0
  800. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64/libkernels_quantized_ios.a +0 -0
  801. package/third-party/ios/ExecutorchLib/frameworks/kernels_quantized.xcframework/ios-arm64-simulator/libkernels_quantized_simulator.a +0 -0
  802. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/Info.plist +43 -0
  803. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/bitmap256.h +82 -0
  804. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/filtered_re2.h +111 -0
  805. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/pod_array.h +43 -0
  806. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter.h +130 -0
  807. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prefilter_tree.h +139 -0
  808. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/prog.h +483 -0
  809. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/re2.h +994 -0
  810. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/regexp.h +692 -0
  811. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/set.h +85 -0
  812. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_array.h +367 -0
  813. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/sparse_set.h +241 -0
  814. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/stringpiece.h +205 -0
  815. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_casefold.h +78 -0
  816. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/unicode_groups.h +64 -0
  817. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Headers/walker-inl.h +235 -0
  818. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/Info.plist +26 -0
  819. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64/re2.framework/re2 +0 -0
  820. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/bitmap256.h +82 -0
  821. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/filtered_re2.h +111 -0
  822. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/pod_array.h +43 -0
  823. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter.h +130 -0
  824. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prefilter_tree.h +139 -0
  825. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/prog.h +483 -0
  826. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/re2.h +994 -0
  827. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/regexp.h +692 -0
  828. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/set.h +85 -0
  829. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_array.h +367 -0
  830. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/sparse_set.h +241 -0
  831. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/stringpiece.h +205 -0
  832. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_casefold.h +78 -0
  833. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/unicode_groups.h +64 -0
  834. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Headers/walker-inl.h +235 -0
  835. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/Info.plist +26 -0
  836. package/third-party/ios/ExecutorchLib/frameworks/re2.xcframework/ios-arm64-simulator/re2.framework/re2 +0 -0
  837. package/third-party/ios/ios.toolchain.cmake +1122 -0
  838. package/LICENSE +0 -79
  839. package/README.md +0 -148
  840. package/android/src/main/java/com/swmansion/rnexecutorch/Classification.kt +0 -64
  841. package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +0 -90
  842. package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +0 -58
  843. package/android/src/main/java/com/swmansion/rnexecutorch/OCR.kt +0 -90
  844. package/android/src/main/java/com/swmansion/rnexecutorch/ObjectDetection.kt +0 -64
  845. package/android/src/main/java/com/swmansion/rnexecutorch/SpeechToText.kt +0 -91
  846. package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +0 -54
  847. package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +0 -51
  848. package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +0 -86
  849. package/android/src/main/java/com/swmansion/rnexecutorch/VerticalOCR.kt +0 -179
  850. package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +0 -54
  851. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +0 -48
  852. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +0 -37
  853. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +0 -46
  854. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/Constants.kt +0 -1005
  855. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +0 -26
  856. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +0 -142
  857. package/android/src/main/java/com/swmansion/rnexecutorch/models/objectDetection/SSDLiteLargeModel.kt +0 -74
  858. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/Detector.kt +0 -82
  859. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/RecognitionHandler.kt +0 -117
  860. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/Recognizer.kt +0 -51
  861. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/VerticalDetector.kt +0 -89
  862. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/CTCLabelConverter.kt +0 -58
  863. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/Constants.kt +0 -31
  864. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/DetectorUtils.kt +0 -608
  865. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +0 -430
  866. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/BaseS2TDecoder.kt +0 -39
  867. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/BaseS2TModule.kt +0 -43
  868. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/Moonshine.kt +0 -16
  869. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/MoonshineDecoder.kt +0 -23
  870. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/MoonshineEncoder.kt +0 -20
  871. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/Whisper.kt +0 -16
  872. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/WhisperDecoder.kt +0 -22
  873. package/android/src/main/java/com/swmansion/rnexecutorch/models/speechToText/WhisperEncoder.kt +0 -29
  874. package/android/src/main/java/com/swmansion/rnexecutorch/models/styleTransfer/StyleTransferModel.kt +0 -43
  875. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -87
  876. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ETError.kt +0 -34
  877. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ImageProcessor.kt +0 -237
  878. package/android/src/main/java/com/swmansion/rnexecutorch/utils/Numerical.kt +0 -8
  879. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ObjectDetectionUtils.kt +0 -201
  880. package/android/src/main/java/com/swmansion/rnexecutorch/utils/STFT.kt +0 -50
  881. package/android/src/main/java/com/swmansion/rnexecutorch/utils/TensorUtils.kt +0 -103
  882. package/ios/RnExecutorch/Classification.h +0 -5
  883. package/ios/RnExecutorch/Classification.mm +0 -54
  884. package/ios/RnExecutorch/ETModule.h +0 -5
  885. package/ios/RnExecutorch/ETModule.mm +0 -75
  886. package/ios/RnExecutorch/ImageSegmentation.h +0 -5
  887. package/ios/RnExecutorch/ImageSegmentation.mm +0 -60
  888. package/ios/RnExecutorch/OCR.h +0 -5
  889. package/ios/RnExecutorch/OCR.mm +0 -96
  890. package/ios/RnExecutorch/ObjectDetection.h +0 -5
  891. package/ios/RnExecutorch/ObjectDetection.mm +0 -56
  892. package/ios/RnExecutorch/SpeechToText.h +0 -5
  893. package/ios/RnExecutorch/SpeechToText.mm +0 -125
  894. package/ios/RnExecutorch/StyleTransfer.h +0 -5
  895. package/ios/RnExecutorch/StyleTransfer.mm +0 -55
  896. package/ios/RnExecutorch/TextEmbeddings.h +0 -5
  897. package/ios/RnExecutorch/TextEmbeddings.mm +0 -62
  898. package/ios/RnExecutorch/Tokenizer.h +0 -5
  899. package/ios/RnExecutorch/Tokenizer.mm +0 -83
  900. package/ios/RnExecutorch/VerticalOCR.h +0 -5
  901. package/ios/RnExecutorch/VerticalOCR.mm +0 -183
  902. package/ios/RnExecutorch/models/BaseModel.h +0 -21
  903. package/ios/RnExecutorch/models/BaseModel.mm +0 -43
  904. package/ios/RnExecutorch/models/classification/ClassificationModel.h +0 -10
  905. package/ios/RnExecutorch/models/classification/ClassificationModel.mm +0 -53
  906. package/ios/RnExecutorch/models/classification/Constants.h +0 -3
  907. package/ios/RnExecutorch/models/image_segmentation/Constants.h +0 -4
  908. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +0 -10
  909. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +0 -146
  910. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.hpp +0 -11
  911. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +0 -64
  912. package/ios/RnExecutorch/models/ocr/Detector.h +0 -9
  913. package/ios/RnExecutorch/models/ocr/Detector.mm +0 -101
  914. package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +0 -16
  915. package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +0 -135
  916. package/ios/RnExecutorch/models/ocr/Recognizer.h +0 -8
  917. package/ios/RnExecutorch/models/ocr/Recognizer.mm +0 -77
  918. package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -10
  919. package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +0 -118
  920. package/ios/RnExecutorch/models/ocr/utils/CTCLabelConverter.h +0 -16
  921. package/ios/RnExecutorch/models/ocr/utils/CTCLabelConverter.mm +0 -80
  922. package/ios/RnExecutorch/models/ocr/utils/Constants.h +0 -26
  923. package/ios/RnExecutorch/models/ocr/utils/DetectorUtils.h +0 -31
  924. package/ios/RnExecutorch/models/ocr/utils/DetectorUtils.mm +0 -754
  925. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.h +0 -10
  926. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -67
  927. package/ios/RnExecutorch/models/ocr/utils/RecognizerUtils.h +0 -35
  928. package/ios/RnExecutorch/models/ocr/utils/RecognizerUtils.mm +0 -331
  929. package/ios/RnExecutorch/models/stt/Moonshine.hpp +0 -13
  930. package/ios/RnExecutorch/models/stt/Moonshine.mm +0 -64
  931. package/ios/RnExecutorch/models/stt/MoonshineDecoder.hpp +0 -16
  932. package/ios/RnExecutorch/models/stt/MoonshineDecoder.mm +0 -24
  933. package/ios/RnExecutorch/models/stt/MoonshineEncoder.hpp +0 -15
  934. package/ios/RnExecutorch/models/stt/MoonshineEncoder.mm +0 -18
  935. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.hpp +0 -26
  936. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +0 -19
  937. package/ios/RnExecutorch/models/stt/Whisper.hpp +0 -12
  938. package/ios/RnExecutorch/models/stt/Whisper.mm +0 -68
  939. package/ios/RnExecutorch/models/stt/WhisperDecoder.hpp +0 -16
  940. package/ios/RnExecutorch/models/stt/WhisperDecoder.mm +0 -22
  941. package/ios/RnExecutorch/models/stt/WhisperEncoder.hpp +0 -15
  942. package/ios/RnExecutorch/models/stt/WhisperEncoder.mm +0 -21
  943. package/ios/RnExecutorch/models/style_transfer/StyleTransferModel.h +0 -11
  944. package/ios/RnExecutorch/models/style_transfer/StyleTransferModel.mm +0 -50
  945. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +0 -15
  946. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +0 -45
  947. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +0 -8
  948. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +0 -49
  949. package/ios/RnExecutorch/utils/Constants.h +0 -8
  950. package/ios/RnExecutorch/utils/ObjectDetectionUtils.hpp +0 -23
  951. package/ios/RnExecutorch/utils/SFFT.hpp +0 -13
  952. package/ios/RnExecutorch/utils/SFFT.mm +0 -71
  953. package/lib/module/constants/sttDefaults.js +0 -72
  954. package/lib/module/constants/sttDefaults.js.map +0 -1
  955. package/lib/module/controllers/SpeechToTextController.js +0 -307
  956. package/lib/module/controllers/SpeechToTextController.js.map +0 -1
  957. package/lib/module/native/NativeClassification.js +0 -5
  958. package/lib/module/native/NativeClassification.js.map +0 -1
  959. package/lib/module/native/NativeETModule.js +0 -5
  960. package/lib/module/native/NativeETModule.js.map +0 -1
  961. package/lib/module/native/NativeImageSegmentation.js +0 -5
  962. package/lib/module/native/NativeImageSegmentation.js.map +0 -1
  963. package/lib/module/native/NativeOCR.js +0 -5
  964. package/lib/module/native/NativeOCR.js.map +0 -1
  965. package/lib/module/native/NativeObjectDetection.js +0 -5
  966. package/lib/module/native/NativeObjectDetection.js.map +0 -1
  967. package/lib/module/native/NativeSpeechToText.js +0 -5
  968. package/lib/module/native/NativeSpeechToText.js.map +0 -1
  969. package/lib/module/native/NativeStyleTransfer.js +0 -5
  970. package/lib/module/native/NativeStyleTransfer.js.map +0 -1
  971. package/lib/module/native/NativeTextEmbeddings.js +0 -5
  972. package/lib/module/native/NativeTextEmbeddings.js.map +0 -1
  973. package/lib/module/native/NativeTokenizer.js +0 -5
  974. package/lib/module/native/NativeTokenizer.js.map +0 -1
  975. package/lib/module/native/NativeVerticalOCR.js +0 -5
  976. package/lib/module/native/NativeVerticalOCR.js.map +0 -1
  977. package/lib/module/package.json +0 -1
  978. package/lib/typescript/constants/sttDefaults.d.ts +0 -28
  979. package/lib/typescript/constants/sttDefaults.d.ts.map +0 -1
  980. package/lib/typescript/controllers/SpeechToTextController.d.ts +0 -52
  981. package/lib/typescript/controllers/SpeechToTextController.d.ts.map +0 -1
  982. package/lib/typescript/native/NativeClassification.d.ts +0 -10
  983. package/lib/typescript/native/NativeClassification.d.ts.map +0 -1
  984. package/lib/typescript/native/NativeETModule.d.ts +0 -9
  985. package/lib/typescript/native/NativeETModule.d.ts.map +0 -1
  986. package/lib/typescript/native/NativeImageSegmentation.d.ts +0 -10
  987. package/lib/typescript/native/NativeImageSegmentation.d.ts.map +0 -1
  988. package/lib/typescript/native/NativeOCR.d.ts +0 -9
  989. package/lib/typescript/native/NativeOCR.d.ts.map +0 -1
  990. package/lib/typescript/native/NativeObjectDetection.d.ts +0 -9
  991. package/lib/typescript/native/NativeObjectDetection.d.ts.map +0 -1
  992. package/lib/typescript/native/NativeSpeechToText.d.ts +0 -12
  993. package/lib/typescript/native/NativeSpeechToText.d.ts.map +0 -1
  994. package/lib/typescript/native/NativeStyleTransfer.d.ts.map +0 -1
  995. package/lib/typescript/native/NativeTextEmbeddings.d.ts +0 -8
  996. package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +0 -1
  997. package/lib/typescript/native/NativeTokenizer.d.ts +0 -12
  998. package/lib/typescript/native/NativeTokenizer.d.ts.map +0 -1
  999. package/lib/typescript/native/NativeVerticalOCR.d.ts +0 -9
  1000. package/lib/typescript/native/NativeVerticalOCR.d.ts.map +0 -1
  1001. package/src/constants/sttDefaults.ts +0 -86
  1002. package/src/controllers/SpeechToTextController.ts +0 -458
  1003. package/src/index.tsx +0 -47
  1004. package/src/native/NativeClassification.ts +0 -9
  1005. package/src/native/NativeETModule.ts +0 -14
  1006. package/src/native/NativeImageSegmentation.ts +0 -14
  1007. package/src/native/NativeOCR.ts +0 -16
  1008. package/src/native/NativeObjectDetection.ts +0 -10
  1009. package/src/native/NativeSpeechToText.ts +0 -17
  1010. package/src/native/NativeStyleTransfer.ts +0 -10
  1011. package/src/native/NativeTextEmbeddings.ts +0 -9
  1012. package/src/native/NativeTokenizer.ts +0 -13
  1013. package/src/native/NativeVerticalOCR.ts +0 -16
@@ -0,0 +1,3261 @@
1
+ /*M///////////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
+ //
5
+ // By downloading, copying, installing or using the software you agree to this
6
+ license.
7
+ // If you do not agree to this license, do not download, install,
8
+ // copy or use the software.
9
+ //
10
+ //
11
+ // License Agreement
12
+ // For Open Source Computer Vision Library
13
+ //
14
+ // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
15
+ // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
16
+ // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
17
+ // Third party copyrights are property of their respective owners.
18
+ //
19
+ // Redistribution and use in source and binary forms, with or without
20
+ modification,
21
+ // are permitted provided that the following conditions are met:
22
+ //
23
+ // * Redistribution's of source code must retain the above copyright notice,
24
+ // this list of conditions and the following disclaimer.
25
+ //
26
+ // * Redistribution's in binary form must reproduce the above copyright
27
+ notice,
28
+ // this list of conditions and the following disclaimer in the documentation
29
+ // and/or other materials provided with the distribution.
30
+ //
31
+ // * The name of the copyright holders may not be used to endorse or promote
32
+ products
33
+ // derived from this software without specific prior written permission.
34
+ //
35
+ // This software is provided by the copyright holders and contributors "as is"
36
+ and
37
+ // any express or implied warranties, including, but not limited to, the implied
38
+ // warranties of merchantability and fitness for a particular purpose are
39
+ disclaimed.
40
+ // In no event shall the Intel Corporation or contributors be liable for any
41
+ direct,
42
+ // indirect, incidental, special, exemplary, or consequential damages
43
+ // (including, but not limited to, procurement of substitute goods or services;
44
+ // loss of use, data, or profits; or business interruption) however caused
45
+ // and on any theory of liability, whether in contract, strict liability,
46
+ // or tort (including negligence or otherwise) arising in any way out of
47
+ // the use of this software, even if advised of the possibility of such damage.
48
+ //
49
+ //M*/
50
+
51
+ #ifndef OPENCV_CORE_C_H
52
+ #define OPENCV_CORE_C_H
53
+
54
+ #include "opencv2/core/types_c.h"
55
+
56
+ #ifdef __cplusplus
57
+ /* disable MSVC warning C4190 / clang-cl -Wreturn-type-c-linkage:
58
+ 'function' has C-linkage specified, but returns UDT 'typename'
59
+ which is incompatible with C
60
+
61
+ It is OK to disable it because we only extend few plain structures with
62
+ C++ constructors for simpler interoperability with C++ API of the library
63
+ */
64
+ #if defined(__clang__)
65
+ // handle clang on Linux and clang-cl (i. e. clang on Windows) first
66
+ #pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
67
+ #elif defined(_MSC_VER)
68
+ // then handle MSVC
69
+ #pragma warning(disable : 4190)
70
+ #endif
71
+ #endif
72
+
73
+ #ifdef __cplusplus
74
+ extern "C" {
75
+ #endif
76
+
77
+ /** @addtogroup core_c
78
+ @{
79
+ */
80
+
81
+ /****************************************************************************************\
82
+ * Array allocation, deallocation, initialization and access to elements
83
+ *
84
+ \****************************************************************************************/
85
+
86
+ /** `malloc` wrapper.
87
+ If there is no enough memory, the function
88
+ (as well as other OpenCV functions that call cvAlloc)
89
+ raises an error. */
90
+ CVAPI(void *) cvAlloc(size_t size);
91
+
92
+ /** `free` wrapper.
93
+ Here and further all the memory releasing functions
94
+ (that all call cvFree) take double pointer in order to
95
+ to clear pointer to the data after releasing it.
96
+ Passing pointer to NULL pointer is Ok: nothing happens in this case
97
+ */
98
+ CVAPI(void) cvFree_(void *ptr);
99
+ #define cvFree(ptr) (cvFree_(*(ptr)), *(ptr) = 0)
100
+
101
+ /** @brief Creates an image header but does not allocate the image data.
102
+
103
+ @param size Image width and height
104
+ @param depth Image depth (see cvCreateImage )
105
+ @param channels Number of channels (see cvCreateImage )
106
+ */
107
+ CVAPI(IplImage *) cvCreateImageHeader(CvSize size, int depth, int channels);
108
+
109
+ /** @brief Initializes an image header that was previously allocated.
110
+
111
+ The returned IplImage\* points to the initialized header.
112
+ @param image Image header to initialize
113
+ @param size Image width and height
114
+ @param depth Image depth (see cvCreateImage )
115
+ @param channels Number of channels (see cvCreateImage )
116
+ @param origin Top-left IPL_ORIGIN_TL or bottom-left IPL_ORIGIN_BL
117
+ @param align Alignment for image rows, typically 4 or 8 bytes
118
+ */
119
+ CVAPI(IplImage *)
120
+ cvInitImageHeader(IplImage *image, CvSize size, int depth, int channels,
121
+ int origin CV_DEFAULT(0), int align CV_DEFAULT(4));
122
+
123
+ /** @brief Creates an image header and allocates the image data.
124
+
125
+ This function call is equivalent to the following code:
126
+ @code
127
+ header = cvCreateImageHeader(size, depth, channels);
128
+ cvCreateData(header);
129
+ @endcode
130
+ @param size Image width and height
131
+ @param depth Bit depth of image elements. See IplImage for valid depths.
132
+ @param channels Number of channels per pixel. See IplImage for details. This
133
+ function only creates images with interleaved channels.
134
+ */
135
+ CVAPI(IplImage *) cvCreateImage(CvSize size, int depth, int channels);
136
+
137
+ /** @brief Deallocates an image header.
138
+
139
+ This call is an analogue of :
140
+ @code
141
+ if(image )
142
+ {
143
+ iplDeallocate(*image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI);
144
+ *image = 0;
145
+ }
146
+ @endcode
147
+ but it does not use IPL functions by default (see the
148
+ CV_TURN_ON_IPL_COMPATIBILITY macro).
149
+ @param image Double pointer to the image header
150
+ */
151
+ CVAPI(void) cvReleaseImageHeader(IplImage **image);
152
+
153
+ /** @brief Deallocates the image header and the image data.
154
+
155
+ This call is a shortened form of :
156
+ @code
157
+ if(*image )
158
+ {
159
+ cvReleaseData(*image);
160
+ cvReleaseImageHeader(image);
161
+ }
162
+ @endcode
163
+ @param image Double pointer to the image header
164
+ */
165
+ CVAPI(void) cvReleaseImage(IplImage **image);
166
+
167
+ /** Creates a copy of IPL image (widthStep may differ) */
168
+ CVAPI(IplImage *) cvCloneImage(const IplImage *image);
169
+
170
+ /** @brief Sets the channel of interest in an IplImage.
171
+
172
+ If the ROI is set to NULL and the coi is *not* 0, the ROI is allocated. Most
173
+ OpenCV functions do *not* support the COI setting, so to process an individual
174
+ image/matrix channel one may copy (via cvCopy or cvSplit) the channel to a
175
+ separate image/matrix, process it and then copy the result back (via cvCopy or
176
+ cvMerge) if needed.
177
+ @param image A pointer to the image header
178
+ @param coi The channel of interest. 0 - all channels are selected, 1 - first
179
+ channel is selected, etc. Note that the channel indices become 1-based.
180
+ */
181
+ CVAPI(void) cvSetImageCOI(IplImage *image, int coi);
182
+
183
+ /** @brief Returns the index of the channel of interest.
184
+
185
+ Returns the channel of interest of in an IplImage. Returned values correspond to
186
+ the coi in cvSetImageCOI.
187
+ @param image A pointer to the image header
188
+ */
189
+ CVAPI(int) cvGetImageCOI(const IplImage *image);
190
+
191
+ /** @brief Sets an image Region Of Interest (ROI) for a given rectangle.
192
+
193
+ If the original image ROI was NULL and the rect is not the whole image, the ROI
194
+ structure is allocated.
195
+
196
+ Most OpenCV functions support the use of ROI and treat the image rectangle as a
197
+ separate image. For example, all of the pixel coordinates are counted from the
198
+ top-left (or bottom-left) corner of the ROI, not the original image.
199
+ @param image A pointer to the image header
200
+ @param rect The ROI rectangle
201
+ */
202
+ CVAPI(void) cvSetImageROI(IplImage *image, CvRect rect);
203
+
204
+ /** @brief Resets the image ROI to include the entire image and releases the ROI
205
+ structure.
206
+
207
+ This produces a similar result to the following, but in addition it releases the
208
+ ROI structure. :
209
+ @code
210
+ cvSetImageROI(image, cvRect(0, 0, image->width, image->height ));
211
+ cvSetImageCOI(image, 0);
212
+ @endcode
213
+ @param image A pointer to the image header
214
+ */
215
+ CVAPI(void) cvResetImageROI(IplImage *image);
216
+
217
+ /** @brief Returns the image ROI.
218
+
219
+ If there is no ROI set, cvRect(0,0,image-\>width,image-\>height) is returned.
220
+ @param image A pointer to the image header
221
+ */
222
+ CVAPI(CvRect) cvGetImageROI(const IplImage *image);
223
+
224
+ /** @brief Creates a matrix header but does not allocate the matrix data.
225
+
226
+ The function allocates a new matrix header and returns a pointer to it. The
227
+ matrix data can then be allocated using cvCreateData or set explicitly to
228
+ user-allocated data via cvSetData.
229
+ @param rows Number of rows in the matrix
230
+ @param cols Number of columns in the matrix
231
+ @param type Type of the matrix elements, see cvCreateMat
232
+ */
233
+ CVAPI(CvMat *) cvCreateMatHeader(int rows, int cols, int type);
234
+
235
+ #define CV_AUTOSTEP 0x7fffffff
236
+
237
+ /** @brief Initializes a pre-allocated matrix header.
238
+
239
+ This function is often used to process raw data with OpenCV matrix functions.
240
+ For example, the following code computes the matrix product of two matrices,
241
+ stored as ordinary arrays:
242
+ @code
243
+ double a[] = { 1, 2, 3, 4,
244
+ 5, 6, 7, 8,
245
+ 9, 10, 11, 12 };
246
+
247
+ double b[] = { 1, 5, 9,
248
+ 2, 6, 10,
249
+ 3, 7, 11,
250
+ 4, 8, 12 };
251
+
252
+ double c[9];
253
+ CvMat Ma, Mb, Mc ;
254
+
255
+ cvInitMatHeader(&Ma, 3, 4, CV_64FC1, a);
256
+ cvInitMatHeader(&Mb, 4, 3, CV_64FC1, b);
257
+ cvInitMatHeader(&Mc, 3, 3, CV_64FC1, c);
258
+
259
+ cvMatMulAdd(&Ma, &Mb, 0, &Mc);
260
+ // the c array now contains the product of a (3x4) and b (4x3)
261
+ @endcode
262
+ @param mat A pointer to the matrix header to be initialized
263
+ @param rows Number of rows in the matrix
264
+ @param cols Number of columns in the matrix
265
+ @param type Type of the matrix elements, see cvCreateMat .
266
+ @param data Optional: data pointer assigned to the matrix header
267
+ @param step Optional: full row width in bytes of the assigned data. By default,
268
+ the minimal possible step is used which assumes there are no gaps between
269
+ subsequent rows of the matrix.
270
+ */
271
+ CVAPI(CvMat *)
272
+ cvInitMatHeader(CvMat *mat, int rows, int cols, int type,
273
+ void *data CV_DEFAULT(NULL), int step CV_DEFAULT(CV_AUTOSTEP));
274
+
275
+ /** @brief Creates a matrix header and allocates the matrix data.
276
+
277
+ The function call is equivalent to the following code:
278
+ @code
279
+ CvMat* mat = cvCreateMatHeader(rows, cols, type);
280
+ cvCreateData(mat);
281
+ @endcode
282
+ @param rows Number of rows in the matrix
283
+ @param cols Number of columns in the matrix
284
+ @param type The type of the matrix elements in the form
285
+ CV_\<bit depth\>\<S|U|F\>C\<number of channels\> , where S=signed, U=unsigned,
286
+ F=float. For example, CV _ 8UC1 means the elements are 8-bit unsigned and the
287
+ there is 1 channel, and CV _ 32SC2 means the elements are 32-bit signed and
288
+ there are 2 channels.
289
+ */
290
+ CVAPI(CvMat *) cvCreateMat(int rows, int cols, int type);
291
+
292
+ /** @brief Deallocates a matrix.
293
+
294
+ The function decrements the matrix data reference counter and deallocates matrix
295
+ header. If the data reference counter is 0, it also deallocates the data. :
296
+ @code
297
+ if(*mat )
298
+ cvDecRefData(*mat);
299
+ cvFree((void**)mat);
300
+ @endcode
301
+ @param mat Double pointer to the matrix
302
+ */
303
+ CVAPI(void) cvReleaseMat(CvMat **mat);
304
+
305
+ /** @brief Decrements an array data reference counter.
306
+
307
+ The function decrements the data reference counter in a CvMat or CvMatND if the
308
+ reference counter
309
+
310
+ pointer is not NULL. If the counter reaches zero, the data is deallocated. In
311
+ the current implementation the reference counter is not NULL only if the data
312
+ was allocated using the cvCreateData function. The counter will be NULL in other
313
+ cases such as: external data was assigned to the header using cvSetData, header
314
+ is part of a larger matrix or image, or the header was converted from an image
315
+ or n-dimensional matrix header.
316
+ @param arr Pointer to an array header
317
+ */
318
+ CV_INLINE void cvDecRefData(CvArr *arr) {
319
+ if (CV_IS_MAT(arr)) {
320
+ CvMat *mat = (CvMat *)arr;
321
+ mat->data.ptr = NULL;
322
+ if (mat->refcount != NULL && --*mat->refcount == 0)
323
+ cvFree(&mat->refcount);
324
+ mat->refcount = NULL;
325
+ } else if (CV_IS_MATND(arr)) {
326
+ CvMatND *mat = (CvMatND *)arr;
327
+ mat->data.ptr = NULL;
328
+ if (mat->refcount != NULL && --*mat->refcount == 0)
329
+ cvFree(&mat->refcount);
330
+ mat->refcount = NULL;
331
+ }
332
+ }
333
+
334
+ /** @brief Increments array data reference counter.
335
+
336
+ The function increments CvMat or CvMatND data reference counter and returns the
337
+ new counter value if the reference counter pointer is not NULL, otherwise it
338
+ returns zero.
339
+ @param arr Array header
340
+ */
341
+ CV_INLINE int cvIncRefData(CvArr *arr) {
342
+ int refcount = 0;
343
+ if (CV_IS_MAT(arr)) {
344
+ CvMat *mat = (CvMat *)arr;
345
+ if (mat->refcount != NULL)
346
+ refcount = ++*mat->refcount;
347
+ } else if (CV_IS_MATND(arr)) {
348
+ CvMatND *mat = (CvMatND *)arr;
349
+ if (mat->refcount != NULL)
350
+ refcount = ++*mat->refcount;
351
+ }
352
+ return refcount;
353
+ }
354
+
355
+ /** Creates an exact copy of the input matrix (except, may be, step value) */
356
+ CVAPI(CvMat *) cvCloneMat(const CvMat *mat);
357
+
358
+ /** @brief Returns matrix header corresponding to the rectangular sub-array of
359
+ input image or matrix.
360
+
361
+ The function returns header, corresponding to a specified rectangle of the input
362
+ array. In other
363
+
364
+ words, it allows the user to treat a rectangular part of input array as a
365
+ stand-alone array. ROI is taken into account by the function so the sub-array of
366
+ ROI is actually extracted.
367
+ @param arr Input array
368
+ @param submat Pointer to the resultant sub-array header
369
+ @param rect Zero-based coordinates of the rectangle of interest
370
+ */
371
+ CVAPI(CvMat *) cvGetSubRect(const CvArr *arr, CvMat *submat, CvRect rect);
372
+ #define cvGetSubArr cvGetSubRect
373
+
374
+ /** @brief Returns array row or row span.
375
+
376
+ The function returns the header, corresponding to a specified row/row span of
377
+ the input array. cvGetRow(arr, submat, row) is a shortcut for cvGetRows(arr,
378
+ submat, row, row+1).
379
+ @param arr Input array
380
+ @param submat Pointer to the resulting sub-array header
381
+ @param start_row Zero-based index of the starting row (inclusive) of the span
382
+ @param end_row Zero-based index of the ending row (exclusive) of the span
383
+ @param delta_row Index step in the row span. That is, the function extracts
384
+ every delta_row -th row from start_row and up to (but not including) end_row .
385
+ */
386
+ CVAPI(CvMat *)
387
+ cvGetRows(const CvArr *arr, CvMat *submat, int start_row, int end_row,
388
+ int delta_row CV_DEFAULT(1));
389
+
390
+ /** @overload
391
+ @param arr Input array
392
+ @param submat Pointer to the resulting sub-array header
393
+ @param row Zero-based index of the selected row
394
+ */
395
+ CV_INLINE CvMat *cvGetRow(const CvArr *arr, CvMat *submat, int row) {
396
+ return cvGetRows(arr, submat, row, row + 1, 1);
397
+ }
398
+
399
+ /** @brief Returns one of more array columns.
400
+
401
+ The function returns the header, corresponding to a specified column span of the
402
+ input array. That
403
+
404
+ is, no data is copied. Therefore, any modifications of the submatrix will affect
405
+ the original array. If you need to copy the columns, use cvCloneMat.
406
+ cvGetCol(arr, submat, col) is a shortcut for cvGetCols(arr, submat, col, col+1).
407
+ @param arr Input array
408
+ @param submat Pointer to the resulting sub-array header
409
+ @param start_col Zero-based index of the starting column (inclusive) of the span
410
+ @param end_col Zero-based index of the ending column (exclusive) of the span
411
+ */
412
+ CVAPI(CvMat *)
413
+ cvGetCols(const CvArr *arr, CvMat *submat, int start_col, int end_col);
414
+
415
+ /** @overload
416
+ @param arr Input array
417
+ @param submat Pointer to the resulting sub-array header
418
+ @param col Zero-based index of the selected column
419
+ */
420
+ CV_INLINE CvMat *cvGetCol(const CvArr *arr, CvMat *submat, int col) {
421
+ return cvGetCols(arr, submat, col, col + 1);
422
+ }
423
+
424
+ /** @brief Returns one of array diagonals.
425
+
426
+ The function returns the header, corresponding to a specified diagonal of the
427
+ input array.
428
+ @param arr Input array
429
+ @param submat Pointer to the resulting sub-array header
430
+ @param diag Index of the array diagonal. Zero value corresponds to the main
431
+ diagonal, -1 corresponds to the diagonal above the main, 1 corresponds to the
432
+ diagonal below the main, and so forth.
433
+ */
434
+ CVAPI(CvMat *)
435
+ cvGetDiag(const CvArr *arr, CvMat *submat, int diag CV_DEFAULT(0));
436
+
437
+ /** low-level scalar <-> raw data conversion functions */
438
+ CVAPI(void)
439
+ cvScalarToRawData(const CvScalar *scalar, void *data, int type,
440
+ int extend_to_12 CV_DEFAULT(0));
441
+
442
+ CVAPI(void) cvRawDataToScalar(const void *data, int type, CvScalar *scalar);
443
+
444
+ /** @brief Creates a new matrix header but does not allocate the matrix data.
445
+
446
+ The function allocates a header for a multi-dimensional dense array. The array
447
+ data can further be allocated using cvCreateData or set explicitly to
448
+ user-allocated data via cvSetData.
449
+ @param dims Number of array dimensions
450
+ @param sizes Array of dimension sizes
451
+ @param type Type of array elements, see cvCreateMat
452
+ */
453
+ CVAPI(CvMatND *) cvCreateMatNDHeader(int dims, const int *sizes, int type);
454
+
455
+ /** @brief Creates the header and allocates the data for a multi-dimensional
456
+ dense array.
457
+
458
+ This function call is equivalent to the following code:
459
+ @code
460
+ CvMatND* mat = cvCreateMatNDHeader(dims, sizes, type);
461
+ cvCreateData(mat);
462
+ @endcode
463
+ @param dims Number of array dimensions. This must not exceed CV_MAX_DIM (32 by
464
+ default, but can be changed at build time).
465
+ @param sizes Array of dimension sizes.
466
+ @param type Type of array elements, see cvCreateMat .
467
+ */
468
+ CVAPI(CvMatND *) cvCreateMatND(int dims, const int *sizes, int type);
469
+
470
+ /** @brief Initializes a pre-allocated multi-dimensional array header.
471
+
472
+ @param mat A pointer to the array header to be initialized
473
+ @param dims The number of array dimensions
474
+ @param sizes An array of dimension sizes
475
+ @param type Type of array elements, see cvCreateMat
476
+ @param data Optional data pointer assigned to the matrix header
477
+ */
478
+ CVAPI(CvMatND *)
479
+ cvInitMatNDHeader(CvMatND *mat, int dims, const int *sizes, int type,
480
+ void *data CV_DEFAULT(NULL));
481
+
482
+ /** @brief Deallocates a multi-dimensional array.
483
+
484
+ The function decrements the array data reference counter and releases the array
485
+ header. If the reference counter reaches 0, it also deallocates the data. :
486
+ @code
487
+ if(*mat )
488
+ cvDecRefData(*mat);
489
+ cvFree((void**)mat);
490
+ @endcode
491
+ @param mat Double pointer to the array
492
+ */
493
+ CV_INLINE void cvReleaseMatND(CvMatND **mat) { cvReleaseMat((CvMat **)mat); }
494
+
495
+ /** Creates a copy of CvMatND (except, may be, steps) */
496
+ CVAPI(CvMatND *) cvCloneMatND(const CvMatND *mat);
497
+
498
+ /** @brief Creates sparse array.
499
+
500
+ The function allocates a multi-dimensional sparse array. Initially the array
501
+ contain no elements, that is PtrND and other related functions will return 0 for
502
+ every index.
503
+ @param dims Number of array dimensions. In contrast to the dense matrix, the
504
+ number of dimensions is practically unlimited (up to \f$2^{16}\f$ ).
505
+ @param sizes Array of dimension sizes
506
+ @param type Type of array elements. The same as for CvMat
507
+ */
508
+ CVAPI(CvSparseMat *) cvCreateSparseMat(int dims, const int *sizes, int type);
509
+
510
+ /** @brief Deallocates sparse array.
511
+
512
+ The function releases the sparse array and clears the array pointer upon exit.
513
+ @param mat Double pointer to the array
514
+ */
515
+ CVAPI(void) cvReleaseSparseMat(CvSparseMat **mat);
516
+
517
+ /** Creates a copy of CvSparseMat (except, may be, zero items) */
518
+ CVAPI(CvSparseMat *) cvCloneSparseMat(const CvSparseMat *mat);
519
+
520
+ /** @brief Initializes sparse array elements iterator.
521
+
522
+ The function initializes iterator of sparse array elements and returns pointer
523
+ to the first element, or NULL if the array is empty.
524
+ @param mat Input array
525
+ @param mat_iterator Initialized iterator
526
+ */
527
+ CVAPI(CvSparseNode *)
528
+ cvInitSparseMatIterator(const CvSparseMat *mat,
529
+ CvSparseMatIterator *mat_iterator);
530
+
531
+ /** @brief Returns the next sparse matrix element
532
+
533
+ The function moves iterator to the next sparse matrix element and returns
534
+ pointer to it. In the current version there is no any particular order of the
535
+ elements, because they are stored in the hash table. The sample below
536
+ demonstrates how to iterate through the sparse matrix:
537
+ @code
538
+ // print all the non-zero sparse matrix elements and compute their sum
539
+ double sum = 0;
540
+ int i, dims = cvGetDims(sparsemat);
541
+ CvSparseMatIterator it;
542
+ CvSparseNode* node = cvInitSparseMatIterator(sparsemat, &it);
543
+
544
+ for(; node != 0; node = cvGetNextSparseNode(&it))
545
+ {
546
+ int* idx = CV_NODE_IDX(array, node);
547
+ float val = *(float*)CV_NODE_VAL(array, node);
548
+ printf("M");
549
+ for(i = 0; i < dims; i++ )
550
+ printf("[%d]", idx[i]);
551
+ printf("=%g\n", val);
552
+
553
+ sum += val;
554
+ }
555
+
556
+ printf("nTotal sum = %g\n", sum);
557
+ @endcode
558
+ @param mat_iterator Sparse array iterator
559
+ */
560
+ CV_INLINE CvSparseNode *cvGetNextSparseNode(CvSparseMatIterator *mat_iterator) {
561
+ if (mat_iterator->node->next)
562
+ return mat_iterator->node = mat_iterator->node->next;
563
+ else {
564
+ int idx;
565
+ for (idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize;
566
+ idx++) {
567
+ CvSparseNode *node = (CvSparseNode *)mat_iterator->mat->hashtable[idx];
568
+ if (node) {
569
+ mat_iterator->curidx = idx;
570
+ return mat_iterator->node = node;
571
+ }
572
+ }
573
+ return NULL;
574
+ }
575
+ }
576
+
577
+ #define CV_MAX_ARR 10
578
+
579
+ /** matrix iterator: used for n-ary operations on dense arrays */
580
+ typedef struct CvNArrayIterator {
581
+ int count; /**< number of arrays */
582
+ int dims; /**< number of dimensions to iterate */
583
+ CvSize size; /**< maximal common linear size: { width = size, height = 1 } */
584
+ uchar *ptr[CV_MAX_ARR]; /**< pointers to the array slices */
585
+ int stack[CV_MAX_DIM]; /**< for internal use */
586
+ CvMatND *hdr[CV_MAX_ARR]; /**< pointers to the headers of the
587
+ matrices that are processed */
588
+ } CvNArrayIterator;
589
+
590
+ #define CV_NO_DEPTH_CHECK 1
591
+ #define CV_NO_CN_CHECK 2
592
+ #define CV_NO_SIZE_CHECK 4
593
+
594
+ /** initializes iterator that traverses through several arrays simultaneously
595
+ (the function together with cvNextArraySlice is used for
596
+ N-ari element-wise operations) */
597
+ CVAPI(int)
598
+ cvInitNArrayIterator(int count, CvArr **arrs, const CvArr *mask, CvMatND *stubs,
599
+ CvNArrayIterator *array_iterator, int flags CV_DEFAULT(0));
600
+
601
+ /** returns zero value if iteration is finished, non-zero (slice length)
602
+ * otherwise */
603
+ CVAPI(int) cvNextNArraySlice(CvNArrayIterator *array_iterator);
604
+
605
+ /** @brief Returns type of array elements.
606
+
607
+ The function returns type of the array elements. In the case of IplImage the
608
+ type is converted to CvMat-like representation. For example, if the image has
609
+ been created as:
610
+ @code
611
+ IplImage* img = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
612
+ @endcode
613
+ The code cvGetElemType(img) will return CV_8UC3.
614
+ @param arr Input array
615
+ */
616
+ CVAPI(int) cvGetElemType(const CvArr *arr);
617
+
618
+ /** @brief Return number of array dimensions
619
+
620
+ The function returns the array dimensionality and the array of dimension sizes.
621
+ In the case of IplImage or CvMat it always returns 2 regardless of number of
622
+ image/matrix rows. For example, the following code calculates total number of
623
+ array elements:
624
+ @code
625
+ int sizes[CV_MAX_DIM];
626
+ int i, total = 1;
627
+ int dims = cvGetDims(arr, size);
628
+ for(i = 0; i < dims; i++ )
629
+ total *= sizes[i];
630
+ @endcode
631
+ @param arr Input array
632
+ @param sizes Optional output vector of the array dimension sizes. For 2d arrays
633
+ the number of rows (height) goes first, number of columns (width) next.
634
+ */
635
+ CVAPI(int) cvGetDims(const CvArr *arr, int *sizes CV_DEFAULT(NULL));
636
+
637
+ /** @brief Returns array size along the specified dimension.
638
+
639
+ @param arr Input array
640
+ @param index Zero-based dimension index (for matrices 0 means number of rows, 1
641
+ means number of columns; for images 0 means height, 1 means width)
642
+ */
643
+ CVAPI(int) cvGetDimSize(const CvArr *arr, int index);
644
+
645
+ /** @brief Return pointer to a particular array element.
646
+
647
+ The functions return a pointer to a specific array element. Number of array
648
+ dimension should match to the number of indices passed to the function except
649
+ for cvPtr1D function that can be used for sequential access to 1D, 2D or nD
650
+ dense arrays.
651
+
652
+ The functions can be used for sparse arrays as well - if the requested node does
653
+ not exist they create it and set it to zero.
654
+
655
+ All these as well as other functions accessing array elements ( cvGetND ,
656
+ cvGetRealND , cvSet , cvSetND , cvSetRealND ) raise an error in case if the
657
+ element index is out of range.
658
+ @param arr Input array
659
+ @param idx0 The first zero-based component of the element index
660
+ @param type Optional output parameter: type of matrix elements
661
+ */
662
+ CVAPI(uchar *) cvPtr1D(const CvArr *arr, int idx0, int *type CV_DEFAULT(NULL));
663
+ /** @overload */
664
+ CVAPI(uchar *)
665
+ cvPtr2D(const CvArr *arr, int idx0, int idx1, int *type CV_DEFAULT(NULL));
666
+ /** @overload */
667
+ CVAPI(uchar *)
668
+ cvPtr3D(const CvArr *arr, int idx0, int idx1, int idx2,
669
+ int *type CV_DEFAULT(NULL));
670
+ /** @overload
671
+ @param arr Input array
672
+ @param idx Array of the element indices
673
+ @param type Optional output parameter: type of matrix elements
674
+ @param create_node Optional input parameter for sparse matrices. Non-zero value
675
+ of the parameter means that the requested element is created if it does not
676
+ exist already.
677
+ @param precalc_hashval Optional input parameter for sparse matrices. If the
678
+ pointer is not NULL, the function does not recalculate the node hash value, but
679
+ takes it from the specified location. It is useful for speeding up pair-wise
680
+ operations (TODO: provide an example)
681
+ */
682
+ CVAPI(uchar *)
683
+ cvPtrND(const CvArr *arr, const int *idx, int *type CV_DEFAULT(NULL),
684
+ int create_node CV_DEFAULT(1),
685
+ unsigned *precalc_hashval CV_DEFAULT(NULL));
686
+
687
+ /** @brief Return a specific array element.
688
+
689
+ The functions return a specific array element. In the case of a sparse array the
690
+ functions return 0 if the requested node does not exist (no new node is created
691
+ by the functions).
692
+ @param arr Input array
693
+ @param idx0 The first zero-based component of the element index
694
+ */
695
+ CVAPI(CvScalar) cvGet1D(const CvArr *arr, int idx0);
696
+ /** @overload */
697
+ CVAPI(CvScalar) cvGet2D(const CvArr *arr, int idx0, int idx1);
698
+ /** @overload */
699
+ CVAPI(CvScalar) cvGet3D(const CvArr *arr, int idx0, int idx1, int idx2);
700
+ /** @overload
701
+ @param arr Input array
702
+ @param idx Array of the element indices
703
+ */
704
+ CVAPI(CvScalar) cvGetND(const CvArr *arr, const int *idx);
705
+
706
+ /** @brief Return a specific element of single-channel 1D, 2D, 3D or nD array.
707
+
708
+ Returns a specific element of a single-channel array. If the array has multiple
709
+ channels, a runtime error is raised. Note that Get?D functions can be used
710
+ safely for both single-channel and multiple-channel arrays though they are a bit
711
+ slower.
712
+
713
+ In the case of a sparse array the functions return 0 if the requested node does
714
+ not exist (no new node is created by the functions).
715
+ @param arr Input array. Must have a single channel.
716
+ @param idx0 The first zero-based component of the element index
717
+ */
718
+ CVAPI(double) cvGetReal1D(const CvArr *arr, int idx0);
719
+ /** @overload */
720
+ CVAPI(double) cvGetReal2D(const CvArr *arr, int idx0, int idx1);
721
+ /** @overload */
722
+ CVAPI(double) cvGetReal3D(const CvArr *arr, int idx0, int idx1, int idx2);
723
+ /** @overload
724
+ @param arr Input array. Must have a single channel.
725
+ @param idx Array of the element indices
726
+ */
727
+ CVAPI(double) cvGetRealND(const CvArr *arr, const int *idx);
728
+
729
+ /** @brief Change the particular array element.
730
+
731
+ The functions assign the new value to a particular array element. In the case of
732
+ a sparse array the functions create the node if it does not exist yet.
733
+ @param arr Input array
734
+ @param idx0 The first zero-based component of the element index
735
+ @param value The assigned value
736
+ */
737
+ CVAPI(void) cvSet1D(CvArr *arr, int idx0, CvScalar value);
738
+ /** @overload */
739
+ CVAPI(void) cvSet2D(CvArr *arr, int idx0, int idx1, CvScalar value);
740
+ /** @overload */
741
+ CVAPI(void) cvSet3D(CvArr *arr, int idx0, int idx1, int idx2, CvScalar value);
742
+ /** @overload
743
+ @param arr Input array
744
+ @param idx Array of the element indices
745
+ @param value The assigned value
746
+ */
747
+ CVAPI(void) cvSetND(CvArr *arr, const int *idx, CvScalar value);
748
+
749
+ /** @brief Change a specific array element.
750
+
751
+ The functions assign a new value to a specific element of a single-channel
752
+ array. If the array has multiple channels, a runtime error is raised. Note that
753
+ the Set\*D function can be used safely for both single-channel and
754
+ multiple-channel arrays, though they are a bit slower.
755
+
756
+ In the case of a sparse array the functions create the node if it does not yet
757
+ exist.
758
+ @param arr Input array
759
+ @param idx0 The first zero-based component of the element index
760
+ @param value The assigned value
761
+ */
762
+ CVAPI(void) cvSetReal1D(CvArr *arr, int idx0, double value);
763
+ /** @overload */
764
+ CVAPI(void) cvSetReal2D(CvArr *arr, int idx0, int idx1, double value);
765
+ /** @overload */
766
+ CVAPI(void) cvSetReal3D(CvArr *arr, int idx0, int idx1, int idx2, double value);
767
+ /** @overload
768
+ @param arr Input array
769
+ @param idx Array of the element indices
770
+ @param value The assigned value
771
+ */
772
+ CVAPI(void) cvSetRealND(CvArr *arr, const int *idx, double value);
773
+
774
+ /** clears element of ND dense array,
775
+ in case of sparse arrays it deletes the specified node */
776
+ CVAPI(void) cvClearND(CvArr *arr, const int *idx);
777
+
778
+ /** @brief Returns matrix header for arbitrary array.
779
+
780
+ The function returns a matrix header for the input array that can be a matrix -
781
+ CvMat, an image - IplImage, or a multi-dimensional dense array - CvMatND (the
782
+ third option is allowed only if allowND != 0) . In the case of matrix the
783
+ function simply returns the input pointer. In the case of IplImage\* or CvMatND
784
+ it initializes the header structure with parameters of the current image ROI and
785
+ returns &header. Because COI is not supported by CvMat, it is returned
786
+ separately.
787
+
788
+ The function provides an easy way to handle both types of arrays - IplImage and
789
+ CvMat using the same code. Input array must have non-zero data pointer,
790
+ otherwise the function will report an error.
791
+
792
+ @note If the input array is IplImage with planar data layout and COI set, the
793
+ function returns the pointer to the selected plane and COI == 0. This feature
794
+ allows user to process IplImage structures with planar data layout, even though
795
+ OpenCV does not support such images.
796
+ @param arr Input array
797
+ @param header Pointer to CvMat structure used as a temporary buffer
798
+ @param coi Optional output parameter for storing COI
799
+ @param allowND If non-zero, the function accepts multi-dimensional dense arrays
800
+ (CvMatND\*) and returns 2D matrix (if CvMatND has two dimensions) or 1D matrix
801
+ (when CvMatND has 1 dimension or more than 2 dimensions). The CvMatND array must
802
+ be continuous.
803
+ @sa cvGetImage, cvarrToMat.
804
+ */
805
+ CVAPI(CvMat *)
806
+ cvGetMat(const CvArr *arr, CvMat *header, int *coi CV_DEFAULT(NULL),
807
+ int allowND CV_DEFAULT(0));
808
+
809
+ /** @brief Returns image header for arbitrary array.
810
+
811
+ The function returns the image header for the input array that can be a matrix
812
+ (CvMat) or image (IplImage). In the case of an image the function simply returns
813
+ the input pointer. In the case of CvMat it initializes an image_header structure
814
+ with the parameters of the input matrix. Note that if we transform IplImage to
815
+ CvMat using cvGetMat and then transform CvMat back to IplImage using this
816
+ function, we will get different headers if the ROI is set in the original image.
817
+ @param arr Input array
818
+ @param image_header Pointer to IplImage structure used as a temporary buffer
819
+ */
820
+ CVAPI(IplImage *) cvGetImage(const CvArr *arr, IplImage *image_header);
821
+
822
+ /** @brief Changes the shape of a multi-dimensional array without copying the
823
+ data.
824
+
825
+ The function is an advanced version of cvReshape that can work with
826
+ multi-dimensional arrays as well (though it can work with ordinary images and
827
+ matrices) and change the number of dimensions.
828
+
829
+ Below are the two samples from the cvReshape description rewritten using
830
+ cvReshapeMatND:
831
+ @code
832
+ IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3);
833
+ IplImage gray_img_hdr, *gray_img;
834
+ gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr),
835
+ &gray_img_hdr, 1, 0, 0);
836
+ ...
837
+ int size[] = { 2, 2, 2 };
838
+ CvMatND* mat = cvCreateMatND(3, size, CV_32F);
839
+ CvMat row_header, *row;
840
+ row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0);
841
+ @endcode
842
+ In C, the header file for this function includes a convenient macro cvReshapeND
843
+ that does away with the sizeof_header parameter. So, the lines containing the
844
+ call to cvReshapeMatND in the examples may be replaced as follow:
845
+ @code
846
+ gray_img = (IplImage*)cvReshapeND(color_img, &gray_img_hdr, 1, 0, 0);
847
+ ...
848
+ row = (CvMat*)cvReshapeND(mat, &row_header, 0, 1, 0);
849
+ @endcode
850
+ @param arr Input array
851
+ @param sizeof_header Size of output header to distinguish between IplImage,
852
+ CvMat and CvMatND output headers
853
+ @param header Output header to be filled
854
+ @param new_cn New number of channels. new_cn = 0 means that the number of
855
+ channels remains unchanged.
856
+ @param new_dims New number of dimensions. new_dims = 0 means that the number of
857
+ dimensions remains the same.
858
+ @param new_sizes Array of new dimension sizes. Only new_dims-1 values are used,
859
+ because the total number of elements must remain the same. Thus, if new_dims =
860
+ 1, new_sizes array is not used.
861
+ */
862
+ CVAPI(CvArr *)
863
+ cvReshapeMatND(const CvArr *arr, int sizeof_header, CvArr *header, int new_cn,
864
+ int new_dims, int *new_sizes);
865
+
866
+ #define cvReshapeND(arr, header, new_cn, new_dims, new_sizes) \
867
+ cvReshapeMatND((arr), sizeof(*(header)), (header), (new_cn), (new_dims), \
868
+ (new_sizes))
869
+
870
+ /** @brief Changes shape of matrix/image without copying data.
871
+
872
+ The function initializes the CvMat header so that it points to the same data as
873
+ the original array but has a different shape - different number of channels,
874
+ different number of rows, or both.
875
+
876
+ The following example code creates one image buffer and two image headers, the
877
+ first is for a 320x240x3 image and the second is for a 960x240x1 image:
878
+ @code
879
+ IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3);
880
+ CvMat gray_mat_hdr;
881
+ IplImage gray_img_hdr, *gray_img;
882
+ cvReshape(color_img, &gray_mat_hdr, 1);
883
+ gray_img = cvGetImage(&gray_mat_hdr, &gray_img_hdr);
884
+ @endcode
885
+ And the next example converts a 3x3 matrix to a single 1x9 vector:
886
+ @code
887
+ CvMat* mat = cvCreateMat(3, 3, CV_32F);
888
+ CvMat row_header, *row;
889
+ row = cvReshape(mat, &row_header, 0, 1);
890
+ @endcode
891
+ @param arr Input array
892
+ @param header Output header to be filled
893
+ @param new_cn New number of channels. 'new_cn = 0' means that the number of
894
+ channels remains unchanged.
895
+ @param new_rows New number of rows. 'new_rows = 0' means that the number of rows
896
+ remains unchanged unless it needs to be changed according to new_cn value.
897
+ */
898
+ CVAPI(CvMat *)
899
+ cvReshape(const CvArr *arr, CvMat *header, int new_cn,
900
+ int new_rows CV_DEFAULT(0));
901
+
902
+ /** Repeats source 2d array several times in both horizontal and
903
+ vertical direction to fill destination array */
904
+ CVAPI(void) cvRepeat(const CvArr *src, CvArr *dst);
905
+
906
+ /** @brief Allocates array data
907
+
908
+ The function allocates image, matrix or multi-dimensional dense array data. Note
909
+ that in the case of matrix types OpenCV allocation functions are used. In the
910
+ case of IplImage they are used unless CV_TURN_ON_IPL_COMPATIBILITY() has been
911
+ called before. In the latter case IPL functions are used to allocate the data.
912
+ @param arr Array header
913
+ */
914
+ CVAPI(void) cvCreateData(CvArr *arr);
915
+
916
+ /** @brief Releases array data.
917
+
918
+ The function releases the array data. In the case of CvMat or CvMatND it simply
919
+ calls cvDecRefData(), that is the function can not deallocate external data. See
920
+ also the note to cvCreateData .
921
+ @param arr Array header
922
+ */
923
+ CVAPI(void) cvReleaseData(CvArr *arr);
924
+
925
+ /** @brief Assigns user data to the array header.
926
+
927
+ The function assigns user data to the array header. Header should be initialized
928
+ before using cvCreateMatHeader, cvCreateImageHeader, cvCreateMatNDHeader,
929
+ cvInitMatHeader, cvInitImageHeader or cvInitMatNDHeader.
930
+ @param arr Array header
931
+ @param data User data
932
+ @param step Full row length in bytes
933
+ */
934
+ CVAPI(void) cvSetData(CvArr *arr, void *data, int step);
935
+
936
+ /** @brief Retrieves low-level information about the array.
937
+
938
+ The function fills output variables with low-level information about the array
939
+ data. All output
940
+
941
+ parameters are optional, so some of the pointers may be set to NULL. If the
942
+ array is IplImage with ROI set, the parameters of ROI are returned.
943
+
944
+ The following example shows how to get access to array elements. It computes
945
+ absolute values of the array elements :
946
+ @code
947
+ float* data;
948
+ int step;
949
+ CvSize size;
950
+
951
+ cvGetRawData(array, (uchar**)&data, &step, &size);
952
+ step /= sizeof(data[0]);
953
+
954
+ for(int y = 0; y < size.height; y++, data += step )
955
+ for(int x = 0; x < size.width; x++ )
956
+ data[x] = (float)fabs(data[x]);
957
+ @endcode
958
+ @param arr Array header
959
+ @param data Output pointer to the whole image origin or ROI origin if ROI is set
960
+ @param step Output full row length in bytes
961
+ @param roi_size Output ROI size
962
+ */
963
+ CVAPI(void)
964
+ cvGetRawData(const CvArr *arr, uchar **data, int *step CV_DEFAULT(NULL),
965
+ CvSize *roi_size CV_DEFAULT(NULL));
966
+
967
+ /** @brief Returns size of matrix or image ROI.
968
+
969
+ The function returns number of rows (CvSize::height) and number of columns
970
+ (CvSize::width) of the input matrix or image. In the case of image the size of
971
+ ROI is returned.
972
+ @param arr array header
973
+ */
974
+ CVAPI(CvSize) cvGetSize(const CvArr *arr);
975
+
976
+ /** @brief Copies one array to another.
977
+
978
+ The function copies selected elements from an input array to an output array:
979
+
980
+ \f[\texttt{dst} (I)= \texttt{src} (I) \quad \text{if} \quad \texttt{mask} (I)
981
+ \ne 0.\f]
982
+
983
+ If any of the passed arrays is of IplImage type, then its ROI and COI fields are
984
+ used. Both arrays must have the same type, the same number of dimensions, and
985
+ the same size. The function can also copy sparse arrays (mask is not supported
986
+ in this case).
987
+ @param src The source array
988
+ @param dst The destination array
989
+ @param mask Operation mask, 8-bit single channel array; specifies elements of
990
+ the destination array to be changed
991
+ */
992
+ CVAPI(void)
993
+ cvCopy(const CvArr *src, CvArr *dst, const CvArr *mask CV_DEFAULT(NULL));
994
+
995
+ /** @brief Sets every element of an array to a given value.
996
+
997
+ The function copies the scalar value to every selected element of the
998
+ destination array:
999
+ \f[\texttt{arr} (I)= \texttt{value} \quad \text{if} \quad \texttt{mask} (I) \ne
1000
+ 0\f] If array arr is of IplImage type, then is ROI used, but COI must not be
1001
+ set.
1002
+ @param arr The destination array
1003
+ @param value Fill value
1004
+ @param mask Operation mask, 8-bit single channel array; specifies elements of
1005
+ the destination array to be changed
1006
+ */
1007
+ CVAPI(void)
1008
+ cvSet(CvArr *arr, CvScalar value, const CvArr *mask CV_DEFAULT(NULL));
1009
+
1010
+ /** @brief Clears the array.
1011
+
1012
+ The function clears the array. In the case of dense arrays (CvMat, CvMatND or
1013
+ IplImage), cvZero(array) is equivalent to cvSet(array,cvScalarAll(0),0). In the
1014
+ case of sparse arrays all the elements are removed.
1015
+ @param arr Array to be cleared
1016
+ */
1017
+ CVAPI(void) cvSetZero(CvArr *arr);
1018
+ #define cvZero cvSetZero
1019
+
1020
+ /** Splits a multi-channel array into the set of single-channel arrays or
1021
+ extracts particular [color] plane */
1022
+ CVAPI(void)
1023
+ cvSplit(const CvArr *src, CvArr *dst0, CvArr *dst1, CvArr *dst2, CvArr *dst3);
1024
+
1025
+ /** Merges a set of single-channel arrays into the single multi-channel array
1026
+ or inserts one particular [color] plane to the array */
1027
+ CVAPI(void)
1028
+ cvMerge(const CvArr *src0, const CvArr *src1, const CvArr *src2,
1029
+ const CvArr *src3, CvArr *dst);
1030
+
1031
+ /** Copies several channels from input arrays to
1032
+ certain channels of output arrays */
1033
+ CVAPI(void)
1034
+ cvMixChannels(const CvArr **src, int src_count, CvArr **dst, int dst_count,
1035
+ const int *from_to, int pair_count);
1036
+
1037
+ /** @brief Converts one array to another with optional linear transformation.
1038
+
1039
+ The function has several different purposes, and thus has several different
1040
+ names. It copies one array to another with optional scaling, which is performed
1041
+ first, and/or optional type conversion, performed after:
1042
+
1043
+ \f[\texttt{dst} (I) = \texttt{scale} \texttt{src} (I) + ( \texttt{shift} _0,
1044
+ \texttt{shift} _1,...)\f]
1045
+
1046
+ All the channels of multi-channel arrays are processed independently.
1047
+
1048
+ The type of conversion is done with rounding and saturation, that is if the
1049
+ result of scaling + conversion can not be represented exactly by a value of the
1050
+ destination array element type, it is set to the nearest representable value on
1051
+ the real axis.
1052
+ @param src Source array
1053
+ @param dst Destination array
1054
+ @param scale Scale factor
1055
+ @param shift Value added to the scaled source array elements
1056
+ */
1057
+ CVAPI(void)
1058
+ cvConvertScale(const CvArr *src, CvArr *dst, double scale CV_DEFAULT(1),
1059
+ double shift CV_DEFAULT(0));
1060
+ #define cvCvtScale cvConvertScale
1061
+ #define cvScale cvConvertScale
1062
+ #define cvConvert(src, dst) cvConvertScale((src), (dst), 1, 0)
1063
+
1064
+ /** Performs linear transformation on every source array element,
1065
+ stores absolute value of the result:
1066
+ dst(x,y,c) = abs(scale*src(x,y,c)+shift).
1067
+ destination array must have 8u type.
1068
+ In other cases one may use cvConvertScale + cvAbsDiffS */
1069
+ CVAPI(void)
1070
+ cvConvertScaleAbs(const CvArr *src, CvArr *dst, double scale CV_DEFAULT(1),
1071
+ double shift CV_DEFAULT(0));
1072
+ #define cvCvtScaleAbs cvConvertScaleAbs
1073
+
1074
+ /** checks termination criteria validity and
1075
+ sets eps to default_eps (if it is not set),
1076
+ max_iter to default_max_iters (if it is not set)
1077
+ */
1078
+ CVAPI(CvTermCriteria)
1079
+ cvCheckTermCriteria(CvTermCriteria criteria, double default_eps,
1080
+ int default_max_iters);
1081
+
1082
+ /****************************************************************************************\
1083
+ * Arithmetic, logic and comparison operations *
1084
+ \****************************************************************************************/
1085
+
1086
+ /** dst(mask) = src1(mask) + src2(mask) */
1087
+ CVAPI(void)
1088
+ cvAdd(const CvArr *src1, const CvArr *src2, CvArr *dst,
1089
+ const CvArr *mask CV_DEFAULT(NULL));
1090
+
1091
+ /** dst(mask) = src(mask) + value */
1092
+ CVAPI(void)
1093
+ cvAddS(const CvArr *src, CvScalar value, CvArr *dst,
1094
+ const CvArr *mask CV_DEFAULT(NULL));
1095
+
1096
+ /** dst(mask) = src1(mask) - src2(mask) */
1097
+ CVAPI(void)
1098
+ cvSub(const CvArr *src1, const CvArr *src2, CvArr *dst,
1099
+ const CvArr *mask CV_DEFAULT(NULL));
1100
+
1101
+ /** dst(mask) = src(mask) - value = src(mask) + (-value) */
1102
+ CV_INLINE void cvSubS(const CvArr *src, CvScalar value, CvArr *dst,
1103
+ const CvArr *mask CV_DEFAULT(NULL)) {
1104
+ cvAddS(src,
1105
+ cvScalar(-value.val[0], -value.val[1], -value.val[2], -value.val[3]),
1106
+ dst, mask);
1107
+ }
1108
+
1109
+ /** dst(mask) = value - src(mask) */
1110
+ CVAPI(void)
1111
+ cvSubRS(const CvArr *src, CvScalar value, CvArr *dst,
1112
+ const CvArr *mask CV_DEFAULT(NULL));
1113
+
1114
+ /** dst(idx) = src1(idx) * src2(idx) * scale
1115
+ (scaled element-wise multiplication of 2 arrays) */
1116
+ CVAPI(void)
1117
+ cvMul(const CvArr *src1, const CvArr *src2, CvArr *dst,
1118
+ double scale CV_DEFAULT(1));
1119
+
1120
+ /** element-wise division/inversion with scaling:
1121
+ dst(idx) = src1(idx) * scale / src2(idx)
1122
+ or dst(idx) = scale / src2(idx) if src1 == 0 */
1123
+ CVAPI(void)
1124
+ cvDiv(const CvArr *src1, const CvArr *src2, CvArr *dst,
1125
+ double scale CV_DEFAULT(1));
1126
+
1127
+ /** dst = src1 * scale + src2 */
1128
+ CVAPI(void)
1129
+ cvScaleAdd(const CvArr *src1, CvScalar scale, const CvArr *src2, CvArr *dst);
1130
+ #define cvAXPY(A, real_scalar, B, C) \
1131
+ cvScaleAdd(A, cvRealScalar(real_scalar), B, C)
1132
+
1133
+ /** dst = src1 * alpha + src2 * beta + gamma */
1134
+ CVAPI(void)
1135
+ cvAddWeighted(const CvArr *src1, double alpha, const CvArr *src2, double beta,
1136
+ double gamma, CvArr *dst);
1137
+
1138
+ /** @brief Calculates the dot product of two arrays in Euclidean metrics.
1139
+
1140
+ The function calculates and returns the Euclidean dot product of two arrays.
1141
+
1142
+ \f[src1 \bullet src2 = \sum _I ( \texttt{src1} (I) \texttt{src2} (I))\f]
1143
+
1144
+ In the case of multiple channel arrays, the results for all channels are
1145
+ accumulated. In particular, cvDotProduct(a,a) where a is a complex vector, will
1146
+ return \f$||\texttt{a}||^2\f$. The function can process multi-dimensional
1147
+ arrays, row by row, layer by layer, and so on.
1148
+ @param src1 The first source array
1149
+ @param src2 The second source array
1150
+ */
1151
+ CVAPI(double) cvDotProduct(const CvArr *src1, const CvArr *src2);
1152
+
1153
+ /** dst(idx) = src1(idx) & src2(idx) */
1154
+ CVAPI(void)
1155
+ cvAnd(const CvArr *src1, const CvArr *src2, CvArr *dst,
1156
+ const CvArr *mask CV_DEFAULT(NULL));
1157
+
1158
+ /** dst(idx) = src(idx) & value */
1159
+ CVAPI(void)
1160
+ cvAndS(const CvArr *src, CvScalar value, CvArr *dst,
1161
+ const CvArr *mask CV_DEFAULT(NULL));
1162
+
1163
+ /** dst(idx) = src1(idx) | src2(idx) */
1164
+ CVAPI(void)
1165
+ cvOr(const CvArr *src1, const CvArr *src2, CvArr *dst,
1166
+ const CvArr *mask CV_DEFAULT(NULL));
1167
+
1168
+ /** dst(idx) = src(idx) | value */
1169
+ CVAPI(void)
1170
+ cvOrS(const CvArr *src, CvScalar value, CvArr *dst,
1171
+ const CvArr *mask CV_DEFAULT(NULL));
1172
+
1173
+ /** dst(idx) = src1(idx) ^ src2(idx) */
1174
+ CVAPI(void)
1175
+ cvXor(const CvArr *src1, const CvArr *src2, CvArr *dst,
1176
+ const CvArr *mask CV_DEFAULT(NULL));
1177
+
1178
+ /** dst(idx) = src(idx) ^ value */
1179
+ CVAPI(void)
1180
+ cvXorS(const CvArr *src, CvScalar value, CvArr *dst,
1181
+ const CvArr *mask CV_DEFAULT(NULL));
1182
+
1183
+ /** dst(idx) = ~src(idx) */
1184
+ CVAPI(void) cvNot(const CvArr *src, CvArr *dst);
1185
+
1186
+ /** dst(idx) = lower(idx) <= src(idx) < upper(idx) */
1187
+ CVAPI(void)
1188
+ cvInRange(const CvArr *src, const CvArr *lower, const CvArr *upper, CvArr *dst);
1189
+
1190
+ /** dst(idx) = lower <= src(idx) < upper */
1191
+ CVAPI(void)
1192
+ cvInRangeS(const CvArr *src, CvScalar lower, CvScalar upper, CvArr *dst);
1193
+
1194
+ #define CV_CMP_EQ 0
1195
+ #define CV_CMP_GT 1
1196
+ #define CV_CMP_GE 2
1197
+ #define CV_CMP_LT 3
1198
+ #define CV_CMP_LE 4
1199
+ #define CV_CMP_NE 5
1200
+
1201
+ /** The comparison operation support single-channel arrays only.
1202
+ Destination image should be 8uC1 or 8sC1 */
1203
+
1204
+ /** dst(idx) = src1(idx) _cmp_op_ src2(idx) */
1205
+ CVAPI(void) cvCmp(const CvArr *src1, const CvArr *src2, CvArr *dst, int cmp_op);
1206
+
1207
+ /** dst(idx) = src1(idx) _cmp_op_ value */
1208
+ CVAPI(void) cvCmpS(const CvArr *src, double value, CvArr *dst, int cmp_op);
1209
+
1210
+ /** dst(idx) = min(src1(idx),src2(idx)) */
1211
+ CVAPI(void) cvMin(const CvArr *src1, const CvArr *src2, CvArr *dst);
1212
+
1213
+ /** dst(idx) = max(src1(idx),src2(idx)) */
1214
+ CVAPI(void) cvMax(const CvArr *src1, const CvArr *src2, CvArr *dst);
1215
+
1216
+ /** dst(idx) = min(src(idx),value) */
1217
+ CVAPI(void) cvMinS(const CvArr *src, double value, CvArr *dst);
1218
+
1219
+ /** dst(idx) = max(src(idx),value) */
1220
+ CVAPI(void) cvMaxS(const CvArr *src, double value, CvArr *dst);
1221
+
1222
+ /** dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */
1223
+ CVAPI(void) cvAbsDiff(const CvArr *src1, const CvArr *src2, CvArr *dst);
1224
+
1225
+ /** dst(x,y,c) = abs(src(x,y,c) - value(c)) */
1226
+ CVAPI(void) cvAbsDiffS(const CvArr *src, CvArr *dst, CvScalar value);
1227
+ #define cvAbs(src, dst) cvAbsDiffS((src), (dst), cvScalarAll(0))
1228
+
1229
+ /****************************************************************************************\
1230
+ * Math operations *
1231
+ \****************************************************************************************/
1232
+
1233
+ /** Does cartesian->polar coordinates conversion.
1234
+ Either of output components (magnitude or angle) is optional */
1235
+ CVAPI(void)
1236
+ cvCartToPolar(const CvArr *x, const CvArr *y, CvArr *magnitude,
1237
+ CvArr *angle CV_DEFAULT(NULL),
1238
+ int angle_in_degrees CV_DEFAULT(0));
1239
+
1240
+ /** Does polar->cartesian coordinates conversion.
1241
+ Either of output components (magnitude or angle) is optional.
1242
+ If magnitude is missing it is assumed to be all 1's */
1243
+ CVAPI(void)
1244
+ cvPolarToCart(const CvArr *magnitude, const CvArr *angle, CvArr *x, CvArr *y,
1245
+ int angle_in_degrees CV_DEFAULT(0));
1246
+
1247
+ /** Does powering: dst(idx) = src(idx)^power */
1248
+ CVAPI(void) cvPow(const CvArr *src, CvArr *dst, double power);
1249
+
1250
+ /** Does exponention: dst(idx) = exp(src(idx)).
1251
+ Overflow is not handled yet. Underflow is handled.
1252
+ Maximal relative error is ~7e-6 for single-precision input */
1253
+ CVAPI(void) cvExp(const CvArr *src, CvArr *dst);
1254
+
1255
+ /** Calculates natural logarithms: dst(idx) = log(abs(src(idx))).
1256
+ Logarithm of 0 gives large negative number(~-700)
1257
+ Maximal relative error is ~3e-7 for single-precision output
1258
+ */
1259
+ CVAPI(void) cvLog(const CvArr *src, CvArr *dst);
1260
+
1261
+ /** Fast arctangent calculation */
1262
+ CVAPI(float) cvFastArctan(float y, float x);
1263
+
1264
+ /** Fast cubic root calculation */
1265
+ CVAPI(float) cvCbrt(float value);
1266
+
1267
+ #define CV_CHECK_RANGE 1
1268
+ #define CV_CHECK_QUIET 2
1269
+ /** Checks array values for NaNs, Infs or simply for too large numbers
1270
+ (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set,
1271
+ no runtime errors is raised (function returns zero value in case of "bad"
1272
+ values). Otherwise cvError is called */
1273
+ CVAPI(int)
1274
+ cvCheckArr(const CvArr *arr, int flags CV_DEFAULT(0),
1275
+ double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0));
1276
+ #define cvCheckArray cvCheckArr
1277
+
1278
+ #define CV_RAND_UNI 0
1279
+ #define CV_RAND_NORMAL 1
1280
+
1281
+ /** @brief Fills an array with random numbers and updates the RNG state.
1282
+
1283
+ The function fills the destination array with uniformly or normally distributed
1284
+ random numbers.
1285
+ @param rng CvRNG state initialized by cvRNG
1286
+ @param arr The destination array
1287
+ @param dist_type Distribution type
1288
+ > - **CV_RAND_UNI** uniform distribution
1289
+ > - **CV_RAND_NORMAL** normal or Gaussian distribution
1290
+ @param param1 The first parameter of the distribution. In the case of a uniform
1291
+ distribution it is the inclusive lower boundary of the random numbers range. In
1292
+ the case of a normal distribution it is the mean value of the random numbers.
1293
+ @param param2 The second parameter of the distribution. In the case of a uniform
1294
+ distribution it is the exclusive upper boundary of the random numbers range. In
1295
+ the case of a normal distribution it is the standard deviation of the random
1296
+ numbers.
1297
+ @sa randu, randn, RNG::fill.
1298
+ */
1299
+ CVAPI(void)
1300
+ cvRandArr(CvRNG *rng, CvArr *arr, int dist_type, CvScalar param1,
1301
+ CvScalar param2);
1302
+
1303
+ CVAPI(void)
1304
+ cvRandShuffle(CvArr *mat, CvRNG *rng, double iter_factor CV_DEFAULT(1.));
1305
+
1306
+ #define CV_SORT_EVERY_ROW 0
1307
+ #define CV_SORT_EVERY_COLUMN 1
1308
+ #define CV_SORT_ASCENDING 0
1309
+ #define CV_SORT_DESCENDING 16
1310
+
1311
+ CVAPI(void)
1312
+ cvSort(const CvArr *src, CvArr *dst CV_DEFAULT(NULL),
1313
+ CvArr *idxmat CV_DEFAULT(NULL), int flags CV_DEFAULT(0));
1314
+
1315
+ /** Finds real roots of a cubic equation */
1316
+ CVAPI(int) cvSolveCubic(const CvMat *coeffs, CvMat *roots);
1317
+
1318
+ /** Finds all real and complex roots of a polynomial equation */
1319
+ CVAPI(void)
1320
+ cvSolvePoly(const CvMat *coeffs, CvMat *roots2, int maxiter CV_DEFAULT(20),
1321
+ int fig CV_DEFAULT(100));
1322
+
1323
+ /****************************************************************************************\
1324
+ * Matrix operations *
1325
+ \****************************************************************************************/
1326
+
1327
+ /** @brief Calculates the cross product of two 3D vectors.
1328
+
1329
+ The function calculates the cross product of two 3D vectors:
1330
+ \f[\texttt{dst} = \texttt{src1} \times \texttt{src2}\f]
1331
+ or:
1332
+ \f[\begin{array}{l} \texttt{dst} _1 = \texttt{src1} _2 \texttt{src2} _3 -
1333
+ \texttt{src1} _3 \texttt{src2} _2 \\ \texttt{dst} _2 = \texttt{src1} _3
1334
+ \texttt{src2} _1 - \texttt{src1} _1 \texttt{src2} _3 \\ \texttt{dst} _3 =
1335
+ \texttt{src1} _1 \texttt{src2} _2 - \texttt{src1} _2 \texttt{src2} _1
1336
+ \end{array}\f]
1337
+ @param src1 The first source vector
1338
+ @param src2 The second source vector
1339
+ @param dst The destination vector
1340
+ */
1341
+ CVAPI(void) cvCrossProduct(const CvArr *src1, const CvArr *src2, CvArr *dst);
1342
+
1343
+ /** Matrix transform: dst = A*B + C, C is optional */
1344
+ #define cvMatMulAdd(src1, src2, src3, dst) \
1345
+ cvGEMM((src1), (src2), 1., (src3), 1., (dst), 0)
1346
+ #define cvMatMul(src1, src2, dst) cvMatMulAdd((src1), (src2), NULL, (dst))
1347
+
1348
+ #define CV_GEMM_A_T 1
1349
+ #define CV_GEMM_B_T 2
1350
+ #define CV_GEMM_C_T 4
1351
+ /** Extended matrix transform:
1352
+ dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */
1353
+ CVAPI(void)
1354
+ cvGEMM(const CvArr *src1, const CvArr *src2, double alpha, const CvArr *src3,
1355
+ double beta, CvArr *dst, int tABC CV_DEFAULT(0));
1356
+ #define cvMatMulAddEx cvGEMM
1357
+
1358
+ /** Transforms each element of source array and stores
1359
+ resultant vectors in destination array */
1360
+ CVAPI(void)
1361
+ cvTransform(const CvArr *src, CvArr *dst, const CvMat *transmat,
1362
+ const CvMat *shiftvec CV_DEFAULT(NULL));
1363
+ #define cvMatMulAddS cvTransform
1364
+
1365
+ /** Does perspective transform on every element of input array */
1366
+ CVAPI(void)
1367
+ cvPerspectiveTransform(const CvArr *src, CvArr *dst, const CvMat *mat);
1368
+
1369
+ /** Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta)
1370
+ * (order=1) */
1371
+ CVAPI(void)
1372
+ cvMulTransposed(const CvArr *src, CvArr *dst, int order,
1373
+ const CvArr *delta CV_DEFAULT(NULL),
1374
+ double scale CV_DEFAULT(1.));
1375
+
1376
+ /** Transposes matrix. Square matrices can be transposed in-place */
1377
+ CVAPI(void) cvTranspose(const CvArr *src, CvArr *dst);
1378
+ #define cvT cvTranspose
1379
+
1380
+ /** Completes the symmetric matrix from the lower (LtoR=0) or from the upper
1381
+ * (LtoR!=0) part */
1382
+ CVAPI(void) cvCompleteSymm(CvMat *matrix, int LtoR CV_DEFAULT(0));
1383
+
1384
+ /** Mirror array data around horizontal (flip=0),
1385
+ vertical (flip=1) or both(flip=-1) axises:
1386
+ cvFlip(src) flips images vertically and sequences horizontally (inplace) */
1387
+ CVAPI(void)
1388
+ cvFlip(const CvArr *src, CvArr *dst CV_DEFAULT(NULL),
1389
+ int flip_mode CV_DEFAULT(0));
1390
+ #define cvMirror cvFlip
1391
+
1392
+ #define CV_SVD_MODIFY_A 1
1393
+ #define CV_SVD_U_T 2
1394
+ #define CV_SVD_V_T 4
1395
+
1396
+ /** Performs Singular Value Decomposition of a matrix */
1397
+ CVAPI(void)
1398
+ cvSVD(CvArr *A, CvArr *W, CvArr *U CV_DEFAULT(NULL), CvArr *V CV_DEFAULT(NULL),
1399
+ int flags CV_DEFAULT(0));
1400
+
1401
+ /** Performs Singular Value Back Substitution (solves A*X = B):
1402
+ flags must be the same as in cvSVD */
1403
+ CVAPI(void)
1404
+ cvSVBkSb(const CvArr *W, const CvArr *U, const CvArr *V, const CvArr *B,
1405
+ CvArr *X, int flags);
1406
+
1407
+ #define CV_LU 0
1408
+ #define CV_SVD 1
1409
+ #define CV_SVD_SYM 2
1410
+ #define CV_CHOLESKY 3
1411
+ #define CV_QR 4
1412
+ #define CV_NORMAL 16
1413
+
1414
+ /** Inverts matrix */
1415
+ CVAPI(double)
1416
+ cvInvert(const CvArr *src, CvArr *dst, int method CV_DEFAULT(CV_LU));
1417
+ #define cvInv cvInvert
1418
+
1419
+ /** Solves linear system (src1)*(dst) = (src2)
1420
+ (returns 0 if src1 is a singular and CV_LU method is used) */
1421
+ CVAPI(int)
1422
+ cvSolve(const CvArr *src1, const CvArr *src2, CvArr *dst,
1423
+ int method CV_DEFAULT(CV_LU));
1424
+
1425
+ /** Calculates determinant of input matrix */
1426
+ CVAPI(double) cvDet(const CvArr *mat);
1427
+
1428
+ /** Calculates trace of the matrix (sum of elements on the main diagonal) */
1429
+ CVAPI(CvScalar) cvTrace(const CvArr *mat);
1430
+
1431
+ /** Finds eigen values and vectors of a symmetric matrix */
1432
+ CVAPI(void)
1433
+ cvEigenVV(CvArr *mat, CvArr *evects, CvArr *evals, double eps CV_DEFAULT(0),
1434
+ int lowindex CV_DEFAULT(-1), int highindex CV_DEFAULT(-1));
1435
+
1436
+ ///* Finds selected eigen values and vectors of a symmetric matrix */
1437
+ // CVAPI(void) cvSelectedEigenVV( CvArr* mat, CvArr* evects, CvArr* evals,
1438
+ // int lowindex, int highindex );
1439
+
1440
+ /** Makes an identity matrix (mat_ij = i == j) */
1441
+ CVAPI(void)
1442
+ cvSetIdentity(CvArr *mat, CvScalar value CV_DEFAULT(cvRealScalar(1)));
1443
+
1444
+ /** Fills matrix with given range of numbers */
1445
+ CVAPI(CvArr *) cvRange(CvArr *mat, double start, double end);
1446
+
1447
+ /** @anchor core_c_CovarFlags
1448
+ @name Flags for cvCalcCovarMatrix
1449
+ @see cvCalcCovarMatrix
1450
+ @{
1451
+ */
1452
+
1453
+ /** flag for cvCalcCovarMatrix, transpose([v1-avg, v2-avg,...]) *
1454
+ * [v1-avg,v2-avg,...] */
1455
+ #define CV_COVAR_SCRAMBLED 0
1456
+
1457
+ /** flag for cvCalcCovarMatrix, [v1-avg, v2-avg,...] *
1458
+ * transpose([v1-avg,v2-avg,...]) */
1459
+ #define CV_COVAR_NORMAL 1
1460
+
1461
+ /** flag for cvCalcCovarMatrix, do not calc average (i.e. mean vector) - use the
1462
+ input vector instead (useful for calculating covariance matrix by parts) */
1463
+ #define CV_COVAR_USE_AVG 2
1464
+
1465
+ /** flag for cvCalcCovarMatrix, scale the covariance matrix coefficients by
1466
+ * number of the vectors */
1467
+ #define CV_COVAR_SCALE 4
1468
+
1469
+ /** flag for cvCalcCovarMatrix, all the input vectors are stored in a single
1470
+ * matrix, as its rows */
1471
+ #define CV_COVAR_ROWS 8
1472
+
1473
+ /** flag for cvCalcCovarMatrix, all the input vectors are stored in a single
1474
+ * matrix, as its columns */
1475
+ #define CV_COVAR_COLS 16
1476
+
1477
+ /** @} */
1478
+
1479
+ /** Calculates covariation matrix for a set of vectors
1480
+ @see @ref core_c_CovarFlags "flags"
1481
+ */
1482
+ CVAPI(void)
1483
+ cvCalcCovarMatrix(const CvArr **vects, int count, CvArr *cov_mat, CvArr *avg,
1484
+ int flags);
1485
+
1486
+ #define CV_PCA_DATA_AS_ROW 0
1487
+ #define CV_PCA_DATA_AS_COL 1
1488
+ #define CV_PCA_USE_AVG 2
1489
+ CVAPI(void)
1490
+ cvCalcPCA(const CvArr *data, CvArr *mean, CvArr *eigenvals, CvArr *eigenvects,
1491
+ int flags);
1492
+
1493
+ CVAPI(void)
1494
+ cvProjectPCA(const CvArr *data, const CvArr *mean, const CvArr *eigenvects,
1495
+ CvArr *result);
1496
+
1497
+ CVAPI(void)
1498
+ cvBackProjectPCA(const CvArr *proj, const CvArr *mean, const CvArr *eigenvects,
1499
+ CvArr *result);
1500
+
1501
+ /** Calculates Mahalanobis(weighted) distance */
1502
+ CVAPI(double)
1503
+ cvMahalanobis(const CvArr *vec1, const CvArr *vec2, const CvArr *mat);
1504
+ #define cvMahalonobis cvMahalanobis
1505
+
1506
+ /****************************************************************************************\
1507
+ * Array Statistics *
1508
+ \****************************************************************************************/
1509
+
1510
+ /** Finds sum of array elements */
1511
+ CVAPI(CvScalar) cvSum(const CvArr *arr);
1512
+
1513
+ /** Calculates number of non-zero pixels */
1514
+ CVAPI(int) cvCountNonZero(const CvArr *arr);
1515
+
1516
+ /** Calculates mean value of array elements */
1517
+ CVAPI(CvScalar) cvAvg(const CvArr *arr, const CvArr *mask CV_DEFAULT(NULL));
1518
+
1519
+ /** Calculates mean and standard deviation of pixel values */
1520
+ CVAPI(void)
1521
+ cvAvgSdv(const CvArr *arr, CvScalar *mean, CvScalar *std_dev,
1522
+ const CvArr *mask CV_DEFAULT(NULL));
1523
+
1524
+ /** Finds global minimum, maximum and their positions */
1525
+ CVAPI(void)
1526
+ cvMinMaxLoc(const CvArr *arr, double *min_val, double *max_val,
1527
+ CvPoint *min_loc CV_DEFAULT(NULL),
1528
+ CvPoint *max_loc CV_DEFAULT(NULL),
1529
+ const CvArr *mask CV_DEFAULT(NULL));
1530
+
1531
+ /** @anchor core_c_NormFlags
1532
+ @name Flags for cvNorm and cvNormalize
1533
+ @{
1534
+ */
1535
+ #define CV_C 1
1536
+ #define CV_L1 2
1537
+ #define CV_L2 4
1538
+ #define CV_NORM_MASK 7
1539
+ #define CV_RELATIVE 8
1540
+ #define CV_DIFF 16
1541
+ #define CV_MINMAX 32
1542
+
1543
+ #define CV_DIFF_C (CV_DIFF | CV_C)
1544
+ #define CV_DIFF_L1 (CV_DIFF | CV_L1)
1545
+ #define CV_DIFF_L2 (CV_DIFF | CV_L2)
1546
+ #define CV_RELATIVE_C (CV_RELATIVE | CV_C)
1547
+ #define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1)
1548
+ #define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2)
1549
+ /** @} */
1550
+
1551
+ /** Finds norm, difference norm or relative difference norm for an array (or two
1552
+ arrays)
1553
+ @see ref core_c_NormFlags "flags"
1554
+ */
1555
+ CVAPI(double)
1556
+ cvNorm(const CvArr *arr1, const CvArr *arr2 CV_DEFAULT(NULL),
1557
+ int norm_type CV_DEFAULT(CV_L2), const CvArr *mask CV_DEFAULT(NULL));
1558
+
1559
+ /** @see ref core_c_NormFlags "flags" */
1560
+ CVAPI(void)
1561
+ cvNormalize(const CvArr *src, CvArr *dst, double a CV_DEFAULT(1.),
1562
+ double b CV_DEFAULT(0.), int norm_type CV_DEFAULT(CV_L2),
1563
+ const CvArr *mask CV_DEFAULT(NULL));
1564
+
1565
+ /** @anchor core_c_ReduceFlags
1566
+ @name Flags for cvReduce
1567
+ @{
1568
+ */
1569
+ #define CV_REDUCE_SUM 0
1570
+ #define CV_REDUCE_AVG 1
1571
+ #define CV_REDUCE_MAX 2
1572
+ #define CV_REDUCE_MIN 3
1573
+ /** @} */
1574
+
1575
+ /** @see @ref core_c_ReduceFlags "flags" */
1576
+ CVAPI(void)
1577
+ cvReduce(const CvArr *src, CvArr *dst, int dim CV_DEFAULT(-1),
1578
+ int op CV_DEFAULT(CV_REDUCE_SUM));
1579
+
1580
+ /****************************************************************************************\
1581
+ * Discrete Linear Transforms and Related Functions *
1582
+ \****************************************************************************************/
1583
+
1584
+ /** @anchor core_c_DftFlags
1585
+ @name Flags for cvDFT, cvDCT and cvMulSpectrums
1586
+ @{
1587
+ */
1588
+ #define CV_DXT_FORWARD 0
1589
+ #define CV_DXT_INVERSE 1
1590
+ #define CV_DXT_SCALE 2 /**< divide result by size of array */
1591
+ #define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE)
1592
+ #define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE
1593
+ #define CV_DXT_ROWS 4 /**< transform each row individually */
1594
+ #define CV_DXT_MUL_CONJ \
1595
+ 8 /**< conjugate the second argument of cvMulSpectrums */
1596
+ /** @} */
1597
+
1598
+ /** Discrete Fourier Transform:
1599
+ complex->complex,
1600
+ real->ccs (forward),
1601
+ ccs->real (inverse)
1602
+ @see core_c_DftFlags "flags"
1603
+ */
1604
+ CVAPI(void)
1605
+ cvDFT(const CvArr *src, CvArr *dst, int flags, int nonzero_rows CV_DEFAULT(0));
1606
+ #define cvFFT cvDFT
1607
+
1608
+ /** Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y))
1609
+ @see core_c_DftFlags "flags"
1610
+ */
1611
+ CVAPI(void)
1612
+ cvMulSpectrums(const CvArr *src1, const CvArr *src2, CvArr *dst, int flags);
1613
+
1614
+ /** Finds optimal DFT vector size >= size0 */
1615
+ CVAPI(int) cvGetOptimalDFTSize(int size0);
1616
+
1617
+ /** Discrete Cosine Transform
1618
+ @see core_c_DftFlags "flags"
1619
+ */
1620
+ CVAPI(void) cvDCT(const CvArr *src, CvArr *dst, int flags);
1621
+
1622
+ /****************************************************************************************\
1623
+ * Dynamic data structures *
1624
+ \****************************************************************************************/
1625
+
1626
+ /** Calculates length of sequence slice (with support of negative indices). */
1627
+ CVAPI(int) cvSliceLength(CvSlice slice, const CvSeq *seq);
1628
+
1629
+ /** Creates new memory storage.
1630
+ block_size == 0 means that default,
1631
+ somewhat optimal size, is used (currently, it is 64K) */
1632
+ CVAPI(CvMemStorage *) cvCreateMemStorage(int block_size CV_DEFAULT(0));
1633
+
1634
+ /** Creates a memory storage that will borrow memory blocks from parent storage
1635
+ */
1636
+ CVAPI(CvMemStorage *) cvCreateChildMemStorage(CvMemStorage *parent);
1637
+
1638
+ /** Releases memory storage. All the children of a parent must be released
1639
+ before the parent. A child storage returns all the blocks to parent when it
1640
+ is released */
1641
+ CVAPI(void) cvReleaseMemStorage(CvMemStorage **storage);
1642
+
1643
+ /** Clears memory storage. This is the only way(!!!) (besides
1644
+ cvRestoreMemStoragePos) to reuse memory allocated for the storage -
1645
+ cvClearSeq,cvClearSet ... do not free any memory. A child storage returns all
1646
+ the blocks to the parent when it is cleared */
1647
+ CVAPI(void) cvClearMemStorage(CvMemStorage *storage);
1648
+
1649
+ /** Remember a storage "free memory" position */
1650
+ CVAPI(void)
1651
+ cvSaveMemStoragePos(const CvMemStorage *storage, CvMemStoragePos *pos);
1652
+
1653
+ /** Restore a storage "free memory" position */
1654
+ CVAPI(void) cvRestoreMemStoragePos(CvMemStorage *storage, CvMemStoragePos *pos);
1655
+
1656
+ /** Allocates continuous buffer of the specified size in the storage */
1657
+ CVAPI(void *) cvMemStorageAlloc(CvMemStorage *storage, size_t size);
1658
+
1659
+ /** Allocates string in memory storage */
1660
+ // CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char*
1661
+ // ptr,
1662
+ // int len CV_DEFAULT(-1) );
1663
+
1664
+ /** Creates new empty sequence that will reside in the specified storage */
1665
+ CVAPI(CvSeq *)
1666
+ cvCreateSeq(int seq_flags, size_t header_size, size_t elem_size,
1667
+ CvMemStorage *storage);
1668
+
1669
+ /** Changes default size (granularity) of sequence blocks.
1670
+ The default size is ~1Kbyte */
1671
+ CVAPI(void) cvSetSeqBlockSize(CvSeq *seq, int delta_elems);
1672
+
1673
+ /** Adds new element to the end of sequence. Returns pointer to the element */
1674
+ CVAPI(schar *) cvSeqPush(CvSeq *seq, const void *element CV_DEFAULT(NULL));
1675
+
1676
+ /** Adds new element to the beginning of sequence. Returns pointer to it */
1677
+ CVAPI(schar *) cvSeqPushFront(CvSeq *seq, const void *element CV_DEFAULT(NULL));
1678
+
1679
+ /** Removes the last element from sequence and optionally saves it */
1680
+ CVAPI(void) cvSeqPop(CvSeq *seq, void *element CV_DEFAULT(NULL));
1681
+
1682
+ /** Removes the first element from sequence and optioanally saves it */
1683
+ CVAPI(void) cvSeqPopFront(CvSeq *seq, void *element CV_DEFAULT(NULL));
1684
+
1685
+ #define CV_FRONT 1
1686
+ #define CV_BACK 0
1687
+ /** Adds several new elements to the end of sequence */
1688
+ CVAPI(void)
1689
+ cvSeqPushMulti(CvSeq *seq, const void *elements, int count,
1690
+ int in_front CV_DEFAULT(0));
1691
+
1692
+ /** Removes several elements from the end of sequence and optionally saves them
1693
+ */
1694
+ CVAPI(void)
1695
+ cvSeqPopMulti(CvSeq *seq, void *elements, int count,
1696
+ int in_front CV_DEFAULT(0));
1697
+
1698
+ /** Inserts a new element in the middle of sequence.
1699
+ cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */
1700
+ CVAPI(schar *)
1701
+ cvSeqInsert(CvSeq *seq, int before_index, const void *element CV_DEFAULT(NULL));
1702
+
1703
+ /** Removes specified sequence element */
1704
+ CVAPI(void) cvSeqRemove(CvSeq *seq, int index);
1705
+
1706
+ /** Removes all the elements from the sequence. The freed memory
1707
+ can be reused later only by the same sequence unless cvClearMemStorage
1708
+ or cvRestoreMemStoragePos is called */
1709
+ CVAPI(void) cvClearSeq(CvSeq *seq);
1710
+
1711
+ /** Retrieves pointer to specified sequence element.
1712
+ Negative indices are supported and mean counting from the end
1713
+ (e.g -1 means the last sequence element) */
1714
+ CVAPI(schar *) cvGetSeqElem(const CvSeq *seq, int index);
1715
+
1716
+ /** Calculates index of the specified sequence element.
1717
+ Returns -1 if element does not belong to the sequence */
1718
+ CVAPI(int)
1719
+ cvSeqElemIdx(const CvSeq *seq, const void *element,
1720
+ CvSeqBlock **block CV_DEFAULT(NULL));
1721
+
1722
+ /** Initializes sequence writer. The new elements will be added to the end of
1723
+ * sequence */
1724
+ CVAPI(void) cvStartAppendToSeq(CvSeq *seq, CvSeqWriter *writer);
1725
+
1726
+ /** Combination of cvCreateSeq and cvStartAppendToSeq */
1727
+ CVAPI(void)
1728
+ cvStartWriteSeq(int seq_flags, int header_size, int elem_size,
1729
+ CvMemStorage *storage, CvSeqWriter *writer);
1730
+
1731
+ /** Closes sequence writer, updates sequence header and returns pointer
1732
+ to the resultant sequence
1733
+ (which may be useful if the sequence was created using cvStartWriteSeq))
1734
+ */
1735
+ CVAPI(CvSeq *) cvEndWriteSeq(CvSeqWriter *writer);
1736
+
1737
+ /** Updates sequence header. May be useful to get access to some of previously
1738
+ written elements via cvGetSeqElem or sequence reader */
1739
+ CVAPI(void) cvFlushSeqWriter(CvSeqWriter *writer);
1740
+
1741
+ /** Initializes sequence reader.
1742
+ The sequence can be read in forward or backward direction */
1743
+ CVAPI(void)
1744
+ cvStartReadSeq(const CvSeq *seq, CvSeqReader *reader,
1745
+ int reverse CV_DEFAULT(0));
1746
+
1747
+ /** Returns current sequence reader position (currently observed sequence
1748
+ * element) */
1749
+ CVAPI(int) cvGetSeqReaderPos(CvSeqReader *reader);
1750
+
1751
+ /** Changes sequence reader position. It may seek to an absolute or
1752
+ to relative to the current position */
1753
+ CVAPI(void)
1754
+ cvSetSeqReaderPos(CvSeqReader *reader, int index,
1755
+ int is_relative CV_DEFAULT(0));
1756
+
1757
+ /** Copies sequence content to a continuous piece of memory */
1758
+ CVAPI(void *)
1759
+ cvCvtSeqToArray(const CvSeq *seq, void *elements,
1760
+ CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ));
1761
+
1762
+ /** Creates sequence header for array.
1763
+ After that all the operations on sequences that do not alter the content
1764
+ can be applied to the resultant sequence */
1765
+ CVAPI(CvSeq *)
1766
+ cvMakeSeqHeaderForArray(int seq_type, int header_size, int elem_size,
1767
+ void *elements, int total, CvSeq *seq,
1768
+ CvSeqBlock *block);
1769
+
1770
+ /** Extracts sequence slice (with or without copying sequence elements) */
1771
+ CVAPI(CvSeq *)
1772
+ cvSeqSlice(const CvSeq *seq, CvSlice slice,
1773
+ CvMemStorage *storage CV_DEFAULT(NULL), int copy_data CV_DEFAULT(0));
1774
+
1775
+ CV_INLINE CvSeq *cvCloneSeq(const CvSeq *seq,
1776
+ CvMemStorage *storage CV_DEFAULT(NULL)) {
1777
+ return cvSeqSlice(seq, CV_WHOLE_SEQ, storage, 1);
1778
+ }
1779
+
1780
+ /** Removes sequence slice */
1781
+ CVAPI(void) cvSeqRemoveSlice(CvSeq *seq, CvSlice slice);
1782
+
1783
+ /** Inserts a sequence or array into another sequence */
1784
+ CVAPI(void)
1785
+ cvSeqInsertSlice(CvSeq *seq, int before_index, const CvArr *from_arr);
1786
+
1787
+ /** a < b ? -1 : a > b ? 1 : 0 */
1788
+ typedef int(CV_CDECL *CvCmpFunc)(const void *a, const void *b, void *userdata);
1789
+
1790
+ /** Sorts sequence in-place given element comparison function */
1791
+ CVAPI(void)
1792
+ cvSeqSort(CvSeq *seq, CvCmpFunc func, void *userdata CV_DEFAULT(NULL));
1793
+
1794
+ /** Finds element in a [sorted] sequence */
1795
+ CVAPI(schar *)
1796
+ cvSeqSearch(CvSeq *seq, const void *elem, CvCmpFunc func, int is_sorted,
1797
+ int *elem_idx, void *userdata CV_DEFAULT(NULL));
1798
+
1799
+ /** Reverses order of sequence elements in-place */
1800
+ CVAPI(void) cvSeqInvert(CvSeq *seq);
1801
+
1802
+ /** Splits sequence into one or more equivalence classes using the specified
1803
+ * criteria */
1804
+ CVAPI(int)
1805
+ cvSeqPartition(const CvSeq *seq, CvMemStorage *storage, CvSeq **labels,
1806
+ CvCmpFunc is_equal, void *userdata);
1807
+
1808
+ /************ Internal sequence functions ************/
1809
+ CVAPI(void) cvChangeSeqBlock(void *reader, int direction);
1810
+ CVAPI(void) cvCreateSeqBlock(CvSeqWriter *writer);
1811
+
1812
+ /** Creates a new set */
1813
+ CVAPI(CvSet *)
1814
+ cvCreateSet(int set_flags, int header_size, int elem_size,
1815
+ CvMemStorage *storage);
1816
+
1817
+ /** Adds new element to the set and returns pointer to it */
1818
+ CVAPI(int)
1819
+ cvSetAdd(CvSet *set_header, CvSetElem *elem CV_DEFAULT(NULL),
1820
+ CvSetElem **inserted_elem CV_DEFAULT(NULL));
1821
+
1822
+ /** Fast variant of cvSetAdd */
1823
+ CV_INLINE CvSetElem *cvSetNew(CvSet *set_header) {
1824
+ CvSetElem *elem = set_header->free_elems;
1825
+ if (elem) {
1826
+ set_header->free_elems = elem->next_free;
1827
+ elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK;
1828
+ set_header->active_count++;
1829
+ } else
1830
+ cvSetAdd(set_header, NULL, &elem);
1831
+ return elem;
1832
+ }
1833
+
1834
+ /** Removes set element given its pointer */
1835
+ CV_INLINE void cvSetRemoveByPtr(CvSet *set_header, void *elem) {
1836
+ CvSetElem *_elem = (CvSetElem *)elem;
1837
+ assert(_elem->flags >=
1838
+ 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/);
1839
+ _elem->next_free = set_header->free_elems;
1840
+ _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG;
1841
+ set_header->free_elems = _elem;
1842
+ set_header->active_count--;
1843
+ }
1844
+
1845
+ /** Removes element from the set by its index */
1846
+ CVAPI(void) cvSetRemove(CvSet *set_header, int index);
1847
+
1848
+ /** Returns a set element by index. If the element doesn't belong to the set,
1849
+ NULL is returned */
1850
+ CV_INLINE CvSetElem *cvGetSetElem(const CvSet *set_header, int idx) {
1851
+ CvSetElem *elem = (CvSetElem *)(void *)cvGetSeqElem((CvSeq *)set_header, idx);
1852
+ return elem && CV_IS_SET_ELEM(elem) ? elem : 0;
1853
+ }
1854
+
1855
+ /** Removes all the elements from the set */
1856
+ CVAPI(void) cvClearSet(CvSet *set_header);
1857
+
1858
+ /** Creates new graph */
1859
+ CVAPI(CvGraph *)
1860
+ cvCreateGraph(int graph_flags, int header_size, int vtx_size, int edge_size,
1861
+ CvMemStorage *storage);
1862
+
1863
+ /** Adds new vertex to the graph */
1864
+ CVAPI(int)
1865
+ cvGraphAddVtx(CvGraph *graph, const CvGraphVtx *vtx CV_DEFAULT(NULL),
1866
+ CvGraphVtx **inserted_vtx CV_DEFAULT(NULL));
1867
+
1868
+ /** Removes vertex from the graph together with all incident edges */
1869
+ CVAPI(int) cvGraphRemoveVtx(CvGraph *graph, int index);
1870
+ CVAPI(int) cvGraphRemoveVtxByPtr(CvGraph *graph, CvGraphVtx *vtx);
1871
+
1872
+ /** Link two vertices specified by indices or pointers if they
1873
+ are not connected or return pointer to already existing edge
1874
+ connecting the vertices.
1875
+ Functions return 1 if a new edge was created, 0 otherwise */
1876
+ CVAPI(int)
1877
+ cvGraphAddEdge(CvGraph *graph, int start_idx, int end_idx,
1878
+ const CvGraphEdge *edge CV_DEFAULT(NULL),
1879
+ CvGraphEdge **inserted_edge CV_DEFAULT(NULL));
1880
+
1881
+ CVAPI(int)
1882
+ cvGraphAddEdgeByPtr(CvGraph *graph, CvGraphVtx *start_vtx, CvGraphVtx *end_vtx,
1883
+ const CvGraphEdge *edge CV_DEFAULT(NULL),
1884
+ CvGraphEdge **inserted_edge CV_DEFAULT(NULL));
1885
+
1886
+ /** Remove edge connecting two vertices */
1887
+ CVAPI(void) cvGraphRemoveEdge(CvGraph *graph, int start_idx, int end_idx);
1888
+ CVAPI(void)
1889
+ cvGraphRemoveEdgeByPtr(CvGraph *graph, CvGraphVtx *start_vtx,
1890
+ CvGraphVtx *end_vtx);
1891
+
1892
+ /** Find edge connecting two vertices */
1893
+ CVAPI(CvGraphEdge *)
1894
+ cvFindGraphEdge(const CvGraph *graph, int start_idx, int end_idx);
1895
+ CVAPI(CvGraphEdge *)
1896
+ cvFindGraphEdgeByPtr(const CvGraph *graph, const CvGraphVtx *start_vtx,
1897
+ const CvGraphVtx *end_vtx);
1898
+ #define cvGraphFindEdge cvFindGraphEdge
1899
+ #define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr
1900
+
1901
+ /** Remove all vertices and edges from the graph */
1902
+ CVAPI(void) cvClearGraph(CvGraph *graph);
1903
+
1904
+ /** Count number of edges incident to the vertex */
1905
+ CVAPI(int) cvGraphVtxDegree(const CvGraph *graph, int vtx_idx);
1906
+ CVAPI(int) cvGraphVtxDegreeByPtr(const CvGraph *graph, const CvGraphVtx *vtx);
1907
+
1908
+ /** Retrieves graph vertex by given index */
1909
+ #define cvGetGraphVtx(graph, idx) \
1910
+ (CvGraphVtx *)cvGetSetElem((CvSet *)(graph), (idx))
1911
+
1912
+ /** Retrieves index of a graph vertex given its pointer */
1913
+ #define cvGraphVtxIdx(graph, vtx) ((vtx)->flags & CV_SET_ELEM_IDX_MASK)
1914
+
1915
+ /** Retrieves index of a graph edge given its pointer */
1916
+ #define cvGraphEdgeIdx(graph, edge) ((edge)->flags & CV_SET_ELEM_IDX_MASK)
1917
+
1918
+ #define cvGraphGetVtxCount(graph) ((graph)->active_count)
1919
+ #define cvGraphGetEdgeCount(graph) ((graph)->edges->active_count)
1920
+
1921
+ #define CV_GRAPH_VERTEX 1
1922
+ #define CV_GRAPH_TREE_EDGE 2
1923
+ #define CV_GRAPH_BACK_EDGE 4
1924
+ #define CV_GRAPH_FORWARD_EDGE 8
1925
+ #define CV_GRAPH_CROSS_EDGE 16
1926
+ #define CV_GRAPH_ANY_EDGE 30
1927
+ #define CV_GRAPH_NEW_TREE 32
1928
+ #define CV_GRAPH_BACKTRACKING 64
1929
+ #define CV_GRAPH_OVER -1
1930
+
1931
+ #define CV_GRAPH_ALL_ITEMS -1
1932
+
1933
+ /** flags for graph vertices and edges */
1934
+ #define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30)
1935
+ #define CV_IS_GRAPH_VERTEX_VISITED(vtx) \
1936
+ (((CvGraphVtx *)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG)
1937
+ #define CV_IS_GRAPH_EDGE_VISITED(edge) \
1938
+ (((CvGraphEdge *)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG)
1939
+ #define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29)
1940
+ #define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28)
1941
+
1942
+ typedef struct CvGraphScanner {
1943
+ CvGraphVtx *vtx; /* current graph vertex (or current edge origin) */
1944
+ CvGraphVtx *dst; /* current graph edge destination vertex */
1945
+ CvGraphEdge *edge; /* current edge */
1946
+
1947
+ CvGraph *graph; /* the graph */
1948
+ CvSeq *stack; /* the graph vertex stack */
1949
+ int index; /* the lower bound of certainly visited vertices */
1950
+ int mask; /* event mask */
1951
+ } CvGraphScanner;
1952
+
1953
+ /** Creates new graph scanner. */
1954
+ CVAPI(CvGraphScanner *)
1955
+ cvCreateGraphScanner(CvGraph *graph, CvGraphVtx *vtx CV_DEFAULT(NULL),
1956
+ int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
1957
+
1958
+ /** Releases graph scanner. */
1959
+ CVAPI(void) cvReleaseGraphScanner(CvGraphScanner **scanner);
1960
+
1961
+ /** Get next graph element */
1962
+ CVAPI(int) cvNextGraphItem(CvGraphScanner *scanner);
1963
+
1964
+ /** Creates a copy of graph */
1965
+ CVAPI(CvGraph *) cvCloneGraph(const CvGraph *graph, CvMemStorage *storage);
1966
+
1967
+ /** Does look-up transformation. Elements of the source array
1968
+ (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table
1969
+ */
1970
+ CVAPI(void) cvLUT(const CvArr *src, CvArr *dst, const CvArr *lut);
1971
+
1972
+ /******************* Iteration through the sequence tree *****************/
1973
+ typedef struct CvTreeNodeIterator {
1974
+ const void *node;
1975
+ int level;
1976
+ int max_level;
1977
+ } CvTreeNodeIterator;
1978
+
1979
+ CVAPI(void)
1980
+ cvInitTreeNodeIterator(CvTreeNodeIterator *tree_iterator, const void *first,
1981
+ int max_level);
1982
+ CVAPI(void *) cvNextTreeNode(CvTreeNodeIterator *tree_iterator);
1983
+ CVAPI(void *) cvPrevTreeNode(CvTreeNodeIterator *tree_iterator);
1984
+
1985
+ /** Inserts sequence into tree with specified "parent" sequence.
1986
+ If parent is equal to frame (e.g. the most external contour),
1987
+ then added contour will have null pointer to parent. */
1988
+ CVAPI(void) cvInsertNodeIntoTree(void *node, void *parent, void *frame);
1989
+
1990
+ /** Removes contour from tree (together with the contour children). */
1991
+ CVAPI(void) cvRemoveNodeFromTree(void *node, void *frame);
1992
+
1993
+ /** Gathers pointers to all the sequences,
1994
+ accessible from the `first`, to the single sequence */
1995
+ CVAPI(CvSeq *)
1996
+ cvTreeToNodeSeq(const void *first, int header_size, CvMemStorage *storage);
1997
+
1998
+ /** The function implements the K-means algorithm for clustering an array of
1999
+ sample vectors in a specified number of classes */
2000
+ #define CV_KMEANS_USE_INITIAL_LABELS 1
2001
+ CVAPI(int)
2002
+ cvKMeans2(const CvArr *samples, int cluster_count, CvArr *labels,
2003
+ CvTermCriteria termcrit, int attempts CV_DEFAULT(1),
2004
+ CvRNG *rng CV_DEFAULT(0), int flags CV_DEFAULT(0),
2005
+ CvArr *_centers CV_DEFAULT(0), double *compactness CV_DEFAULT(0));
2006
+
2007
+ /****************************************************************************************\
2008
+ * System functions *
2009
+ \****************************************************************************************/
2010
+
2011
+ /** Loads optimized functions from IPP, MKL etc. or switches back to pure C code
2012
+ */
2013
+ CVAPI(int) cvUseOptimized(int on_off);
2014
+
2015
+ typedef IplImage *(CV_STDCALL *Cv_iplCreateImageHeader)(int, int, int, char *,
2016
+ char *, int, int, int,
2017
+ int, int, IplROI *,
2018
+ IplImage *, void *,
2019
+ IplTileInfo *);
2020
+ typedef void(CV_STDCALL *Cv_iplAllocateImageData)(IplImage *, int, int);
2021
+ typedef void(CV_STDCALL *Cv_iplDeallocate)(IplImage *, int);
2022
+ typedef IplROI *(CV_STDCALL *Cv_iplCreateROI)(int, int, int, int, int);
2023
+ typedef IplImage *(CV_STDCALL *Cv_iplCloneImage)(const IplImage *);
2024
+
2025
+ /** @brief Makes OpenCV use IPL functions for allocating IplImage and IplROI
2026
+ structures.
2027
+
2028
+ Normally, the function is not called directly. Instead, a simple macro
2029
+ CV_TURN_ON_IPL_COMPATIBILITY() is used that calls cvSetIPLAllocators and passes
2030
+ there pointers to IPL allocation functions. :
2031
+ @code
2032
+ ...
2033
+ CV_TURN_ON_IPL_COMPATIBILITY()
2034
+ ...
2035
+ @endcode
2036
+ @param create_header pointer to a function, creating IPL image header.
2037
+ @param allocate_data pointer to a function, allocating IPL image data.
2038
+ @param deallocate pointer to a function, deallocating IPL image.
2039
+ @param create_roi pointer to a function, creating IPL image ROI (i.e. Region of
2040
+ Interest).
2041
+ @param clone_image pointer to a function, cloning an IPL image.
2042
+ */
2043
+ CVAPI(void)
2044
+ cvSetIPLAllocators(Cv_iplCreateImageHeader create_header,
2045
+ Cv_iplAllocateImageData allocate_data,
2046
+ Cv_iplDeallocate deallocate, Cv_iplCreateROI create_roi,
2047
+ Cv_iplCloneImage clone_image);
2048
+
2049
+ #define CV_TURN_ON_IPL_COMPATIBILITY() \
2050
+ cvSetIPLAllocators(iplCreateImageHeader, iplAllocateImage, iplDeallocate, \
2051
+ iplCreateROI, iplCloneImage)
2052
+
2053
+ /****************************************************************************************\
2054
+ * Data Persistence *
2055
+ \****************************************************************************************/
2056
+
2057
+ #if 0
2058
+ /********************************** High-level functions ********************************/
2059
+
2060
+ /** @brief Opens file storage for reading or writing data.
2061
+
2062
+ The function opens file storage for reading or writing data. In the latter case, a new file is
2063
+ created or an existing file is rewritten. The type of the read or written file is determined by the
2064
+ filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON.
2065
+
2066
+ At the same time, it also supports adding parameters like "example.xml?base64".
2067
+
2068
+ The function returns a pointer to the CvFileStorage structure.
2069
+ If the file cannot be opened then the function returns NULL.
2070
+ @param filename Name of the file associated with the storage
2071
+ @param memstorage Memory storage used for temporary data and for
2072
+ : storing dynamic structures, such as CvSeq or CvGraph . If it is NULL, a temporary memory
2073
+ storage is created and used.
2074
+ @param flags Can be one of the following:
2075
+ > - **CV_STORAGE_READ** the storage is open for reading
2076
+ > - **CV_STORAGE_WRITE** the storage is open for writing
2077
+ (use **CV_STORAGE_WRITE | CV_STORAGE_WRITE_BASE64** to write rawdata in Base64)
2078
+ @param encoding
2079
+ */
2080
+ CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage,
2081
+ int flags, const char* encoding CV_DEFAULT(NULL) );
2082
+
2083
+ /** @brief Releases file storage.
2084
+
2085
+ The function closes the file associated with the storage and releases all the temporary structures.
2086
+ It must be called after all I/O operations with the storage are finished.
2087
+ @param fs Double pointer to the released file storage
2088
+ */
2089
+ CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs );
2090
+
2091
+ /** returns attribute value or 0 (NULL) if there is no such attribute */
2092
+ CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name );
2093
+
2094
+ /** @brief Starts writing a new structure.
2095
+
2096
+ The function starts writing a compound structure (collection) that can be a sequence or a map. After
2097
+ all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should
2098
+ be called. The function can be used to group some objects or to implement the write function for a
2099
+ some user object (see CvTypeInfo).
2100
+ @param fs File storage
2101
+ @param name Name of the written structure. The structure can be accessed by this name when the
2102
+ storage is read.
2103
+ @param struct_flags A combination one of the following values:
2104
+ - **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ),
2105
+ that is, its elements do not have a name.
2106
+ - **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that
2107
+ is, all its elements have names.
2108
+ One and only one of the two above flags must be specified
2109
+ - **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that
2110
+ the structure is written as a flow (not as a block), which is more compact. It is
2111
+ recommended to use this flag for structures or arrays whose elements are all scalars.
2112
+ @param type_name Optional parameter - the object type name. In
2113
+ case of XML it is written as a type_id attribute of the structure opening tag. In the case of
2114
+ YAML it is written after a colon following the structure name (see the example in
2115
+ CvFileStorage description). In case of JSON it is written as a name/value pair.
2116
+ Mainly it is used with user objects. When the storage is read, the
2117
+ encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ).
2118
+ @param attributes This parameter is not used in the current implementation
2119
+ */
2120
+ CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name,
2121
+ int struct_flags, const char* type_name CV_DEFAULT(NULL),
2122
+ CvAttrList attributes CV_DEFAULT(cvAttrList()));
2123
+
2124
+ /** @brief Finishes writing to a file node collection.
2125
+ @param fs File storage
2126
+ @sa cvStartWriteStruct.
2127
+ */
2128
+ CVAPI(void) cvEndWriteStruct( CvFileStorage* fs );
2129
+
2130
+ /** @brief Writes an integer value.
2131
+
2132
+ The function writes a single integer value (with or without a name) to the file storage.
2133
+ @param fs File storage
2134
+ @param name Name of the written value. Should be NULL if and only if the parent structure is a
2135
+ sequence.
2136
+ @param value The written value
2137
+ */
2138
+ CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value );
2139
+
2140
+ /** @brief Writes a floating-point value.
2141
+
2142
+ The function writes a single floating-point value (with or without a name) to file storage. Special
2143
+ values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf.
2144
+
2145
+ The following example shows how to use the low-level writing functions to store custom structures,
2146
+ such as termination criteria, without registering a new type. :
2147
+ @code
2148
+ void write_termcriteria( CvFileStorage* fs, const char* struct_name,
2149
+ CvTermCriteria* termcrit )
2150
+ {
2151
+ cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0));
2152
+ cvWriteComment( fs, "termination criteria", 1 ); // just a description
2153
+ if( termcrit->type & CV_TERMCRIT_ITER )
2154
+ cvWriteInteger( fs, "max_iterations", termcrit->max_iter );
2155
+ if( termcrit->type & CV_TERMCRIT_EPS )
2156
+ cvWriteReal( fs, "accuracy", termcrit->epsilon );
2157
+ cvEndWriteStruct( fs );
2158
+ }
2159
+ @endcode
2160
+ @param fs File storage
2161
+ @param name Name of the written value. Should be NULL if and only if the parent structure is a
2162
+ sequence.
2163
+ @param value The written value
2164
+ */
2165
+ CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value );
2166
+
2167
+ /** @brief Writes a text string.
2168
+
2169
+ The function writes a text string to file storage.
2170
+ @param fs File storage
2171
+ @param name Name of the written string . Should be NULL if and only if the parent structure is a
2172
+ sequence.
2173
+ @param str The written text string
2174
+ @param quote If non-zero, the written string is put in quotes, regardless of whether they are
2175
+ required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when
2176
+ the string starts with a digit or contains spaces).
2177
+ */
2178
+ CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name,
2179
+ const char* str, int quote CV_DEFAULT(0) );
2180
+
2181
+ /** @brief Writes a comment.
2182
+
2183
+ The function writes a comment into file storage. The comments are skipped when the storage is read.
2184
+ @param fs File storage
2185
+ @param comment The written comment, single-line or multi-line
2186
+ @param eol_comment If non-zero, the function tries to put the comment at the end of current line.
2187
+ If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current
2188
+ line, the comment starts a new line.
2189
+ */
2190
+ CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment,
2191
+ int eol_comment );
2192
+
2193
+ /** @brief Writes an object to file storage.
2194
+
2195
+ The function writes an object to file storage. First, the appropriate type info is found using
2196
+ cvTypeOf. Then, the write method associated with the type info is called.
2197
+
2198
+ Attributes are used to customize the writing procedure. The standard types support the following
2199
+ attributes (all the dt attributes have the same format as in cvWriteRawData):
2200
+
2201
+ -# CvSeq
2202
+ - **header_dt** description of user fields of the sequence header that follow CvSeq, or
2203
+ CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or
2204
+ point sequence)
2205
+ - **dt** description of the sequence elements.
2206
+ - **recursive** if the attribute is present and is not equal to "0" or "false", the whole
2207
+ tree of sequences (contours) is stored.
2208
+ -# CvGraph
2209
+ - **header_dt** description of user fields of the graph header that follows CvGraph;
2210
+ - **vertex_dt** description of user fields of graph vertices
2211
+ - **edge_dt** description of user fields of graph edges (note that the edge weight is
2212
+ always written, so there is no need to specify it explicitly)
2213
+
2214
+ Below is the code that creates the YAML file shown in the CvFileStorage description:
2215
+ @code
2216
+ #include "cxcore.h"
2217
+
2218
+ int main( int argc, char** argv )
2219
+ {
2220
+ CvMat* mat = cvCreateMat( 3, 3, CV_32F );
2221
+ CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE );
2222
+
2223
+ cvSetIdentity( mat );
2224
+ cvWrite( fs, "A", mat, cvAttrList(0,0) );
2225
+
2226
+ cvReleaseFileStorage( &fs );
2227
+ cvReleaseMat( &mat );
2228
+ return 0;
2229
+ }
2230
+ @endcode
2231
+ @param fs File storage
2232
+ @param name Name of the written object. Should be NULL if and only if the parent structure is a
2233
+ sequence.
2234
+ @param ptr Pointer to the object
2235
+ @param attributes The attributes of the object. They are specific for each particular type (see
2236
+ the discussion below).
2237
+ */
2238
+ CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr,
2239
+ CvAttrList attributes CV_DEFAULT(cvAttrList()));
2240
+
2241
+ /** @brief Starts the next stream.
2242
+
2243
+ The function finishes the currently written stream and starts the next stream. In the case of XML
2244
+ the file with multiple streams looks like this:
2245
+ @code{.xml}
2246
+ <opencv_storage>
2247
+ <!-- stream #1 data -->
2248
+ </opencv_storage>
2249
+ <opencv_storage>
2250
+ <!-- stream #2 data -->
2251
+ </opencv_storage>
2252
+ ...
2253
+ @endcode
2254
+ The YAML file will look like this:
2255
+ @code{.yaml}
2256
+ %YAML 1.0
2257
+ # stream #1 data
2258
+ ...
2259
+ ---
2260
+ # stream #2 data
2261
+ @endcode
2262
+ This is useful for concatenating files or for resuming the writing process.
2263
+ @param fs File storage
2264
+ */
2265
+ CVAPI(void) cvStartNextStream( CvFileStorage* fs );
2266
+
2267
+ /** @brief Writes multiple numbers.
2268
+
2269
+ The function writes an array, whose elements consist of single or multiple numbers. The function
2270
+ call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single
2271
+ call is more efficient. Note that because none of the elements have a name, they should be written
2272
+ to a sequence rather than a map.
2273
+ @param fs File storage
2274
+ @param src Pointer to the written array
2275
+ @param len Number of the array elements to write
2276
+ @param dt Specification of each array element, see @ref format_spec "format specification"
2277
+ */
2278
+ CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src,
2279
+ int len, const char* dt );
2280
+
2281
+ /** @brief Writes multiple numbers in Base64.
2282
+
2283
+ If either CV_STORAGE_WRITE_BASE64 or cv::FileStorage::WRITE_BASE64 is used,
2284
+ this function will be the same as cvWriteRawData. If neither, the main
2285
+ difference is that it outputs a sequence in Base64 encoding rather than
2286
+ in plain text.
2287
+
2288
+ This function can only be used to write a sequence with a type "binary".
2289
+
2290
+ @param fs File storage
2291
+ @param src Pointer to the written array
2292
+ @param len Number of the array elements to write
2293
+ @param dt Specification of each array element, see @ref format_spec "format specification"
2294
+ */
2295
+ CVAPI(void) cvWriteRawDataBase64( CvFileStorage* fs, const void* src,
2296
+ int len, const char* dt );
2297
+
2298
+ /** @brief Returns a unique pointer for a given name.
2299
+
2300
+ The function returns a unique pointer for each particular file node name. This pointer can be then
2301
+ passed to the cvGetFileNode function that is faster than cvGetFileNodeByName because it compares
2302
+ text strings by comparing pointers rather than the strings' content.
2303
+
2304
+ Consider the following example where an array of points is encoded as a sequence of 2-entry maps:
2305
+ @code
2306
+ points:
2307
+ - { x: 10, y: 10 }
2308
+ - { x: 20, y: 20 }
2309
+ - { x: 30, y: 30 }
2310
+ # ...
2311
+ @endcode
2312
+ Then, it is possible to get hashed "x" and "y" pointers to speed up decoding of the points. :
2313
+ @code
2314
+ #include "cxcore.h"
2315
+
2316
+ int main( int argc, char** argv )
2317
+ {
2318
+ CvFileStorage* fs = cvOpenFileStorage( "points.yml", 0, CV_STORAGE_READ );
2319
+ CvStringHashNode* x_key = cvGetHashedNode( fs, "x", -1, 1 );
2320
+ CvStringHashNode* y_key = cvGetHashedNode( fs, "y", -1, 1 );
2321
+ CvFileNode* points = cvGetFileNodeByName( fs, 0, "points" );
2322
+
2323
+ if( CV_NODE_IS_SEQ(points->tag) )
2324
+ {
2325
+ CvSeq* seq = points->data.seq;
2326
+ int i, total = seq->total;
2327
+ CvSeqReader reader;
2328
+ cvStartReadSeq( seq, &reader, 0 );
2329
+ for( i = 0; i < total; i++ )
2330
+ {
2331
+ CvFileNode* pt = (CvFileNode*)reader.ptr;
2332
+ #if 1 // faster variant
2333
+ CvFileNode* xnode = cvGetFileNode( fs, pt, x_key, 0 );
2334
+ CvFileNode* ynode = cvGetFileNode( fs, pt, y_key, 0 );
2335
+ assert( xnode && CV_NODE_IS_INT(xnode->tag) &&
2336
+ ynode && CV_NODE_IS_INT(ynode->tag));
2337
+ int x = xnode->data.i; // or x = cvReadInt( xnode, 0 );
2338
+ int y = ynode->data.i; // or y = cvReadInt( ynode, 0 );
2339
+ #elif 1 // slower variant; does not use x_key & y_key
2340
+ CvFileNode* xnode = cvGetFileNodeByName( fs, pt, "x" );
2341
+ CvFileNode* ynode = cvGetFileNodeByName( fs, pt, "y" );
2342
+ assert( xnode && CV_NODE_IS_INT(xnode->tag) &&
2343
+ ynode && CV_NODE_IS_INT(ynode->tag));
2344
+ int x = xnode->data.i; // or x = cvReadInt( xnode, 0 );
2345
+ int y = ynode->data.i; // or y = cvReadInt( ynode, 0 );
2346
+ #else // the slowest yet the easiest to use variant
2347
+ int x = cvReadIntByName( fs, pt, "x", 0 );
2348
+ int y = cvReadIntByName( fs, pt, "y", 0 );
2349
+ #endif
2350
+ CV_NEXT_SEQ_ELEM( seq->elem_size, reader );
2351
+ printf("
2352
+ }
2353
+ }
2354
+ cvReleaseFileStorage( &fs );
2355
+ return 0;
2356
+ }
2357
+ @endcode
2358
+ Please note that whatever method of accessing a map you are using, it is still much slower than
2359
+ using plain sequences; for example, in the above example, it is more efficient to encode the points
2360
+ as pairs of integers in a single numeric sequence.
2361
+ @param fs File storage
2362
+ @param name Literal node name
2363
+ @param len Length of the name (if it is known apriori), or -1 if it needs to be calculated
2364
+ @param create_missing Flag that specifies, whether an absent key should be added into the hash table
2365
+ */
2366
+ CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name,
2367
+ int len CV_DEFAULT(-1),
2368
+ int create_missing CV_DEFAULT(0));
2369
+
2370
+ /** @brief Retrieves one of the top-level nodes of the file storage.
2371
+
2372
+ The function returns one of the top-level file nodes. The top-level nodes do not have a name, they
2373
+ correspond to the streams that are stored one after another in the file storage. If the index is out
2374
+ of range, the function returns a NULL pointer, so all the top-level nodes can be iterated by
2375
+ subsequent calls to the function with stream_index=0,1,..., until the NULL pointer is returned.
2376
+ This function can be used as a base for recursive traversal of the file storage.
2377
+ @param fs File storage
2378
+ @param stream_index Zero-based index of the stream. See cvStartNextStream . In most cases,
2379
+ there is only one stream in the file; however, there can be several.
2380
+ */
2381
+ CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs,
2382
+ int stream_index CV_DEFAULT(0) );
2383
+
2384
+ /** @brief Finds a node in a map or file storage.
2385
+
2386
+ The function finds a file node. It is a faster version of cvGetFileNodeByName (see
2387
+ cvGetHashedKey discussion). Also, the function can insert a new node, if it is not in the map yet.
2388
+ @param fs File storage
2389
+ @param map The parent map. If it is NULL, the function searches a top-level node. If both map and
2390
+ key are NULLs, the function returns the root file node - a map that contains top-level nodes.
2391
+ @param key Unique pointer to the node name, retrieved with cvGetHashedKey
2392
+ @param create_missing Flag that specifies whether an absent node should be added to the map
2393
+ */
2394
+ CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map,
2395
+ const CvStringHashNode* key,
2396
+ int create_missing CV_DEFAULT(0) );
2397
+
2398
+ /** @brief Finds a node in a map or file storage.
2399
+
2400
+ The function finds a file node by name. The node is searched either in map or, if the pointer is
2401
+ NULL, among the top-level file storage nodes. Using this function for maps and cvGetSeqElem (or
2402
+ sequence reader) for sequences, it is possible to navigate through the file storage. To speed up
2403
+ multiple queries for a certain key (e.g., in the case of an array of structures) one may use a
2404
+ combination of cvGetHashedKey and cvGetFileNode.
2405
+ @param fs File storage
2406
+ @param map The parent map. If it is NULL, the function searches in all the top-level nodes
2407
+ (streams), starting with the first one.
2408
+ @param name The file node name
2409
+ */
2410
+ CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs,
2411
+ const CvFileNode* map,
2412
+ const char* name );
2413
+
2414
+ /** @brief Retrieves an integer value from a file node.
2415
+
2416
+ The function returns an integer that is represented by the file node. If the file node is NULL, the
2417
+ default_value is returned (thus, it is convenient to call the function right after cvGetFileNode
2418
+ without checking for a NULL pointer). If the file node has type CV_NODE_INT, then node-\>data.i is
2419
+ returned. If the file node has type CV_NODE_REAL, then node-\>data.f is converted to an integer
2420
+ and returned. Otherwise the error is reported.
2421
+ @param node File node
2422
+ @param default_value The value that is returned if node is NULL
2423
+ */
2424
+ CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) )
2425
+ {
2426
+ return !node ? default_value :
2427
+ CV_NODE_IS_INT(node->tag) ? node->data.i :
2428
+ CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff;
2429
+ }
2430
+
2431
+ /** @brief Finds a file node and returns its value.
2432
+
2433
+ The function is a simple superposition of cvGetFileNodeByName and cvReadInt.
2434
+ @param fs File storage
2435
+ @param map The parent map. If it is NULL, the function searches a top-level node.
2436
+ @param name The node name
2437
+ @param default_value The value that is returned if the file node is not found
2438
+ */
2439
+ CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map,
2440
+ const char* name, int default_value CV_DEFAULT(0) )
2441
+ {
2442
+ return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value );
2443
+ }
2444
+
2445
+ /** @brief Retrieves a floating-point value from a file node.
2446
+
2447
+ The function returns a floating-point value that is represented by the file node. If the file node
2448
+ is NULL, the default_value is returned (thus, it is convenient to call the function right after
2449
+ cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_REAL ,
2450
+ then node-\>data.f is returned. If the file node has type CV_NODE_INT , then node-:math:\>data.f
2451
+ is converted to floating-point and returned. Otherwise the result is not determined.
2452
+ @param node File node
2453
+ @param default_value The value that is returned if node is NULL
2454
+ */
2455
+ CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) )
2456
+ {
2457
+ return !node ? default_value :
2458
+ CV_NODE_IS_INT(node->tag) ? (double)node->data.i :
2459
+ CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300;
2460
+ }
2461
+
2462
+ /** @brief Finds a file node and returns its value.
2463
+
2464
+ The function is a simple superposition of cvGetFileNodeByName and cvReadReal .
2465
+ @param fs File storage
2466
+ @param map The parent map. If it is NULL, the function searches a top-level node.
2467
+ @param name The node name
2468
+ @param default_value The value that is returned if the file node is not found
2469
+ */
2470
+ CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map,
2471
+ const char* name, double default_value CV_DEFAULT(0.) )
2472
+ {
2473
+ return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value );
2474
+ }
2475
+
2476
+ /** @brief Retrieves a text string from a file node.
2477
+
2478
+ The function returns a text string that is represented by the file node. If the file node is NULL,
2479
+ the default_value is returned (thus, it is convenient to call the function right after
2480
+ cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_STR , then
2481
+ node-:math:\>data.str.ptr is returned. Otherwise the result is not determined.
2482
+ @param node File node
2483
+ @param default_value The value that is returned if node is NULL
2484
+ */
2485
+ CV_INLINE const char* cvReadString( const CvFileNode* node,
2486
+ const char* default_value CV_DEFAULT(NULL) )
2487
+ {
2488
+ return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0;
2489
+ }
2490
+
2491
+ /** @brief Finds a file node by its name and returns its value.
2492
+
2493
+ The function is a simple superposition of cvGetFileNodeByName and cvReadString .
2494
+ @param fs File storage
2495
+ @param map The parent map. If it is NULL, the function searches a top-level node.
2496
+ @param name The node name
2497
+ @param default_value The value that is returned if the file node is not found
2498
+ */
2499
+ CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map,
2500
+ const char* name, const char* default_value CV_DEFAULT(NULL) )
2501
+ {
2502
+ return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value );
2503
+ }
2504
+
2505
+
2506
+ /** @brief Decodes an object and returns a pointer to it.
2507
+
2508
+ The function decodes a user object (creates an object in a native representation from the file
2509
+ storage subtree) and returns it. The object to be decoded must be an instance of a registered type
2510
+ that supports the read method (see CvTypeInfo). The type of the object is determined by the type
2511
+ name that is encoded in the file. If the object is a dynamic structure, it is created either in
2512
+ memory storage and passed to cvOpenFileStorage or, if a NULL pointer was passed, in temporary
2513
+ memory storage, which is released when cvReleaseFileStorage is called. Otherwise, if the object is
2514
+ not a dynamic structure, it is created in a heap and should be released with a specialized function
2515
+ or by using the generic cvRelease.
2516
+ @param fs File storage
2517
+ @param node The root object node
2518
+ @param attributes Unused parameter
2519
+ */
2520
+ CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node,
2521
+ CvAttrList* attributes CV_DEFAULT(NULL));
2522
+
2523
+ /** @brief Finds an object by name and decodes it.
2524
+
2525
+ The function is a simple superposition of cvGetFileNodeByName and cvRead.
2526
+ @param fs File storage
2527
+ @param map The parent map. If it is NULL, the function searches a top-level node.
2528
+ @param name The node name
2529
+ @param attributes Unused parameter
2530
+ */
2531
+ CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map,
2532
+ const char* name, CvAttrList* attributes CV_DEFAULT(NULL) )
2533
+ {
2534
+ return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes );
2535
+ }
2536
+
2537
+
2538
+ /** @brief Initializes the file node sequence reader.
2539
+
2540
+ The function initializes the sequence reader to read data from a file node. The initialized reader
2541
+ can be then passed to cvReadRawDataSlice.
2542
+ @param fs File storage
2543
+ @param src The file node (a sequence) to read numbers from
2544
+ @param reader Pointer to the sequence reader
2545
+ */
2546
+ CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src,
2547
+ CvSeqReader* reader );
2548
+
2549
+ /** @brief Initializes file node sequence reader.
2550
+
2551
+ The function reads one or more elements from the file node, representing a sequence, to a
2552
+ user-specified array. The total number of read sequence elements is a product of total and the
2553
+ number of components in each array element. For example, if dt=2if, the function will read total\*3
2554
+ sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read
2555
+ repeatedly by repositioning the reader using cvSetSeqReaderPos.
2556
+ @param fs File storage
2557
+ @param reader The sequence reader. Initialize it with cvStartReadRawData .
2558
+ @param count The number of elements to read
2559
+ @param dst Pointer to the destination array
2560
+ @param dt Specification of each array element. It has the same format as in cvWriteRawData .
2561
+ */
2562
+ CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
2563
+ int count, void* dst, const char* dt );
2564
+
2565
+ /** @brief Reads multiple numbers.
2566
+
2567
+ The function reads elements from a file node that represents a sequence of scalars.
2568
+ @param fs File storage
2569
+ @param src The file node (a sequence) to read numbers from
2570
+ @param dst Pointer to the destination array
2571
+ @param dt Specification of each array element. It has the same format as in cvWriteRawData .
2572
+ */
2573
+ CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src,
2574
+ void* dst, const char* dt );
2575
+
2576
+ /** @brief Writes a file node to another file storage.
2577
+
2578
+ The function writes a copy of a file node to file storage. Possible applications of the function are
2579
+ merging several file storages into one and conversion between XML, YAML and JSON formats.
2580
+ @param fs Destination file storage
2581
+ @param new_node_name New name of the file node in the destination file storage. To keep the
2582
+ existing name, use cvcvGetFileNodeName
2583
+ @param node The written node
2584
+ @param embed If the written node is a collection and this parameter is not zero, no extra level of
2585
+ hierarchy is created. Instead, all the elements of node are written into the currently written
2586
+ structure. Of course, map elements can only be embedded into another map, and sequence elements
2587
+ can only be embedded into another sequence.
2588
+ */
2589
+ CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name,
2590
+ const CvFileNode* node, int embed );
2591
+
2592
+ /** @brief Returns the name of a file node.
2593
+
2594
+ The function returns the name of a file node or NULL, if the file node does not have a name or if
2595
+ node is NULL.
2596
+ @param node File node
2597
+ */
2598
+ CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node );
2599
+
2600
+ /*********************************** Adding own types ***********************************/
2601
+
2602
+ /** @brief Registers a new type.
2603
+
2604
+ The function registers a new type, which is described by info . The function creates a copy of the
2605
+ structure, so the user should delete it after calling the function.
2606
+ @param info Type info structure
2607
+ */
2608
+ CVAPI(void) cvRegisterType( const CvTypeInfo* info );
2609
+
2610
+ /** @brief Unregisters the type.
2611
+
2612
+ The function unregisters a type with a specified name. If the name is unknown, it is possible to
2613
+ locate the type info by an instance of the type using cvTypeOf or by iterating the type list,
2614
+ starting from cvFirstType, and then calling cvUnregisterType(info-\>typeName).
2615
+ @param type_name Name of an unregistered type
2616
+ */
2617
+ CVAPI(void) cvUnregisterType( const char* type_name );
2618
+
2619
+ /** @brief Returns the beginning of a type list.
2620
+
2621
+ The function returns the first type in the list of registered types. Navigation through the list can
2622
+ be done via the prev and next fields of the CvTypeInfo structure.
2623
+ */
2624
+ CVAPI(CvTypeInfo*) cvFirstType(void);
2625
+
2626
+ /** @brief Finds a type by its name.
2627
+
2628
+ The function finds a registered type by its name. It returns NULL if there is no type with the
2629
+ specified name.
2630
+ @param type_name Type name
2631
+ */
2632
+ CVAPI(CvTypeInfo*) cvFindType( const char* type_name );
2633
+
2634
+ /** @brief Returns the type of an object.
2635
+
2636
+ The function finds the type of a given object. It iterates through the list of registered types and
2637
+ calls the is_instance function/method for every type info structure with that object until one of
2638
+ them returns non-zero or until the whole list has been traversed. In the latter case, the function
2639
+ returns NULL.
2640
+ @param struct_ptr The object pointer
2641
+ */
2642
+ CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr );
2643
+
2644
+ #endif
2645
+
2646
+ /** @brief Releases an object.
2647
+
2648
+ The function finds the type of a given object and calls release with the double
2649
+ pointer.
2650
+ @param struct_ptr Double pointer to the object
2651
+ */
2652
+ CVAPI(void) cvRelease(void **struct_ptr);
2653
+
2654
+ /** @brief Makes a clone of an object.
2655
+
2656
+ The function finds the type of a given object and calls clone with the passed
2657
+ object. Of course, if you know the object type, for example, struct_ptr is
2658
+ CvMat\*, it is faster to call the specific function, like cvCloneMat.
2659
+ @param struct_ptr The object to clone
2660
+ */
2661
+ CVAPI(void *) cvClone(const void *struct_ptr);
2662
+
2663
+ /*********************************** Measuring Execution Time
2664
+ * ***************************/
2665
+
2666
+ /** helper functions for RNG initialization and accurate time measurement:
2667
+ uses internal clock counter on x86 */
2668
+ CVAPI(int64) cvGetTickCount(void);
2669
+ CVAPI(double) cvGetTickFrequency(void);
2670
+
2671
+ /*********************************** CPU capabilities
2672
+ * ***********************************/
2673
+
2674
+ CVAPI(int) cvCheckHardwareSupport(int feature);
2675
+
2676
+ /*********************************** Multi-Threading
2677
+ * ************************************/
2678
+
2679
+ /** retrieve/set the number of threads used in OpenMP implementations */
2680
+ CVAPI(int) cvGetNumThreads(void);
2681
+ CVAPI(void) cvSetNumThreads(int threads CV_DEFAULT(0));
2682
+ /** get index of the thread being executed */
2683
+ CVAPI(int) cvGetThreadNum(void);
2684
+
2685
+ /********************************** Error Handling
2686
+ * **************************************/
2687
+
2688
+ /** Get current OpenCV error status */
2689
+ CVAPI(int) cvGetErrStatus(void);
2690
+
2691
+ /** Sets error status silently */
2692
+ CVAPI(void) cvSetErrStatus(int status);
2693
+
2694
+ #define CV_ErrModeLeaf 0 /* Print error and exit program */
2695
+ #define CV_ErrModeParent 1 /* Print error and continue */
2696
+ #define CV_ErrModeSilent 2 /* Don't print and continue */
2697
+
2698
+ /** Retrieves current error processing mode */
2699
+ CVAPI(int) cvGetErrMode(void);
2700
+
2701
+ /** Sets error processing mode, returns previously used mode */
2702
+ CVAPI(int) cvSetErrMode(int mode);
2703
+
2704
+ /** Sets error status and performs some additional actions (displaying message
2705
+ box, writing message to stderr, terminating application etc.) depending on the
2706
+ current error mode */
2707
+ CVAPI(void)
2708
+ cvError(int status, const char *func_name, const char *err_msg,
2709
+ const char *file_name, int line);
2710
+
2711
+ /** Retrieves textual description of the error given its code */
2712
+ CVAPI(const char *) cvErrorStr(int status);
2713
+
2714
+ /** Retrieves detailed information about the last error occurred */
2715
+ CVAPI(int)
2716
+ cvGetErrInfo(const char **errcode_desc, const char **description,
2717
+ const char **filename, int *line);
2718
+
2719
+ /** Maps IPP error codes to the counterparts from OpenCV */
2720
+ CVAPI(int) cvErrorFromIppStatus(int ipp_status);
2721
+
2722
+ typedef int(CV_CDECL *CvErrorCallback)(int status, const char *func_name,
2723
+ const char *err_msg,
2724
+ const char *file_name, int line,
2725
+ void *userdata);
2726
+
2727
+ /** Assigns a new error-handling function */
2728
+ CVAPI(CvErrorCallback)
2729
+ cvRedirectError(CvErrorCallback error_handler, void *userdata CV_DEFAULT(NULL),
2730
+ void **prev_userdata CV_DEFAULT(NULL));
2731
+
2732
+ /** Output nothing */
2733
+ CVAPI(int)
2734
+ cvNulDevReport(int status, const char *func_name, const char *err_msg,
2735
+ const char *file_name, int line, void *userdata);
2736
+
2737
+ /** Output to console(fprintf(stderr,...)) */
2738
+ CVAPI(int)
2739
+ cvStdErrReport(int status, const char *func_name, const char *err_msg,
2740
+ const char *file_name, int line, void *userdata);
2741
+
2742
+ /** Output to MessageBox(WIN32) */
2743
+ CVAPI(int)
2744
+ cvGuiBoxReport(int status, const char *func_name, const char *err_msg,
2745
+ const char *file_name, int line, void *userdata);
2746
+
2747
+ #define OPENCV_ERROR(status, func, context) \
2748
+ cvError((status), (func), (context), __FILE__, __LINE__)
2749
+
2750
+ #define OPENCV_ASSERT(expr, func, context) \
2751
+ { \
2752
+ if (!(expr)) { \
2753
+ OPENCV_ERROR(CV_StsInternal, (func), (context)); \
2754
+ } \
2755
+ }
2756
+
2757
+ #define OPENCV_CALL(Func) \
2758
+ { \
2759
+ Func; \
2760
+ }
2761
+
2762
+ /** CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR
2763
+ * macro */
2764
+ #ifdef CV_NO_FUNC_NAMES
2765
+ #define CV_FUNCNAME(Name)
2766
+ #define cvFuncName ""
2767
+ #else
2768
+ #define CV_FUNCNAME(Name) static char cvFuncName[] = Name
2769
+ #endif
2770
+
2771
+ /**
2772
+ CV_ERROR macro unconditionally raises error with passed code and message.
2773
+ After raising error, control will be transferred to the exit label.
2774
+ */
2775
+ #define CV_ERROR(Code, Msg) \
2776
+ { \
2777
+ cvError((Code), cvFuncName, Msg, __FILE__, __LINE__); \
2778
+ __CV_EXIT__; \
2779
+ }
2780
+
2781
+ /**
2782
+ CV_CHECK macro checks error status after CV (or IPL)
2783
+ function call. If error detected, control will be transferred to the exit
2784
+ label.
2785
+ */
2786
+ #define CV_CHECK() \
2787
+ { \
2788
+ if (cvGetErrStatus() < 0) \
2789
+ CV_ERROR(CV_StsBackTrace, "Inner function failed."); \
2790
+ }
2791
+
2792
+ /**
2793
+ CV_CALL macro calls CV (or IPL) function, checks error status and
2794
+ signals a error if the function failed. Useful in "parent node"
2795
+ error processing mode
2796
+ */
2797
+ #define CV_CALL(Func) \
2798
+ { \
2799
+ Func; \
2800
+ CV_CHECK(); \
2801
+ }
2802
+
2803
+ /** Runtime assertion macro */
2804
+ #define CV_ASSERT(Condition) \
2805
+ { \
2806
+ if (!(Condition)) \
2807
+ CV_ERROR(CV_StsInternal, "Assertion: " #Condition " failed"); \
2808
+ }
2809
+
2810
+ #define __CV_BEGIN__ {
2811
+ #define __CV_END__ \
2812
+ goto exit; \
2813
+ exit:; \
2814
+ }
2815
+ #define __CV_EXIT__ goto exit
2816
+
2817
+ /** @} core_c */
2818
+
2819
+ #ifdef __cplusplus
2820
+ } // extern "C"
2821
+ #endif
2822
+
2823
+ #ifdef __cplusplus
2824
+
2825
+ #include "opencv2/core/utility.hpp"
2826
+
2827
+ namespace cv {
2828
+
2829
+ //! @addtogroup core_c_glue
2830
+ //! @{
2831
+
2832
+ /////////////////////////////////////////// glue
2833
+ //////////////////////////////////////////////
2834
+
2835
+ //! converts array (CvMat or IplImage) to cv::Mat
2836
+ CV_EXPORTS Mat cvarrToMat(const CvArr *arr, bool copyData = false,
2837
+ bool allowND = true, int coiMode = 0,
2838
+ AutoBuffer<double> *buf = 0);
2839
+
2840
+ static inline Mat cvarrToMatND(const CvArr *arr, bool copyData = false,
2841
+ int coiMode = 0) {
2842
+ return cvarrToMat(arr, copyData, true, coiMode);
2843
+ }
2844
+
2845
+ //! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of
2846
+ //! it.
2847
+ CV_EXPORTS void extractImageCOI(const CvArr *arr, OutputArray coiimg,
2848
+ int coi = -1);
2849
+ //! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage
2850
+ CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr *arr, int coi = -1);
2851
+
2852
+ ////// specialized implementations of DefaultDeleter::operator() for classic
2853
+ /// OpenCV types //////
2854
+
2855
+ template <> struct DefaultDeleter<CvMat> {
2856
+ CV_EXPORTS void operator()(CvMat *obj) const;
2857
+ };
2858
+ template <> struct DefaultDeleter<IplImage> {
2859
+ CV_EXPORTS void operator()(IplImage *obj) const;
2860
+ };
2861
+ template <> struct DefaultDeleter<CvMatND> {
2862
+ CV_EXPORTS void operator()(CvMatND *obj) const;
2863
+ };
2864
+ template <> struct DefaultDeleter<CvSparseMat> {
2865
+ CV_EXPORTS void operator()(CvSparseMat *obj) const;
2866
+ };
2867
+ template <> struct DefaultDeleter<CvMemStorage> {
2868
+ CV_EXPORTS void operator()(CvMemStorage *obj) const;
2869
+ };
2870
+
2871
+ ////////////// convenient wrappers for operating old-style dynamic structures
2872
+ /////////////////
2873
+
2874
+ template <typename _Tp> class SeqIterator;
2875
+
2876
+ typedef Ptr<CvMemStorage> MemStorage;
2877
+
2878
+ /*!
2879
+ Template Sequence Class derived from CvSeq
2880
+
2881
+ The class provides more convenient access to sequence elements,
2882
+ STL-style operations and iterators.
2883
+
2884
+ \note The class is targeted for simple data types,
2885
+ i.e. no constructors or destructors
2886
+ are called for the sequence elements.
2887
+ */
2888
+ template <typename _Tp> class Seq {
2889
+ public:
2890
+ typedef SeqIterator<_Tp> iterator;
2891
+ typedef SeqIterator<_Tp> const_iterator;
2892
+
2893
+ //! the default constructor
2894
+ Seq();
2895
+ //! the constructor for wrapping CvSeq structure. The real element type in
2896
+ //! CvSeq should match _Tp.
2897
+ Seq(const CvSeq *seq);
2898
+ //! creates the empty sequence that resides in the specified storage
2899
+ Seq(MemStorage &storage, int headerSize = sizeof(CvSeq));
2900
+ //! returns read-write reference to the specified element
2901
+ _Tp &operator[](int idx);
2902
+ //! returns read-only reference to the specified element
2903
+ const _Tp &operator[](int idx) const;
2904
+ //! returns iterator pointing to the beginning of the sequence
2905
+ SeqIterator<_Tp> begin() const;
2906
+ //! returns iterator pointing to the element following the last sequence
2907
+ //! element
2908
+ SeqIterator<_Tp> end() const;
2909
+ //! returns the number of elements in the sequence
2910
+ size_t size() const;
2911
+ //! returns the type of sequence elements (CV_8UC1 ... CV_64FC(CV_CN_MAX) ...)
2912
+ int type() const;
2913
+ //! returns the depth of sequence elements (CV_8U ... CV_64F)
2914
+ int depth() const;
2915
+ //! returns the number of channels in each sequence element
2916
+ int channels() const;
2917
+ //! returns the size of each sequence element
2918
+ size_t elemSize() const;
2919
+ //! returns index of the specified sequence element
2920
+ size_t index(const _Tp &elem) const;
2921
+ //! appends the specified element to the end of the sequence
2922
+ void push_back(const _Tp &elem);
2923
+ //! appends the specified element to the front of the sequence
2924
+ void push_front(const _Tp &elem);
2925
+ //! appends zero or more elements to the end of the sequence
2926
+ void push_back(const _Tp *elems, size_t count);
2927
+ //! appends zero or more elements to the front of the sequence
2928
+ void push_front(const _Tp *elems, size_t count);
2929
+ //! inserts the specified element to the specified position
2930
+ void insert(int idx, const _Tp &elem);
2931
+ //! inserts zero or more elements to the specified position
2932
+ void insert(int idx, const _Tp *elems, size_t count);
2933
+ //! removes element at the specified position
2934
+ void remove(int idx);
2935
+ //! removes the specified subsequence
2936
+ void remove(const Range &r);
2937
+
2938
+ //! returns reference to the first sequence element
2939
+ _Tp &front();
2940
+ //! returns read-only reference to the first sequence element
2941
+ const _Tp &front() const;
2942
+ //! returns reference to the last sequence element
2943
+ _Tp &back();
2944
+ //! returns read-only reference to the last sequence element
2945
+ const _Tp &back() const;
2946
+ //! returns true iff the sequence contains no elements
2947
+ bool empty() const;
2948
+
2949
+ //! removes all the elements from the sequence
2950
+ void clear();
2951
+ //! removes the first element from the sequence
2952
+ void pop_front();
2953
+ //! removes the last element from the sequence
2954
+ void pop_back();
2955
+ //! removes zero or more elements from the beginning of the sequence
2956
+ void pop_front(_Tp *elems, size_t count);
2957
+ //! removes zero or more elements from the end of the sequence
2958
+ void pop_back(_Tp *elems, size_t count);
2959
+
2960
+ //! copies the whole sequence or the sequence slice to the specified vector
2961
+ void copyTo(std::vector<_Tp> &vec, const Range &range = Range::all()) const;
2962
+ //! returns the vector containing all the sequence elements
2963
+ operator std::vector<_Tp>() const;
2964
+
2965
+ CvSeq *seq;
2966
+ };
2967
+
2968
+ /*!
2969
+ STL-style Sequence Iterator inherited from the CvSeqReader structure
2970
+ */
2971
+ template <typename _Tp> class SeqIterator : public CvSeqReader {
2972
+ public:
2973
+ //! the default constructor
2974
+ SeqIterator();
2975
+ //! the constructor setting the iterator to the beginning or to the end of the
2976
+ //! sequence
2977
+ SeqIterator(const Seq<_Tp> &seq, bool seekEnd = false);
2978
+ //! positions the iterator within the sequence
2979
+ void seek(size_t pos);
2980
+ //! reports the current iterator position
2981
+ size_t tell() const;
2982
+ //! returns reference to the current sequence element
2983
+ _Tp &operator*();
2984
+ //! returns read-only reference to the current sequence element
2985
+ const _Tp &operator*() const;
2986
+ //! moves iterator to the next sequence element
2987
+ SeqIterator &operator++();
2988
+ //! moves iterator to the next sequence element
2989
+ SeqIterator operator++(int) const;
2990
+ //! moves iterator to the previous sequence element
2991
+ SeqIterator &operator--();
2992
+ //! moves iterator to the previous sequence element
2993
+ SeqIterator operator--(int) const;
2994
+
2995
+ //! moves iterator forward by the specified offset (possibly negative)
2996
+ SeqIterator &operator+=(int);
2997
+ //! moves iterator backward by the specified offset (possibly negative)
2998
+ SeqIterator &operator-=(int);
2999
+
3000
+ // this is index of the current element module seq->total*2
3001
+ // (to distinguish between 0 and seq->total)
3002
+ int index;
3003
+ };
3004
+
3005
+ // bridge C++ => C Seq API
3006
+ CV_EXPORTS schar *seqPush(CvSeq *seq, const void *element = 0);
3007
+ CV_EXPORTS schar *seqPushFront(CvSeq *seq, const void *element = 0);
3008
+ CV_EXPORTS void seqPop(CvSeq *seq, void *element = 0);
3009
+ CV_EXPORTS void seqPopFront(CvSeq *seq, void *element = 0);
3010
+ CV_EXPORTS void seqPopMulti(CvSeq *seq, void *elements, int count,
3011
+ int in_front = 0);
3012
+ CV_EXPORTS void seqRemove(CvSeq *seq, int index);
3013
+ CV_EXPORTS void clearSeq(CvSeq *seq);
3014
+ CV_EXPORTS schar *getSeqElem(const CvSeq *seq, int index);
3015
+ CV_EXPORTS void seqRemoveSlice(CvSeq *seq, CvSlice slice);
3016
+ CV_EXPORTS void seqInsertSlice(CvSeq *seq, int before_index,
3017
+ const CvArr *from_arr);
3018
+
3019
+ template <typename _Tp> inline Seq<_Tp>::Seq() : seq(0) {}
3020
+ template <typename _Tp>
3021
+ inline Seq<_Tp>::Seq(const CvSeq *_seq) : seq((CvSeq *)_seq) {
3022
+ CV_Assert(!_seq || _seq->elem_size == sizeof(_Tp));
3023
+ }
3024
+
3025
+ template <typename _Tp>
3026
+ inline Seq<_Tp>::Seq(MemStorage &storage, int headerSize) {
3027
+ CV_Assert(headerSize >= (int)sizeof(CvSeq));
3028
+ seq = cvCreateSeq(DataType<_Tp>::type, headerSize, sizeof(_Tp), storage);
3029
+ }
3030
+
3031
+ template <typename _Tp> inline _Tp &Seq<_Tp>::operator[](int idx) {
3032
+ return *(_Tp *)getSeqElem(seq, idx);
3033
+ }
3034
+
3035
+ template <typename _Tp> inline const _Tp &Seq<_Tp>::operator[](int idx) const {
3036
+ return *(_Tp *)getSeqElem(seq, idx);
3037
+ }
3038
+
3039
+ template <typename _Tp> inline SeqIterator<_Tp> Seq<_Tp>::begin() const {
3040
+ return SeqIterator<_Tp>(*this);
3041
+ }
3042
+
3043
+ template <typename _Tp> inline SeqIterator<_Tp> Seq<_Tp>::end() const {
3044
+ return SeqIterator<_Tp>(*this, true);
3045
+ }
3046
+
3047
+ template <typename _Tp> inline size_t Seq<_Tp>::size() const {
3048
+ return seq ? seq->total : 0;
3049
+ }
3050
+
3051
+ template <typename _Tp> inline int Seq<_Tp>::type() const {
3052
+ return seq ? CV_MAT_TYPE(seq->flags) : 0;
3053
+ }
3054
+
3055
+ template <typename _Tp> inline int Seq<_Tp>::depth() const {
3056
+ return seq ? CV_MAT_DEPTH(seq->flags) : 0;
3057
+ }
3058
+
3059
+ template <typename _Tp> inline int Seq<_Tp>::channels() const {
3060
+ return seq ? CV_MAT_CN(seq->flags) : 0;
3061
+ }
3062
+
3063
+ template <typename _Tp> inline size_t Seq<_Tp>::elemSize() const {
3064
+ return seq ? seq->elem_size : 0;
3065
+ }
3066
+
3067
+ template <typename _Tp> inline size_t Seq<_Tp>::index(const _Tp &elem) const {
3068
+ return cvSeqElemIdx(seq, &elem);
3069
+ }
3070
+
3071
+ template <typename _Tp> inline void Seq<_Tp>::push_back(const _Tp &elem) {
3072
+ cvSeqPush(seq, &elem);
3073
+ }
3074
+
3075
+ template <typename _Tp> inline void Seq<_Tp>::push_front(const _Tp &elem) {
3076
+ cvSeqPushFront(seq, &elem);
3077
+ }
3078
+
3079
+ template <typename _Tp>
3080
+ inline void Seq<_Tp>::push_back(const _Tp *elem, size_t count) {
3081
+ cvSeqPushMulti(seq, elem, (int)count, 0);
3082
+ }
3083
+
3084
+ template <typename _Tp>
3085
+ inline void Seq<_Tp>::push_front(const _Tp *elem, size_t count) {
3086
+ cvSeqPushMulti(seq, elem, (int)count, 1);
3087
+ }
3088
+
3089
+ template <typename _Tp> inline _Tp &Seq<_Tp>::back() {
3090
+ return *(_Tp *)getSeqElem(seq, -1);
3091
+ }
3092
+
3093
+ template <typename _Tp> inline const _Tp &Seq<_Tp>::back() const {
3094
+ return *(const _Tp *)getSeqElem(seq, -1);
3095
+ }
3096
+
3097
+ template <typename _Tp> inline _Tp &Seq<_Tp>::front() {
3098
+ return *(_Tp *)getSeqElem(seq, 0);
3099
+ }
3100
+
3101
+ template <typename _Tp> inline const _Tp &Seq<_Tp>::front() const {
3102
+ return *(const _Tp *)getSeqElem(seq, 0);
3103
+ }
3104
+
3105
+ template <typename _Tp> inline bool Seq<_Tp>::empty() const {
3106
+ return !seq || seq->total == 0;
3107
+ }
3108
+
3109
+ template <typename _Tp> inline void Seq<_Tp>::clear() {
3110
+ if (seq)
3111
+ clearSeq(seq);
3112
+ }
3113
+
3114
+ template <typename _Tp> inline void Seq<_Tp>::pop_back() { seqPop(seq); }
3115
+
3116
+ template <typename _Tp> inline void Seq<_Tp>::pop_front() { seqPopFront(seq); }
3117
+
3118
+ template <typename _Tp>
3119
+ inline void Seq<_Tp>::pop_back(_Tp *elem, size_t count) {
3120
+ seqPopMulti(seq, elem, (int)count, 0);
3121
+ }
3122
+
3123
+ template <typename _Tp>
3124
+ inline void Seq<_Tp>::pop_front(_Tp *elem, size_t count) {
3125
+ seqPopMulti(seq, elem, (int)count, 1);
3126
+ }
3127
+
3128
+ template <typename _Tp> inline void Seq<_Tp>::insert(int idx, const _Tp &elem) {
3129
+ seqInsert(seq, idx, &elem);
3130
+ }
3131
+
3132
+ template <typename _Tp>
3133
+ inline void Seq<_Tp>::insert(int idx, const _Tp *elems, size_t count) {
3134
+ CvMat m = cvMat(1, count, DataType<_Tp>::type, elems);
3135
+ seqInsertSlice(seq, idx, &m);
3136
+ }
3137
+
3138
+ template <typename _Tp> inline void Seq<_Tp>::remove(int idx) {
3139
+ seqRemove(seq, idx);
3140
+ }
3141
+
3142
+ template <typename _Tp> inline void Seq<_Tp>::remove(const Range &r) {
3143
+ seqRemoveSlice(seq, cvSlice(r.start, r.end));
3144
+ }
3145
+
3146
+ template <typename _Tp>
3147
+ inline void Seq<_Tp>::copyTo(std::vector<_Tp> &vec, const Range &range) const {
3148
+ size_t len = !seq ? 0
3149
+ : range == Range::all() ? seq->total
3150
+ : range.end - range.start;
3151
+ vec.resize(len);
3152
+ if (seq && len)
3153
+ cvCvtSeqToArray(seq, &vec[0], cvSlice(range));
3154
+ }
3155
+
3156
+ template <typename _Tp> inline Seq<_Tp>::operator std::vector<_Tp>() const {
3157
+ std::vector<_Tp> vec;
3158
+ copyTo(vec);
3159
+ return vec;
3160
+ }
3161
+
3162
+ template <typename _Tp> inline SeqIterator<_Tp>::SeqIterator() {
3163
+ memset(this, 0, sizeof(*this));
3164
+ }
3165
+
3166
+ template <typename _Tp>
3167
+ inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp> &_seq, bool seekEnd) {
3168
+ cvStartReadSeq(_seq.seq, this);
3169
+ index = seekEnd ? _seq.seq->total : 0;
3170
+ }
3171
+
3172
+ template <typename _Tp> inline void SeqIterator<_Tp>::seek(size_t pos) {
3173
+ cvSetSeqReaderPos(this, (int)pos, false);
3174
+ index = pos;
3175
+ }
3176
+
3177
+ template <typename _Tp> inline size_t SeqIterator<_Tp>::tell() const {
3178
+ return index;
3179
+ }
3180
+
3181
+ template <typename _Tp> inline _Tp &SeqIterator<_Tp>::operator*() {
3182
+ return *(_Tp *)ptr;
3183
+ }
3184
+
3185
+ template <typename _Tp> inline const _Tp &SeqIterator<_Tp>::operator*() const {
3186
+ return *(const _Tp *)ptr;
3187
+ }
3188
+
3189
+ template <typename _Tp>
3190
+ inline SeqIterator<_Tp> &SeqIterator<_Tp>::operator++() {
3191
+ CV_NEXT_SEQ_ELEM(sizeof(_Tp), *this);
3192
+ if (++index >= seq->total * 2)
3193
+ index = 0;
3194
+ return *this;
3195
+ }
3196
+
3197
+ template <typename _Tp>
3198
+ inline SeqIterator<_Tp> SeqIterator<_Tp>::operator++(int) const {
3199
+ SeqIterator<_Tp> it = *this;
3200
+ ++*this;
3201
+ return it;
3202
+ }
3203
+
3204
+ template <typename _Tp>
3205
+ inline SeqIterator<_Tp> &SeqIterator<_Tp>::operator--() {
3206
+ CV_PREV_SEQ_ELEM(sizeof(_Tp), *this);
3207
+ if (--index < 0)
3208
+ index = seq->total * 2 - 1;
3209
+ return *this;
3210
+ }
3211
+
3212
+ template <typename _Tp>
3213
+ inline SeqIterator<_Tp> SeqIterator<_Tp>::operator--(int) const {
3214
+ SeqIterator<_Tp> it = *this;
3215
+ --*this;
3216
+ return it;
3217
+ }
3218
+
3219
+ template <typename _Tp>
3220
+ inline SeqIterator<_Tp> &SeqIterator<_Tp>::operator+=(int delta) {
3221
+ cvSetSeqReaderPos(this, delta, 1);
3222
+ index += delta;
3223
+ int n = seq->total * 2;
3224
+ if (index < 0)
3225
+ index += n;
3226
+ if (index >= n)
3227
+ index -= n;
3228
+ return *this;
3229
+ }
3230
+
3231
+ template <typename _Tp>
3232
+ inline SeqIterator<_Tp> &SeqIterator<_Tp>::operator-=(int delta) {
3233
+ return (*this += -delta);
3234
+ }
3235
+
3236
+ template <typename _Tp>
3237
+ inline ptrdiff_t operator-(const SeqIterator<_Tp> &a,
3238
+ const SeqIterator<_Tp> &b) {
3239
+ ptrdiff_t delta = a.index - b.index, n = a.seq->total;
3240
+ if (delta > n || delta < -n)
3241
+ delta += delta < 0 ? n : -n;
3242
+ return delta;
3243
+ }
3244
+
3245
+ template <typename _Tp>
3246
+ inline bool operator==(const SeqIterator<_Tp> &a, const SeqIterator<_Tp> &b) {
3247
+ return a.seq == b.seq && a.index == b.index;
3248
+ }
3249
+
3250
+ template <typename _Tp>
3251
+ inline bool operator!=(const SeqIterator<_Tp> &a, const SeqIterator<_Tp> &b) {
3252
+ return !(a == b);
3253
+ }
3254
+
3255
+ //! @}
3256
+
3257
+ } // namespace cv
3258
+
3259
+ #endif
3260
+
3261
+ #endif