react-native-image-stitcher 0.1.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 (151) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +21 -0
  4. package/README.md +189 -0
  5. package/RNImageStitcher.podspec +76 -0
  6. package/android/build.gradle +224 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/cpp/CMakeLists.txt +124 -0
  9. package/android/src/main/cpp/image_stitcher_jni.cpp +145 -0
  10. package/android/src/main/cpp/keyframe_gate_jni.cpp +204 -0
  11. package/android/src/main/java/io/imagestitcher/rn/BatchStitcher.kt +426 -0
  12. package/android/src/main/java/io/imagestitcher/rn/IncrementalFirstwinsEngine.kt +960 -0
  13. package/android/src/main/java/io/imagestitcher/rn/IncrementalStitcher.kt +2371 -0
  14. package/android/src/main/java/io/imagestitcher/rn/KeyframeGate.kt +256 -0
  15. package/android/src/main/java/io/imagestitcher/rn/QualityChecker.kt +167 -0
  16. package/android/src/main/java/io/imagestitcher/rn/RNImageStitcherPackage.kt +39 -0
  17. package/android/src/main/java/io/imagestitcher/rn/RNSARCameraView.kt +558 -0
  18. package/android/src/main/java/io/imagestitcher/rn/RNSARCameraViewManager.kt +35 -0
  19. package/android/src/main/java/io/imagestitcher/rn/RNSARSession.kt +784 -0
  20. package/android/src/main/java/io/imagestitcher/rn/ar/BackgroundRenderer.kt +176 -0
  21. package/android/src/main/java/io/imagestitcher/rn/ar/ShaderUtil.kt +67 -0
  22. package/android/src/main/java/io/imagestitcher/rn/ar/YuvImageConverter.kt +201 -0
  23. package/cpp/ar_frame_pose.h +63 -0
  24. package/cpp/keyframe_gate.cpp +927 -0
  25. package/cpp/keyframe_gate.hpp +240 -0
  26. package/cpp/stitcher.cpp +2207 -0
  27. package/cpp/stitcher.hpp +275 -0
  28. package/dist/ar/useARSession.d.ts +102 -0
  29. package/dist/ar/useARSession.js +133 -0
  30. package/dist/camera/ARCameraView.d.ts +93 -0
  31. package/dist/camera/ARCameraView.js +170 -0
  32. package/dist/camera/Camera.d.ts +134 -0
  33. package/dist/camera/Camera.js +688 -0
  34. package/dist/camera/CameraShutter.d.ts +80 -0
  35. package/dist/camera/CameraShutter.js +237 -0
  36. package/dist/camera/CameraView.d.ts +65 -0
  37. package/dist/camera/CameraView.js +117 -0
  38. package/dist/camera/CaptureControlsBar.d.ts +87 -0
  39. package/dist/camera/CaptureControlsBar.js +82 -0
  40. package/dist/camera/CaptureHeader.d.ts +62 -0
  41. package/dist/camera/CaptureHeader.js +81 -0
  42. package/dist/camera/CapturePreview.d.ts +70 -0
  43. package/dist/camera/CapturePreview.js +188 -0
  44. package/dist/camera/CaptureStatusOverlay.d.ts +75 -0
  45. package/dist/camera/CaptureStatusOverlay.js +326 -0
  46. package/dist/camera/CaptureThumbnailStrip.d.ts +87 -0
  47. package/dist/camera/CaptureThumbnailStrip.js +177 -0
  48. package/dist/camera/IncrementalPanGuide.d.ts +83 -0
  49. package/dist/camera/IncrementalPanGuide.js +267 -0
  50. package/dist/camera/PanoramaBandOverlay.d.ts +107 -0
  51. package/dist/camera/PanoramaBandOverlay.js +399 -0
  52. package/dist/camera/PanoramaConfirmModal.d.ts +57 -0
  53. package/dist/camera/PanoramaConfirmModal.js +128 -0
  54. package/dist/camera/PanoramaGuidance.d.ts +79 -0
  55. package/dist/camera/PanoramaGuidance.js +246 -0
  56. package/dist/camera/PanoramaSettingsModal.d.ts +311 -0
  57. package/dist/camera/PanoramaSettingsModal.js +611 -0
  58. package/dist/camera/ViewportCropOverlay.d.ts +46 -0
  59. package/dist/camera/ViewportCropOverlay.js +67 -0
  60. package/dist/camera/useCapture.d.ts +111 -0
  61. package/dist/camera/useCapture.js +160 -0
  62. package/dist/camera/useDeviceOrientation.d.ts +48 -0
  63. package/dist/camera/useDeviceOrientation.js +131 -0
  64. package/dist/camera/useVideoCapture.d.ts +79 -0
  65. package/dist/camera/useVideoCapture.js +151 -0
  66. package/dist/index.d.ts +26 -0
  67. package/dist/index.js +39 -0
  68. package/dist/quality/normaliseOrientation.d.ts +36 -0
  69. package/dist/quality/normaliseOrientation.js +62 -0
  70. package/dist/quality/runQualityCheck.d.ts +41 -0
  71. package/dist/quality/runQualityCheck.js +98 -0
  72. package/dist/sensors/useIMUTranslationGate.d.ts +70 -0
  73. package/dist/sensors/useIMUTranslationGate.js +235 -0
  74. package/dist/stitching/IncrementalStitcherView.d.ts +41 -0
  75. package/dist/stitching/IncrementalStitcherView.js +157 -0
  76. package/dist/stitching/incremental.d.ts +930 -0
  77. package/dist/stitching/incremental.js +133 -0
  78. package/dist/stitching/stitchFrames.d.ts +55 -0
  79. package/dist/stitching/stitchFrames.js +56 -0
  80. package/dist/stitching/stitchVideo.d.ts +119 -0
  81. package/dist/stitching/stitchVideo.js +57 -0
  82. package/dist/stitching/useIncrementalJSDriver.d.ts +74 -0
  83. package/dist/stitching/useIncrementalJSDriver.js +199 -0
  84. package/dist/stitching/useIncrementalStitcher.d.ts +58 -0
  85. package/dist/stitching/useIncrementalStitcher.js +172 -0
  86. package/dist/types.d.ts +58 -0
  87. package/dist/types.js +15 -0
  88. package/ios/Package.swift +72 -0
  89. package/ios/Sources/RNImageStitcher/ARCameraViewManager.m +33 -0
  90. package/ios/Sources/RNImageStitcher/ARCameraViewManager.swift +40 -0
  91. package/ios/Sources/RNImageStitcher/ARSessionBridge.m +55 -0
  92. package/ios/Sources/RNImageStitcher/ARSessionBridge.swift +149 -0
  93. package/ios/Sources/RNImageStitcher/IncrementalStitcher.swift +2727 -0
  94. package/ios/Sources/RNImageStitcher/IncrementalStitcherBridge.m +85 -0
  95. package/ios/Sources/RNImageStitcher/IncrementalStitcherBridge.swift +625 -0
  96. package/ios/Sources/RNImageStitcher/KeyframeGate.swift +328 -0
  97. package/ios/Sources/RNImageStitcher/KeyframeGateBridge.h +141 -0
  98. package/ios/Sources/RNImageStitcher/KeyframeGateBridge.mm +278 -0
  99. package/ios/Sources/RNImageStitcher/OpenCVIncrementalStitcher.h +473 -0
  100. package/ios/Sources/RNImageStitcher/OpenCVIncrementalStitcher.mm +1326 -0
  101. package/ios/Sources/RNImageStitcher/OpenCVKeyframeCollector.h +97 -0
  102. package/ios/Sources/RNImageStitcher/OpenCVKeyframeCollector.mm +296 -0
  103. package/ios/Sources/RNImageStitcher/OpenCVSlitScanStitcher.h +103 -0
  104. package/ios/Sources/RNImageStitcher/OpenCVSlitScanStitcher.mm +3285 -0
  105. package/ios/Sources/RNImageStitcher/OpenCVStitcher.h +238 -0
  106. package/ios/Sources/RNImageStitcher/OpenCVStitcher.mm +1880 -0
  107. package/ios/Sources/RNImageStitcher/QualityChecker.swift +252 -0
  108. package/ios/Sources/RNImageStitcher/QualityCheckerBridge.m +26 -0
  109. package/ios/Sources/RNImageStitcher/QualityCheckerBridge.swift +72 -0
  110. package/ios/Sources/RNImageStitcher/RNSARCameraView.swift +114 -0
  111. package/ios/Sources/RNImageStitcher/RNSARSession.swift +1111 -0
  112. package/ios/Sources/RNImageStitcher/Stitcher.swift +243 -0
  113. package/ios/Sources/RNImageStitcher/StitcherBridge.m +28 -0
  114. package/ios/Sources/RNImageStitcher/StitcherBridge.swift +246 -0
  115. package/package.json +73 -0
  116. package/react-native.config.js +34 -0
  117. package/scripts/opencv-version.txt +1 -0
  118. package/scripts/postinstall-fetch-binaries.js +286 -0
  119. package/src/ar/useARSession.ts +210 -0
  120. package/src/camera/.gitkeep +0 -0
  121. package/src/camera/ARCameraView.tsx +256 -0
  122. package/src/camera/Camera.tsx +1053 -0
  123. package/src/camera/CameraShutter.tsx +292 -0
  124. package/src/camera/CameraView.tsx +157 -0
  125. package/src/camera/CaptureControlsBar.tsx +204 -0
  126. package/src/camera/CaptureHeader.tsx +184 -0
  127. package/src/camera/CapturePreview.tsx +318 -0
  128. package/src/camera/CaptureStatusOverlay.tsx +391 -0
  129. package/src/camera/CaptureThumbnailStrip.tsx +277 -0
  130. package/src/camera/IncrementalPanGuide.tsx +328 -0
  131. package/src/camera/PanoramaBandOverlay.tsx +498 -0
  132. package/src/camera/PanoramaConfirmModal.tsx +206 -0
  133. package/src/camera/PanoramaGuidance.tsx +327 -0
  134. package/src/camera/PanoramaSettingsModal.tsx +1357 -0
  135. package/src/camera/ViewportCropOverlay.tsx +81 -0
  136. package/src/camera/useCapture.ts +279 -0
  137. package/src/camera/useDeviceOrientation.ts +140 -0
  138. package/src/camera/useVideoCapture.ts +236 -0
  139. package/src/index.ts +53 -0
  140. package/src/quality/.gitkeep +0 -0
  141. package/src/quality/normaliseOrientation.ts +79 -0
  142. package/src/quality/runQualityCheck.ts +131 -0
  143. package/src/sensors/useIMUTranslationGate.ts +347 -0
  144. package/src/stitching/.gitkeep +0 -0
  145. package/src/stitching/IncrementalStitcherView.tsx +198 -0
  146. package/src/stitching/incremental.ts +1021 -0
  147. package/src/stitching/stitchFrames.ts +88 -0
  148. package/src/stitching/stitchVideo.ts +153 -0
  149. package/src/stitching/useIncrementalJSDriver.ts +273 -0
  150. package/src/stitching/useIncrementalStitcher.ts +252 -0
  151. package/src/types.ts +78 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,96 @@
