react-native-nitro-ar 2026.2.1 → 2026.2.2
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.
- package/ios/HybridARMeshAnchor.swift +48 -20
- package/ios/HybridARSegmentationResult.swift +344 -0
- package/ios/HybridARView.swift +113 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/ARObjectMeasurement.nitro.js +6 -0
- package/lib/commonjs/specs/ARObjectMeasurement.nitro.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ARObjectMeasurement.nitro.js +4 -0
- package/lib/module/specs/ARObjectMeasurement.nitro.js.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ARObjectMeasurement.nitro.d.ts +34 -0
- package/lib/typescript/src/specs/ARObjectMeasurement.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/ARView.nitro.d.ts +5 -0
- package/lib/typescript/src/specs/ARView.nitro.d.ts.map +1 -1
- package/nitrogen/generated/ios/NitroAR-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/NitroAR-Swift-Cxx-Bridge.hpp +154 -0
- package/nitrogen/generated/ios/NitroAR-Swift-Cxx-Umbrella.hpp +8 -0
- package/nitrogen/generated/ios/c++/HybridARSegmentationResultSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridARSegmentationResultSpecSwift.hpp +102 -0
- package/nitrogen/generated/ios/c++/HybridARViewSpecSwift.hpp +25 -0
- package/nitrogen/generated/ios/swift/ARObjectMeasurement.swift +71 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_ARObjectMeasurement_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridARSegmentationResultSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridARSegmentationResultSpec_cxx.swift +187 -0
- package/nitrogen/generated/ios/swift/HybridARViewSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridARViewSpec_cxx.swift +53 -0
- package/nitrogen/generated/shared/c++/ARObjectMeasurement.hpp +107 -0
- package/nitrogen/generated/shared/c++/HybridARSegmentationResultSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridARSegmentationResultSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/HybridARViewSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridARViewSpec.hpp +10 -0
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/specs/ARObjectMeasurement.nitro.ts +33 -0
- package/src/specs/ARView.nitro.ts +7 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: (any HybridARSegmentationResultSpec)?) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__ {
|
|
15
|
+
public typealias bridge = margelo.nitro.ar.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: (any HybridARSegmentationResultSpec)?) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: (any HybridARSegmentationResultSpec)?) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: bridge.std__optional_std__shared_ptr_HybridARSegmentationResultSpec__) -> Void {
|
|
25
|
+
self.closure({ () -> (any HybridARSegmentationResultSpec)? in
|
|
26
|
+
if bridge.has_value_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__(value) {
|
|
27
|
+
let __unwrapped = bridge.get_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__(value)
|
|
28
|
+
return { () -> any HybridARSegmentationResultSpec in
|
|
29
|
+
let __unsafePointer = bridge.get_std__shared_ptr_HybridARSegmentationResultSpec_(__unwrapped)
|
|
30
|
+
let __instance = HybridARSegmentationResultSpec_cxx.fromUnsafe(__unsafePointer)
|
|
31
|
+
return __instance.getHybridARSegmentationResultSpec()
|
|
32
|
+
}()
|
|
33
|
+
} else {
|
|
34
|
+
return nil
|
|
35
|
+
}
|
|
36
|
+
}())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
41
|
+
* This acquires one additional strong reference on the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
45
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Casts an unsafe pointer to a `Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__`.
|
|
50
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__>`.
|
|
51
|
+
* This removes one strong reference from the object!
|
|
52
|
+
*/
|
|
53
|
+
@inline(__always)
|
|
54
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__ {
|
|
55
|
+
return Unmanaged<Func_void_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__>.fromOpaque(pointer).takeRetainedValue()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridARSegmentationResultSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/// See ``HybridARSegmentationResultSpec``
|
|
11
|
+
public protocol HybridARSegmentationResultSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
var success: Bool { get }
|
|
14
|
+
var boundingBox: [Double] { get }
|
|
15
|
+
var maskPixelCount: Double { get }
|
|
16
|
+
|
|
17
|
+
// Methods
|
|
18
|
+
func getDepthPoints() throws -> [Double]
|
|
19
|
+
func measure() throws -> ARObjectMeasurement?
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public extension HybridARSegmentationResultSpec_protocol {
|
|
23
|
+
/// Default implementation of ``HybridObject.toString``
|
|
24
|
+
func toString() -> String {
|
|
25
|
+
return "[HybridObject ARSegmentationResult]"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// See ``HybridARSegmentationResultSpec``
|
|
30
|
+
open class HybridARSegmentationResultSpec_base {
|
|
31
|
+
private weak var cxxWrapper: HybridARSegmentationResultSpec_cxx? = nil
|
|
32
|
+
public init() { }
|
|
33
|
+
public func getCxxWrapper() -> HybridARSegmentationResultSpec_cxx {
|
|
34
|
+
#if DEBUG
|
|
35
|
+
guard self is any HybridARSegmentationResultSpec else {
|
|
36
|
+
fatalError("`self` is not a `HybridARSegmentationResultSpec`! Did you accidentally inherit from `HybridARSegmentationResultSpec_base` instead of `HybridARSegmentationResultSpec`?")
|
|
37
|
+
}
|
|
38
|
+
#endif
|
|
39
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
40
|
+
return cxxWrapper
|
|
41
|
+
} else {
|
|
42
|
+
let cxxWrapper = HybridARSegmentationResultSpec_cxx(self as! any HybridARSegmentationResultSpec)
|
|
43
|
+
self.cxxWrapper = cxxWrapper
|
|
44
|
+
return cxxWrapper
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A Swift base-protocol representing the ARSegmentationResult HybridObject.
|
|
51
|
+
* Implement this protocol to create Swift-based instances of ARSegmentationResult.
|
|
52
|
+
* ```swift
|
|
53
|
+
* class HybridARSegmentationResult : HybridARSegmentationResultSpec {
|
|
54
|
+
* // ...
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
public typealias HybridARSegmentationResultSpec = HybridARSegmentationResultSpec_protocol & HybridARSegmentationResultSpec_base
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridARSegmentationResultSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A class implementation that bridges HybridARSegmentationResultSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridARSegmentationResultSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::ar::bridge::swift`)
|
|
22
|
+
* from `NitroAR-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.ar.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridARSegmentationResultSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridARSegmentationResultSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridARSegmentationResultSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridARSegmentationResultSpec_cxx` that wraps the given `HybridARSegmentationResultSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridARSegmentationResultSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridARSegmentationResultSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridARSegmentationResultSpec() -> any HybridARSegmentationResultSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridARSegmentationResultSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridARSegmentationResultSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridARSegmentationResultSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridARSegmentationResultSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridARSegmentationResultSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridARSegmentationResultSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridARSegmentationResultSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridARSegmentationResultSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridARSegmentationResultSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
public final var success: Bool {
|
|
125
|
+
@inline(__always)
|
|
126
|
+
get {
|
|
127
|
+
return self.__implementation.success
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public final var boundingBox: bridge.std__vector_double_ {
|
|
132
|
+
@inline(__always)
|
|
133
|
+
get {
|
|
134
|
+
return { () -> bridge.std__vector_double_ in
|
|
135
|
+
var __vector = bridge.create_std__vector_double_(self.__implementation.boundingBox.count)
|
|
136
|
+
for __item in self.__implementation.boundingBox {
|
|
137
|
+
__vector.push_back(__item)
|
|
138
|
+
}
|
|
139
|
+
return __vector
|
|
140
|
+
}()
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public final var maskPixelCount: Double {
|
|
145
|
+
@inline(__always)
|
|
146
|
+
get {
|
|
147
|
+
return self.__implementation.maskPixelCount
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Methods
|
|
152
|
+
@inline(__always)
|
|
153
|
+
public final func getDepthPoints() -> bridge.Result_std__vector_double__ {
|
|
154
|
+
do {
|
|
155
|
+
let __result = try self.__implementation.getDepthPoints()
|
|
156
|
+
let __resultCpp = { () -> bridge.std__vector_double_ in
|
|
157
|
+
var __vector = bridge.create_std__vector_double_(__result.count)
|
|
158
|
+
for __item in __result {
|
|
159
|
+
__vector.push_back(__item)
|
|
160
|
+
}
|
|
161
|
+
return __vector
|
|
162
|
+
}()
|
|
163
|
+
return bridge.create_Result_std__vector_double__(__resultCpp)
|
|
164
|
+
} catch (let __error) {
|
|
165
|
+
let __exceptionPtr = __error.toCpp()
|
|
166
|
+
return bridge.create_Result_std__vector_double__(__exceptionPtr)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@inline(__always)
|
|
171
|
+
public final func measure() -> bridge.Result_std__optional_ARObjectMeasurement__ {
|
|
172
|
+
do {
|
|
173
|
+
let __result = try self.__implementation.measure()
|
|
174
|
+
let __resultCpp = { () -> bridge.std__optional_ARObjectMeasurement_ in
|
|
175
|
+
if let __unwrappedValue = __result {
|
|
176
|
+
return bridge.create_std__optional_ARObjectMeasurement_(__unwrappedValue)
|
|
177
|
+
} else {
|
|
178
|
+
return .init()
|
|
179
|
+
}
|
|
180
|
+
}()
|
|
181
|
+
return bridge.create_Result_std__optional_ARObjectMeasurement__(__resultCpp)
|
|
182
|
+
} catch (let __error) {
|
|
183
|
+
let __exceptionPtr = __error.toCpp()
|
|
184
|
+
return bridge.create_Result_std__optional_ARObjectMeasurement__(__exceptionPtr)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -37,6 +37,8 @@ public protocol HybridARViewSpec_protocol: HybridObject, HybridView {
|
|
|
37
37
|
func pauseSession() throws -> Void
|
|
38
38
|
func resetSession() throws -> Void
|
|
39
39
|
func isLiDARAvailable() throws -> Bool
|
|
40
|
+
func segmentObject(x: Double, y: Double) throws -> Promise<(any HybridARSegmentationResultSpec)?>
|
|
41
|
+
func measureObject(x: Double, y: Double) throws -> Promise<ARObjectMeasurement?>
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
public extension HybridARViewSpec_protocol {
|
|
@@ -542,6 +542,59 @@ open class HybridARViewSpec_cxx {
|
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
+
@inline(__always)
|
|
546
|
+
public final func segmentObject(x: Double, y: Double) -> bridge.Result_std__shared_ptr_Promise_std__optional_std__shared_ptr_HybridARSegmentationResultSpec_____ {
|
|
547
|
+
do {
|
|
548
|
+
let __result = try self.__implementation.segmentObject(x: x, y: y)
|
|
549
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_std__shared_ptr_HybridARSegmentationResultSpec____ in
|
|
550
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__optional_std__shared_ptr_HybridARSegmentationResultSpec____()
|
|
551
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_std__shared_ptr_HybridARSegmentationResultSpec____(__promise)
|
|
552
|
+
__result
|
|
553
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_std__shared_ptr_HybridARSegmentationResultSpec__ in
|
|
554
|
+
if let __unwrappedValue = __result {
|
|
555
|
+
return bridge.create_std__optional_std__shared_ptr_HybridARSegmentationResultSpec__({ () -> bridge.std__shared_ptr_HybridARSegmentationResultSpec_ in
|
|
556
|
+
let __cxxWrapped = __unwrappedValue.getCxxWrapper()
|
|
557
|
+
return __cxxWrapped.getCxxPart()
|
|
558
|
+
}())
|
|
559
|
+
} else {
|
|
560
|
+
return .init()
|
|
561
|
+
}
|
|
562
|
+
}()) })
|
|
563
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
564
|
+
return __promise
|
|
565
|
+
}()
|
|
566
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__shared_ptr_HybridARSegmentationResultSpec_____(__resultCpp)
|
|
567
|
+
} catch (let __error) {
|
|
568
|
+
let __exceptionPtr = __error.toCpp()
|
|
569
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__shared_ptr_HybridARSegmentationResultSpec_____(__exceptionPtr)
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
@inline(__always)
|
|
574
|
+
public final func measureObject(x: Double, y: Double) -> bridge.Result_std__shared_ptr_Promise_std__optional_ARObjectMeasurement____ {
|
|
575
|
+
do {
|
|
576
|
+
let __result = try self.__implementation.measureObject(x: x, y: y)
|
|
577
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_ARObjectMeasurement___ in
|
|
578
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__optional_ARObjectMeasurement___()
|
|
579
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_ARObjectMeasurement___(__promise)
|
|
580
|
+
__result
|
|
581
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_ARObjectMeasurement_ in
|
|
582
|
+
if let __unwrappedValue = __result {
|
|
583
|
+
return bridge.create_std__optional_ARObjectMeasurement_(__unwrappedValue)
|
|
584
|
+
} else {
|
|
585
|
+
return .init()
|
|
586
|
+
}
|
|
587
|
+
}()) })
|
|
588
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
589
|
+
return __promise
|
|
590
|
+
}()
|
|
591
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__optional_ARObjectMeasurement____(__resultCpp)
|
|
592
|
+
} catch (let __error) {
|
|
593
|
+
let __exceptionPtr = __error.toCpp()
|
|
594
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__optional_ARObjectMeasurement____(__exceptionPtr)
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
545
598
|
public final func getView() -> UnsafeMutableRawPointer {
|
|
546
599
|
return Unmanaged.passRetained(__implementation.view).toOpaque()
|
|
547
600
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ARObjectMeasurement.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <vector>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::ar {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (ARObjectMeasurement).
|
|
39
|
+
*/
|
|
40
|
+
struct ARObjectMeasurement final {
|
|
41
|
+
public:
|
|
42
|
+
double width SWIFT_PRIVATE;
|
|
43
|
+
double height SWIFT_PRIVATE;
|
|
44
|
+
double depth SWIFT_PRIVATE;
|
|
45
|
+
std::vector<double> center SWIFT_PRIVATE;
|
|
46
|
+
std::vector<double> axes SWIFT_PRIVATE;
|
|
47
|
+
double confidence SWIFT_PRIVATE;
|
|
48
|
+
double pointCount SWIFT_PRIVATE;
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
ARObjectMeasurement() = default;
|
|
52
|
+
explicit ARObjectMeasurement(double width, double height, double depth, std::vector<double> center, std::vector<double> axes, double confidence, double pointCount): width(width), height(height), depth(depth), center(center), axes(axes), confidence(confidence), pointCount(pointCount) {}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
friend bool operator==(const ARObjectMeasurement& lhs, const ARObjectMeasurement& rhs) = default;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::ar
|
|
59
|
+
|
|
60
|
+
namespace margelo::nitro {
|
|
61
|
+
|
|
62
|
+
// C++ ARObjectMeasurement <> JS ARObjectMeasurement (object)
|
|
63
|
+
template <>
|
|
64
|
+
struct JSIConverter<margelo::nitro::ar::ARObjectMeasurement> final {
|
|
65
|
+
static inline margelo::nitro::ar::ARObjectMeasurement fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
66
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
67
|
+
return margelo::nitro::ar::ARObjectMeasurement(
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
|
|
69
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "depth"))),
|
|
71
|
+
JSIConverter<std::vector<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "center"))),
|
|
72
|
+
JSIConverter<std::vector<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "axes"))),
|
|
73
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confidence"))),
|
|
74
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pointCount")))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ar::ARObjectMeasurement& arg) {
|
|
78
|
+
jsi::Object obj(runtime);
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "depth"), JSIConverter<double>::toJSI(runtime, arg.depth));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "center"), JSIConverter<std::vector<double>>::toJSI(runtime, arg.center));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "axes"), JSIConverter<std::vector<double>>::toJSI(runtime, arg.axes));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "confidence"), JSIConverter<double>::toJSI(runtime, arg.confidence));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "pointCount"), JSIConverter<double>::toJSI(runtime, arg.pointCount));
|
|
86
|
+
return obj;
|
|
87
|
+
}
|
|
88
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
89
|
+
if (!value.isObject()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
jsi::Object obj = value.getObject(runtime);
|
|
93
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
|
|
97
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
|
|
98
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "depth")))) return false;
|
|
99
|
+
if (!JSIConverter<std::vector<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "center")))) return false;
|
|
100
|
+
if (!JSIConverter<std::vector<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "axes")))) return false;
|
|
101
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confidence")))) return false;
|
|
102
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pointCount")))) return false;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridARSegmentationResultSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridARSegmentationResultSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::ar {
|
|
11
|
+
|
|
12
|
+
void HybridARSegmentationResultSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridGetter("success", &HybridARSegmentationResultSpec::getSuccess);
|
|
18
|
+
prototype.registerHybridGetter("boundingBox", &HybridARSegmentationResultSpec::getBoundingBox);
|
|
19
|
+
prototype.registerHybridGetter("maskPixelCount", &HybridARSegmentationResultSpec::getMaskPixelCount);
|
|
20
|
+
prototype.registerHybridMethod("getDepthPoints", &HybridARSegmentationResultSpec::getDepthPoints);
|
|
21
|
+
prototype.registerHybridMethod("measure", &HybridARSegmentationResultSpec::measure);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::ar
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridARSegmentationResultSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `ARObjectMeasurement` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::ar { struct ARObjectMeasurement; }
|
|
18
|
+
|
|
19
|
+
#include <vector>
|
|
20
|
+
#include "ARObjectMeasurement.hpp"
|
|
21
|
+
#include <optional>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::ar {
|
|
24
|
+
|
|
25
|
+
using namespace margelo::nitro;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An abstract base class for `ARSegmentationResult`
|
|
29
|
+
* Inherit this class to create instances of `HybridARSegmentationResultSpec` in C++.
|
|
30
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
31
|
+
* @example
|
|
32
|
+
* ```cpp
|
|
33
|
+
* class HybridARSegmentationResult: public HybridARSegmentationResultSpec {
|
|
34
|
+
* public:
|
|
35
|
+
* HybridARSegmentationResult(...): HybridObject(TAG) { ... }
|
|
36
|
+
* // ...
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class HybridARSegmentationResultSpec: public virtual HybridObject {
|
|
41
|
+
public:
|
|
42
|
+
// Constructor
|
|
43
|
+
explicit HybridARSegmentationResultSpec(): HybridObject(TAG) { }
|
|
44
|
+
|
|
45
|
+
// Destructor
|
|
46
|
+
~HybridARSegmentationResultSpec() override = default;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Properties
|
|
50
|
+
virtual bool getSuccess() = 0;
|
|
51
|
+
virtual std::vector<double> getBoundingBox() = 0;
|
|
52
|
+
virtual double getMaskPixelCount() = 0;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Methods
|
|
56
|
+
virtual std::vector<double> getDepthPoints() = 0;
|
|
57
|
+
virtual std::optional<ARObjectMeasurement> measure() = 0;
|
|
58
|
+
|
|
59
|
+
protected:
|
|
60
|
+
// Hybrid Setup
|
|
61
|
+
void loadHybridMethods() override;
|
|
62
|
+
|
|
63
|
+
protected:
|
|
64
|
+
// Tag for logging
|
|
65
|
+
static constexpr auto TAG = "ARSegmentationResult";
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro::ar
|
|
@@ -49,6 +49,8 @@ namespace margelo::nitro::ar {
|
|
|
49
49
|
prototype.registerHybridMethod("pauseSession", &HybridARViewSpec::pauseSession);
|
|
50
50
|
prototype.registerHybridMethod("resetSession", &HybridARViewSpec::resetSession);
|
|
51
51
|
prototype.registerHybridMethod("isLiDARAvailable", &HybridARViewSpec::isLiDARAvailable);
|
|
52
|
+
prototype.registerHybridMethod("segmentObject", &HybridARViewSpec::segmentObject);
|
|
53
|
+
prototype.registerHybridMethod("measureObject", &HybridARViewSpec::measureObject);
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -17,11 +17,19 @@
|
|
|
17
17
|
namespace margelo::nitro::ar { enum class SceneReconstructionMode; }
|
|
18
18
|
// Forward declaration of `ARViewHitResult` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::ar { struct ARViewHitResult; }
|
|
20
|
+
// Forward declaration of `HybridARSegmentationResultSpec` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::ar { class HybridARSegmentationResultSpec; }
|
|
22
|
+
// Forward declaration of `ARObjectMeasurement` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::ar { struct ARObjectMeasurement; }
|
|
20
24
|
|
|
21
25
|
#include <optional>
|
|
22
26
|
#include "SceneReconstructionMode.hpp"
|
|
23
27
|
#include <string>
|
|
24
28
|
#include "ARViewHitResult.hpp"
|
|
29
|
+
#include <memory>
|
|
30
|
+
#include "HybridARSegmentationResultSpec.hpp"
|
|
31
|
+
#include <NitroModules/Promise.hpp>
|
|
32
|
+
#include "ARObjectMeasurement.hpp"
|
|
25
33
|
|
|
26
34
|
namespace margelo::nitro::ar {
|
|
27
35
|
|
|
@@ -88,6 +96,8 @@ namespace margelo::nitro::ar {
|
|
|
88
96
|
virtual void pauseSession() = 0;
|
|
89
97
|
virtual void resetSession() = 0;
|
|
90
98
|
virtual bool isLiDARAvailable() = 0;
|
|
99
|
+
virtual std::shared_ptr<Promise<std::optional<std::shared_ptr<HybridARSegmentationResultSpec>>>> segmentObject(double x, double y) = 0;
|
|
100
|
+
virtual std::shared_ptr<Promise<std::optional<ARObjectMeasurement>>> measureObject(double x, double y) = 0;
|
|
91
101
|
|
|
92
102
|
protected:
|
|
93
103
|
// Hybrid Setup
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,6 +13,10 @@ export type {
|
|
|
13
13
|
ARLightEstimate,
|
|
14
14
|
} from "./specs/ARLightEstimate.nitro";
|
|
15
15
|
export type { ARMeasurement } from "./specs/ARMeasurement.nitro";
|
|
16
|
+
export type {
|
|
17
|
+
ARObjectMeasurement,
|
|
18
|
+
ARSegmentationResult,
|
|
19
|
+
} from "./specs/ARObjectMeasurement.nitro";
|
|
16
20
|
|
|
17
21
|
export type {
|
|
18
22
|
ARPlaneAnchor,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HybridObject } from "react-native-nitro-modules";
|
|
2
|
+
|
|
3
|
+
/** Result of measuring an object in 3D space */
|
|
4
|
+
export interface ARObjectMeasurement {
|
|
5
|
+
/** Width in meters (X axis) */
|
|
6
|
+
width: number;
|
|
7
|
+
/** Height in meters (Y axis) */
|
|
8
|
+
height: number;
|
|
9
|
+
/** Depth in meters (Z axis) */
|
|
10
|
+
depth: number;
|
|
11
|
+
/** Center position in world space [x, y, z] */
|
|
12
|
+
center: number[];
|
|
13
|
+
/** Orientation axes (3x3 matrix as 9 values) */
|
|
14
|
+
axes: number[];
|
|
15
|
+
/** Confidence score 0-1 */
|
|
16
|
+
confidence: number;
|
|
17
|
+
/** Number of 3D points used for measurement */
|
|
18
|
+
pointCount: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Result of object segmentation */
|
|
22
|
+
export interface ARSegmentationResult extends HybridObject<{ ios: "swift" }> {
|
|
23
|
+
/** Whether segmentation was successful */
|
|
24
|
+
readonly success: boolean;
|
|
25
|
+
/** Bounding box in normalized coordinates [x, y, width, height] */
|
|
26
|
+
readonly boundingBox: number[];
|
|
27
|
+
/** Number of pixels in the mask */
|
|
28
|
+
readonly maskPixelCount: number;
|
|
29
|
+
/** Get 3D points within the segmented region (requires LiDAR) */
|
|
30
|
+
getDepthPoints(): number[];
|
|
31
|
+
/** Measure the segmented object */
|
|
32
|
+
measure(): ARObjectMeasurement | undefined;
|
|
33
|
+
}
|