1
+ # Changelog
2
+
3
+ All notable changes to `react-native-image-stitcher` will be
4
+ documented in this file.
5
+
6
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
+
9
+ > [!IMPORTANT]
10
+ > **0.x → 1.0 stability gate.** Per non-functional requirement NF2 of
11
+ > the design doc, the 0.x line is API-unstable. We intentionally ship
12
+ > a small, focused public surface here so the v1.0 contract can be
13
+ > stabilised without churning a sprawling API. Breaking changes
14
+ > during 0.x are bumped to a new MINOR (e.g., 0.1 → 0.2), and the
15
+ > upgrade path is documented in this CHANGELOG.
16
+
17
+ ## [Unreleased]
18
+
19
+ ## [0.1.0] — TBD
20
+
21
+ First public release.
22
+
23
+ ### Added
24
+
25
+ - `<Camera>` — props-based RN component combining tap-to-photo and
26
+ hold-to-pan-and-stitch panorama capture in one surface. Switches
27
+ internally between ARKit/ARCore (AR mode) and vision-camera + IMU
28
+ (non-AR mode); the host doesn't manage the modes directly.
29
+ - `useARSession()` — hook exposing the underlying ARKit/ARCore session
30
+ (availability, tracking state, pose log). For hosts that want to
31
+ build AR-driven UIs on top of the public lib's foundation.
32
+ - `useIMUTranslationGate()` — hook exposing the same IMU-fused
33
+ translation-budget gate that `<Camera>` uses internally on the non-AR
34
+ capture path. Useful if you're building your own non-AR capture
35
+ pipeline.
36
+ - Native binaries (OpenCV `cv::Stitcher` xcframework for iOS, `.so`
37
+ for Android) fetched from GitHub Releases on `npm install` via the
38
+ package's postinstall script. Android ships `arm64-v8a` only —
39
+ covers all production Android phones; x86/x86_64 emulator support
40
+ is on the v0.2 roadmap.
41
+ - Apache 2.0 license.
42
+
43
+ ### Deliberately NOT exported in v0.1.0
44
+
45
+ The following are intentionally internal so the public surface stays
46
+ small. If you have a real use-case for any of these, please open an
47
+ issue describing it.
48
+
49
+ - `useCapture`, `useDeviceOrientation` — internal hooks `<Camera>`
50
+ composes; expose these only after we have a story for what their
51
+ separate-from-`<Camera>` use-case looks like.
52
+ - `CameraView`, `ARCameraView` — underlying preview surfaces. Hosts
53
+ that need both modes should use `<Camera>` (which switches between
54
+ them); hosts that need only one path should still go through
55
+ `<Camera>` (a future prop `mode="ar-only"` / `"non-ar-only"` is on
56
+ the v0.2 roadmap).
57
+ - `CameraShutter`, `CaptureStatusOverlay`, `CaptureHeader`,
58
+ `CaptureControlsBar`, `PanoramaGuidance`, `IncrementalPanGuide`,
59
+ `PanoramaBandOverlay`, `ViewportCropOverlay`, `CapturePreview`,
60
+ `PanoramaConfirmModal`, `CaptureThumbnailStrip`,
61
+ `PanoramaSettingsModal`, `DEFAULT_PANORAMA_SETTINGS` — sub-pieces of
62
+ `<Camera>`.
63
+ - `useIncrementalStitcher`, `useIncrementalJSDriver`,
64
+ `IncrementalStitcherView`, `incrementalStitcherIsAvailable`,
65
+ `getIncrementalNativeModule`, `cleanupOldKeyframes`,
66
+ `subscribeIncrementalState`, `IncrementalOutcome` — internal driver
67
+ primitives for the incremental engine.
68
+ - `stitchFrames`, `stitchVideo`, `StitchNotImplementedError` —
69
+ batch-stitching primitives. A candidate for graduating to public
70
+ in v0.2 once we've decided whether they should be a parallel API
71
+ to `<Camera>` or a hidden orchestrator.
72
+ - `runQualityCheck`, `normaliseOrientation` — image-quality helpers.
73
+ Same status as batch-stitching.
74
+ - `useVideoCapture` — sweep-video capture, currently iOS-only with no
75
+ shipping Android port.
76
+
77
+ ### Migration from pre-publication ad-hoc usage
78
+
79
+ If you imported from `@retailens/capture-sdk` or directly from a
80
+ subtree-checkout of the monorepo, the migration to the published
81
+ `react-native-image-stitcher` package is:
82
+
83
+ | Old import (`@retailens/capture-sdk`) | New import (`react-native-image-stitcher`) |
84
+ |---|---|
85
+ | `Camera`, `CameraError`, … | unchanged |
86
+ | `useARSession`, `useIMUTranslationGate` | unchanged |
87
+ | Any other deep export (e.g. `stitchFrames`, `measureRegion`) | retired or moved — see "Deliberately NOT exported" above; retail-specific features are now in `retailens-camera-sdk` (private) |
88
+
89
+ Native module names also changed:
90
+ - `NativeModules.RetaiLensQualityChecker` → `NativeModules.RNImageStitcherQualityChecker`
91
+ - Java package: `com.retailens.capturesdk` → `io.imagestitcher.rn`
92
+ - iOS pod: `RetaiLensCaptureSDK` → `RNImageStitcher`
93
+ - iOS xcframework: shipped as `opencv2.xcframework` (linked from `RNImageStitcher.podspec`)
94
+
95
+ [Unreleased]: https://github.com/bhargavkanda/react-native-image-stitcher/compare/v0.1.0...HEAD
96
+ [0.1.0]: https://github.com/bhargavkanda/react-native-image-stitcher/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Tiger Analytics
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,21 @@
1
+ react-native-image-stitcher
2
+ Copyright 2026 Tiger Analytics
3
+
4
+ This product includes software developed at Tiger Analytics
5
+ (https://www.tigeranalytics.com/).
6
+
7
+ Bundled third-party components:
8
+
9
+ • OpenCV (https://opencv.org/) — Apache License 2.0
10
+ Used for image stitching, feature detection, and homography
11
+ estimation in the panorama pipeline. The npm package's
12
+ `postinstall` script fetches a custom-built OpenCV 4.10.0
13
+ distribution as a runtime dependency; see
14
+ `scripts/postinstall-fetch-binaries.js`.
15
+
16
+ • React Native, vision-camera, expo-sensors, react-native-safe-area-context
17
+ Peer dependencies declared in `package.json#peerDependencies`.
18
+ Each retains its own license.
19
+
20
+ Per the Apache 2.0 License § 4(d), this NOTICE must be reproduced in
21
+ derivative works that ship a NOTICE file.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # react-native-image-stitcher
2
+
3
+ **Pose-aware panorama capture + stitching for React Native (iOS + Android).**
4
+ One `<Camera>` component, both tap-to-photo and hold-to-pan modes, both
5
+ AR-backed and IMU-fallback capture paths.
6
+
7
+ > [!NOTE]
8
+ > This package lives in the [RetaiLens monorepo](https://github.com/bhargav-kanda/RetaiLens)
9
+ > under `retailens-capture-sdk/` during development. At publication
10
+ > (see [`2026-05-15-react-native-image-stitcher-publication.md`](https://github.com/bhargav-kanda/RetaiLens/blob/main/docs/site-content/design/2026-05-15-react-native-image-stitcher-publication.md))
11
+ > the public subset is `git subtree split` extracted to a standalone
12
+ > repo at `github.com/bhargavkanda/react-native-image-stitcher` and
13
+ > published to npm. This README describes the **public lib** as it
14
+ > will look post-extraction.
15
+
16
+ ## What it does
17
+
18
+ | Feature | Behaviour |
19
+ |---|---|
20
+ | **Tap shutter** | Single photo via vision-camera's `takePhoto` (non-AR) or `ARFrame.capturedImage` (AR). |
21
+ | **Hold shutter** | Panorama capture — pan and release. Engine accumulates keyframes; stitches via `cv::Stitcher::PANORAMA` (or `SCANS` if the pose suggests a flat-translation scan). |
22
+ | **Lens chip** | 1× / 0.5× toggle above the shutter. Selecting 0.5× forces non-AR (AR sessions can't switch physical lenses mid-session). |
23
+ | **AR toggle** | Bottom-right corner, conditional on the 1× lens. Toggles between AR-pose-driven and IMU-driven capture paths. |
24
+ | **Internal settings panel** | Opt-in gear icon (top-right) via `showSettingsButton` prop. Exposes blender, seam finder, warper, flow-gate tunables — useful for internal testers; hidden from public consumers by default. |
25
+
26
+ ## Installation
27
+
28
+ ```sh
29
+ npm install react-native-image-stitcher
30
+ # or
31
+ yarn add react-native-image-stitcher
32
+ ```
33
+
34
+ Peer dependencies (the host app provides these):
35
+
36
+ ```jsonc
37
+ {
38
+ "react": ">=18.0.0",
39
+ "react-native": ">=0.72.0",
40
+ "react-native-vision-camera": ">=4.7.0",
41
+ "react-native-sensors": ">=7.0.0",
42
+ "expo-sensors": ">=14.0.0",
43
+ "react-native-safe-area-context": ">=4.0.0"
44
+ }
45
+ ```
46
+
47
+ On install, a `postinstall` script downloads the matching custom
48
+ OpenCV build (`opencv2.xcframework` for iOS + per-ABI `.so`
49
+ files for Android) from the package's GitHub Releases — about 100 MB
50
+ of binaries fetched once and cached locally. Set
51
+ `SKIP_OPENCV_FETCH=1` to bypass the download (e.g., in CI where the
52
+ binaries are pre-staged).
53
+
54
+ After install run the standard React Native native-build steps:
55
+
56
+ ```sh
57
+ cd ios && pod install # iOS
58
+ cd android && ./gradlew :app:assembleDebug # Android
59
+ ```
60
+
61
+ > [!IMPORTANT]
62
+ > **The host app needs several pieces of native configuration on top of
63
+ > the standard `pod install` / `gradlew assembleDebug` steps** — most
64
+ > notably: switching `AppDelegate.swift` and `MainApplication.kt` to
65
+ > Expo's factory classes, adding several `Info.plist` permission strings
66
+ > (otherwise iOS SIGABRTs the app on launch), and applying two
67
+ > `patch-package` patches for React Native 0.84 compatibility.
68
+ >
69
+ > **Read [`docs/host-app-integration.md`](docs/host-app-integration.md)
70
+ > before your first run** — it covers every required step plus a
71
+ > troubleshooting table mapping every common runtime crash to its
72
+ > missing-config cause. The [`example/`](example/) directory is the
73
+ > canonical reference implementation.
74
+
75
+ ## Quick start
76
+
77
+ ```tsx
78
+ import {
79
+ Camera,
80
+ type CameraCaptureResult,
81
+ type CameraError,
82
+ } from 'react-native-image-stitcher';
83
+
84
+ export function CaptureScreen() {
85
+ const handleCapture = (result: CameraCaptureResult) => {
86
+ if (result.type === 'photo') {
87
+ console.log('Photo:', result.uri, result.width, result.height);
88
+ } else {
89
+ console.log(
90
+ 'Panorama:',
91
+ result.uri,
92
+ `${result.framesIncluded}/${result.framesRequested} frames`,
93
+ );
94
+ }
95
+ };
96
+
97
+ const handleError = (err: CameraError) => {
98
+ console.warn(err.code, err.message);
99
+ };
100
+
101
+ return (
102
+ <Camera
103
+ defaultCaptureSource="ar"
104
+ defaultLens="1x"
105
+ enablePhotoMode
106
+ enablePanoramaMode
107
+ onCapture={handleCapture}
108
+ onError={handleError}
109
+ />
110
+ );
111
+ }
112
+ ```
113
+
114
+ ## `<Camera>` props (summary)
115
+
116
+ See `src/camera/Camera.tsx` for the full TSDoc. Highlights:
117
+
118
+ ### Initial values (uncontrolled — read once at mount)
119
+
120
+ | Prop | Default | Notes |
121
+ |---|---|---|
122
+ | `defaultCaptureSource` | `'ar'` | `'ar'` ↔ `'non-ar'` |
123
+ | `defaultLens` | `'1x'` | `'1x'` ↔ `'0.5x'` |
124
+ | `defaultStitchMode` | `'auto'` | `'auto'`, `'panorama'`, `'scans'` |
125
+ | `defaultBlender` | `'multiband'` | `'multiband'`, `'feather'` |
126
+ | `defaultSeamFinder` | `'graphcut'` | `'graphcut'`, `'skip'` |
127
+ | `defaultWarper` | `'plane'` | `'plane'`, `'cylindrical'`, `'spherical'` |
128
+ | `defaultFlowNoveltyPercentile` | `0.85` | Range 0.50 – 0.99 |
129
+ | `defaultFlowEvalEveryNFrames` | `5` | Range 1 – 10 |
130
+ | `defaultFlowMaxTranslationCm` | `8` | 0 = disabled |
131
+ | `defaultKeyframeMaxCount` | `6` | Range 3 – 10 |
132
+ | `defaultKeyframeOverlapThreshold` | `0.20` | Range 0.20 – 0.60 |
133
+
134
+ ### UI toggles
135
+
136
+ | Prop | Default | Notes |
137
+ |---|---|---|
138
+ | `enablePhotoMode` | `true` | Tap-to-photo |
139
+ | `enablePanoramaMode` | `true` | Hold-to-pan |
140
+ | `showSettingsButton` | `false` | Internal-tester only; OFF for public consumers |
141
+
142
+ ### Callbacks
143
+
144
+ | Prop | Fires when |
145
+ |---|---|
146
+ | `onCapture(result)` | Photo OR panorama capture completes successfully. `result.type` discriminates. |
147
+ | `onCaptureSourceChange(source)` | Effective capture source changes (e.g., user toggles AR, or selecting 0.5× forces non-AR). |
148
+ | `onLensChange(lens)` | User taps the 1×/0.5× chip. |
149
+ | `onFramesDropped(info)` | cv::Stitcher's confidence retry loop dropped one or more input frames. |
150
+ | `onError(err)` | Classified error. `err.code` from a known taxonomy (`STITCH_NEED_MORE_IMGS`, `STITCH_HOMOGRAPHY_FAIL`, `STITCH_CAMERA_PARAMS_FAIL`, `STITCH_OOM`, `CAMERA_PERMISSION_DENIED`, etc.). |
151
+
152
+ ## Lens ↔ AR interaction
153
+
154
+ | Action | `arPreference` | `lens` | UI |
155
+ |---|---|---|---|
156
+ | Initial mount with defaults | `true` | `1x` | AR toggle ON |
157
+ | User switches to 0.5× | unchanged (`true`) | `0.5x` | AR toggle HIDDEN, forced non-AR |
158
+ | User switches back to 1× | unchanged (`true`) | `1x` | AR toggle visible at its previous state |
159
+ | User taps AR toggle off (on 1×) | `false` | `1x` | AR toggle OFF |
160
+
161
+ The component owns the runtime state; the parent persists across launches via the `on*Change` callbacks if desired.
162
+
163
+ ## Architecture notes
164
+
165
+ | Concern | Approach |
166
+ |---|---|
167
+ | **OpenCV** | Custom build (modules: `core`, `imgproc`, `features2d`, `calib3d`, `flann`, `stitching`, `video`, `photo`). Hosted as GitHub Release assets; fetched at install time. ~75 MB iOS, ~40 MB Android. |
168
+ | **iOS framework** | `opencv2.xcframework` (arm64 device + arm64+x86_64 simulator). |
169
+ | **Android namespace** | `io.imagestitcher.rn`. |
170
+ | **Stitching pipeline** | Shared C++ under `cpp/stitcher.cpp` invoked from both iOS Obj-C++ and Android JNI. PANORAMA + SCANS modes; C+D progressive-confidence retry over keyframes. |
171
+ | **Two capture-source paths** | AR uses ARKit (iOS) / ARCore (Android) pose stream. Non-AR uses vision-camera + IMU integration via `useIMUTranslationGate`. |
172
+ | **Two supported pan modes** | Landscape phone + vertical pan; portrait phone + horizontal pan. Any other combination is a user deviation, not a supported mode. |
173
+
174
+ ## License
175
+
176
+ Apache License 2.0. See [LICENSE](LICENSE) for the full text and
177
+ [NOTICE](NOTICE) for the third-party attribution required by § 4(d).
178
+
179
+ ## Contributing
180
+
181
+ See [CONTRIBUTING.md](CONTRIBUTING.md). All contributors sign a CLA
182
+ (automated on first PR) so the project retains the right to relicense
183
+ future versions.
184
+
185
+ ## Related design documents
186
+
187
+ - [`2026-05-15-react-native-image-stitcher-publication.md`](https://github.com/bhargav-kanda/RetaiLens/blob/main/docs/site-content/design/2026-05-15-react-native-image-stitcher-publication.md) — publication plan + public/private split.
188
+ - [`2026-05-14-realtime-batch-fusion.md`](https://github.com/bhargav-kanda/RetaiLens/blob/main/docs/site-content/design/2026-05-14-realtime-batch-fusion.md) — realtime + batch convergence design.
189
+ - [`2026-05-13-stitch-pipeline-mode-selection.md`](https://github.com/bhargav-kanda/RetaiLens/blob/main/docs/site-content/design/2026-05-13-stitch-pipeline-mode-selection.md) — PANORAMA vs SCANS auto-routing.
@@ -0,0 +1,76 @@
1
+ #
2
+ # RNImageStitcher.podspec
3
+ #
4
+ # CocoaPods spec consumed by host RN apps via React Native's
5
+ # autolinking. The host app's package.json depends on
6
+ # `react-native-image-stitcher`, autolinking discovers this podspec
7
+ # at the package root, and `pod install` links the OpenCV xcframework
8
+ # that the `postinstall-fetch-binaries.js` script downloaded into
9
+ # `ios/Frameworks/` at npm-install time.
10
+ #
11
+
12
+ require 'json'
13
+
14
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
15
+
16
+ Pod::Spec.new do |s|
17
+ s.name = 'RNImageStitcher'
18
+ s.version = package['version']
19
+ s.summary = 'Pose-aware panorama capture + stitching for React Native'
20
+ s.description = package['description']
21
+ s.homepage = 'https://github.com/bhargavkanda/react-native-image-stitcher'
22
+ s.license = { :type => 'Apache-2.0', :file => 'LICENSE' }
23
+ s.authors = { 'Tiger Analytics' => 'opensource@tigeranalytics.com' }
24
+ s.source = {
25
+ :git => 'https://github.com/bhargavkanda/react-native-image-stitcher.git',
26
+ :tag => "v#{s.version}"
27
+ }
28
+
29
+ # iOS 14 floor matches the React Native ecosystem's current standard
30
+ # deployment target. Lowering would require conditionalising the
31
+ # @available checks in the AR session bridges — not worth the
32
+ # maintenance overhead.
33
+ s.platforms = { :ios => '14.0' }
34
+ s.swift_version = '5.0'
35
+
36
+ # Sources: iOS-specific Swift/Obj-C/Obj-C++ AND the shared C++ port
37
+ # (cpp/) that both iOS and Android compile from a single source.
38
+ s.source_files = ['ios/Sources/**/*.{swift,h,m,mm}',
39
+ 'cpp/**/*.{h,hpp,cpp}']
40
+ # public_header_files intentionally omitted — React Native's
41
+ # @objc(...) dispatch doesn't need umbrella headers, and exposing
42
+ # all OpenCV*.h headers to consumers locks us into supporting
43
+ # internal Obj-C++ classes as public API. See CHANGELOG v0.1.0.
44
+
45
+ # Frameworks shipped with iOS itself — no binary cost.
46
+ s.frameworks = ['Accelerate', 'CoreImage', 'UIKit', 'ARKit']
47
+
48
+ s.dependency 'React-Core'
49
+
50
+ # ─────────────────────────────────────────────────────────────────────
51
+ # OpenCV — pre-built custom xcframework fetched by postinstall
52
+ # ─────────────────────────────────────────────────────────────────────
53
+ #
54
+ # The npm `postinstall` script (`scripts/postinstall-fetch-binaries.js`)
55
+ # downloads `opencv2.xcframework` from the matching GitHub
56
+ # Release into `ios/Frameworks/`. This podspec just declares the
57
+ # vendored framework so the linker picks it up at `pod install` time.
58
+ #
59
+ # Pre-built means: no source build at pod-install time (the old
60
+ # opencv-mobile flow took 20+ minutes); no architecture quirks on
61
+ # Apple Silicon Macs (the xcframework ships device-arm64 +
62
+ # simulator-arm64+x86_64 slices); reproducible across CI runs.
63
+ #
64
+ # If the xcframework isn't on disk when `pod install` runs, the user
65
+ # forgot to `npm install` (or set SKIP_OPENCV_FETCH=1). pod install
66
+ # will fail with "framework not found" — the JS postinstall script
67
+ # emits a clear error message in that case pointing users to re-run.
68
+ s.vendored_frameworks = 'ios/Frameworks/opencv2.xcframework'
69
+
70
+ s.pod_target_xcconfig = {
71
+ 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
72
+ 'CLANG_CXX_LIBRARY' => 'libc++',
73
+ 'OTHER_CPLUSPLUSFLAGS' => '$(inherited) -std=c++17',
74
+ 'HEADER_SEARCH_PATHS' => '$(inherited) "${PODS_TARGET_SRCROOT}/cpp"',
75
+ }
76
+ end