react-native-camera-vision-pixel-colors 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 (79) hide show
  1. package/CameraVisionPixelColors.podspec +32 -0
  2. package/LICENSE +21 -0
  3. package/README.md +190 -0
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +151 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  10. package/android/src/main/java/com/cameravisionpixelcolors/CameraVisionPixelColorsPackage.kt +24 -0
  11. package/android/src/main/java/com/cameravisionpixelcolors/PixelAnalyzerEngine.kt +256 -0
  12. package/android/src/main/java/com/cameravisionpixelcolors/PixelColorsFrameProcessor.kt +40 -0
  13. package/android/src/main/java/com/cameravisionpixelcolors/YuvToBitmapConverter.kt +33 -0
  14. package/android/src/main/java/com/margelo/nitro/cameravisionpixelcolors/HybridCameraVisionPixelColors.kt +50 -0
  15. package/app.plugin.js +1 -0
  16. package/ios/Bridge.h +8 -0
  17. package/ios/HybridCameraVisionPixelColors.swift +53 -0
  18. package/ios/PixelAnalyzerEngine.swift +346 -0
  19. package/ios/PixelColorsFrameProcessor.m +5 -0
  20. package/ios/PixelColorsFrameProcessor.swift +50 -0
  21. package/lib/commonjs/index.js +28 -0
  22. package/lib/commonjs/index.js.map +1 -0
  23. package/lib/commonjs/package.json +1 -0
  24. package/lib/commonjs/specs/camera-vision-pixel-colors.nitro.js +6 -0
  25. package/lib/commonjs/specs/camera-vision-pixel-colors.nitro.js.map +1 -0
  26. package/lib/module/index.js +23 -0
  27. package/lib/module/index.js.map +1 -0
  28. package/lib/module/specs/camera-vision-pixel-colors.nitro.js +4 -0
  29. package/lib/module/specs/camera-vision-pixel-colors.nitro.js.map +1 -0
  30. package/lib/typescript/src/index.d.ts +6 -0
  31. package/lib/typescript/src/index.d.ts.map +1 -0
  32. package/lib/typescript/src/specs/camera-vision-pixel-colors.nitro.d.ts +40 -0
  33. package/lib/typescript/src/specs/camera-vision-pixel-colors.nitro.d.ts.map +1 -0
  34. package/nitro.json +25 -0
  35. package/nitrogen/generated/.gitattributes +1 -0
  36. package/nitrogen/generated/android/CameraVisionPixelColors+autolinking.cmake +81 -0
  37. package/nitrogen/generated/android/CameraVisionPixelColors+autolinking.gradle +27 -0
  38. package/nitrogen/generated/android/CameraVisionPixelColorsOnLoad.cpp +44 -0
  39. package/nitrogen/generated/android/CameraVisionPixelColorsOnLoad.hpp +25 -0
  40. package/nitrogen/generated/android/c++/JHybridCameraVisionPixelColorsSpec.cpp +90 -0
  41. package/nitrogen/generated/android/c++/JHybridCameraVisionPixelColorsSpec.hpp +66 -0
  42. package/nitrogen/generated/android/c++/JImageData.hpp +66 -0
  43. package/nitrogen/generated/android/c++/JMotionResult.hpp +61 -0
  44. package/nitrogen/generated/android/c++/JPixelColorsResult.hpp +114 -0
  45. package/nitrogen/generated/android/c++/JRGBColor.hpp +65 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cameravisionpixelcolors/CameraVisionPixelColorsOnLoad.kt +35 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cameravisionpixelcolors/HybridCameraVisionPixelColorsSpec.kt +58 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cameravisionpixelcolors/ImageData.kt +44 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cameravisionpixelcolors/MotionResult.kt +41 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cameravisionpixelcolors/PixelColorsResult.kt +50 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cameravisionpixelcolors/RGBColor.kt +44 -0
  52. package/nitrogen/generated/ios/CameraVisionPixelColors+autolinking.rb +60 -0
  53. package/nitrogen/generated/ios/CameraVisionPixelColors-Swift-Cxx-Bridge.cpp +49 -0
  54. package/nitrogen/generated/ios/CameraVisionPixelColors-Swift-Cxx-Bridge.hpp +162 -0
  55. package/nitrogen/generated/ios/CameraVisionPixelColors-Swift-Cxx-Umbrella.hpp +59 -0
  56. package/nitrogen/generated/ios/CameraVisionPixelColorsAutolinking.mm +33 -0
  57. package/nitrogen/generated/ios/CameraVisionPixelColorsAutolinking.swift +26 -0
  58. package/nitrogen/generated/ios/c++/HybridCameraVisionPixelColorsSpecSwift.cpp +11 -0
  59. package/nitrogen/generated/ios/c++/HybridCameraVisionPixelColorsSpecSwift.hpp +99 -0
  60. package/nitrogen/generated/ios/swift/Func_void_PixelColorsResult.swift +47 -0
  61. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  62. package/nitrogen/generated/ios/swift/HybridCameraVisionPixelColorsSpec.swift +56 -0
  63. package/nitrogen/generated/ios/swift/HybridCameraVisionPixelColorsSpec_cxx.swift +146 -0
  64. package/nitrogen/generated/ios/swift/ImageData.swift +40 -0
  65. package/nitrogen/generated/ios/swift/MotionResult.swift +35 -0
  66. package/nitrogen/generated/ios/swift/PixelColorsResult.swift +81 -0
  67. package/nitrogen/generated/ios/swift/RGBColor.swift +40 -0
  68. package/nitrogen/generated/shared/c++/HybridCameraVisionPixelColorsSpec.cpp +21 -0
  69. package/nitrogen/generated/shared/c++/HybridCameraVisionPixelColorsSpec.hpp +67 -0
  70. package/nitrogen/generated/shared/c++/ImageData.hpp +91 -0
  71. package/nitrogen/generated/shared/c++/MotionResult.hpp +87 -0
  72. package/nitrogen/generated/shared/c++/PixelColorsResult.hpp +105 -0
  73. package/nitrogen/generated/shared/c++/RGBColor.hpp +91 -0
  74. package/package.json +143 -0
  75. package/plugin/withPixelColors.js +12 -0
  76. package/plugin/withPixelColorsAndroid.js +11 -0
  77. package/plugin/withPixelColorsIOS.js +11 -0
  78. package/src/index.ts +42 -0
  79. package/src/specs/camera-vision-pixel-colors.nitro.ts +40 -0
@@ -0,0 +1,99 @@
1
+ ///
2
+ /// HybridCameraVisionPixelColorsSpecSwift.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
+ #include "HybridCameraVisionPixelColorsSpec.hpp"
11
+
12
+ // Forward declaration of `HybridCameraVisionPixelColorsSpec_cxx` to properly resolve imports.
13
+ namespace CameraVisionPixelColors { class HybridCameraVisionPixelColorsSpec_cxx; }
14
+
15
+ // Forward declaration of `PixelColorsResult` to properly resolve imports.
16
+ namespace margelo::nitro::cameravisionpixelcolors { struct PixelColorsResult; }
17
+ // Forward declaration of `RGBColor` to properly resolve imports.
18
+ namespace margelo::nitro::cameravisionpixelcolors { struct RGBColor; }
19
+ // Forward declaration of `MotionResult` to properly resolve imports.
20
+ namespace margelo::nitro::cameravisionpixelcolors { struct MotionResult; }
21
+ // Forward declaration of `ImageData` to properly resolve imports.
22
+ namespace margelo::nitro::cameravisionpixelcolors { struct ImageData; }
23
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
24
+ namespace NitroModules { class ArrayBufferHolder; }
25
+
26
+ #include "PixelColorsResult.hpp"
27
+ #include <NitroModules/Promise.hpp>
28
+ #include "RGBColor.hpp"
29
+ #include <vector>
30
+ #include "MotionResult.hpp"
31
+ #include <optional>
32
+ #include "ImageData.hpp"
33
+ #include <NitroModules/ArrayBuffer.hpp>
34
+ #include <NitroModules/ArrayBufferHolder.hpp>
35
+
36
+ #include "CameraVisionPixelColors-Swift-Cxx-Umbrella.hpp"
37
+
38
+ namespace margelo::nitro::cameravisionpixelcolors {
39
+
40
+ /**
41
+ * The C++ part of HybridCameraVisionPixelColorsSpec_cxx.swift.
42
+ *
43
+ * HybridCameraVisionPixelColorsSpecSwift (C++) accesses HybridCameraVisionPixelColorsSpec_cxx (Swift), and might
44
+ * contain some additional bridging code for C++ <> Swift interop.
45
+ *
46
+ * Since this obviously introduces an overhead, I hope at some point in
47
+ * the future, HybridCameraVisionPixelColorsSpec_cxx can directly inherit from the C++ class HybridCameraVisionPixelColorsSpec
48
+ * to simplify the whole structure and memory management.
49
+ */
50
+ class HybridCameraVisionPixelColorsSpecSwift: public virtual HybridCameraVisionPixelColorsSpec {
51
+ public:
52
+ // Constructor from a Swift instance
53
+ explicit HybridCameraVisionPixelColorsSpecSwift(const CameraVisionPixelColors::HybridCameraVisionPixelColorsSpec_cxx& swiftPart):
54
+ HybridObject(HybridCameraVisionPixelColorsSpec::TAG),
55
+ _swiftPart(swiftPart) { }
56
+
57
+ public:
58
+ // Get the Swift part
59
+ inline CameraVisionPixelColors::HybridCameraVisionPixelColorsSpec_cxx& getSwiftPart() noexcept {
60
+ return _swiftPart;
61
+ }
62
+
63
+ public:
64
+ inline size_t getExternalMemorySize() noexcept override {
65
+ return _swiftPart.getMemorySize();
66
+ }
67
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
68
+ if (auto otherCast = std::dynamic_pointer_cast<HybridCameraVisionPixelColorsSpecSwift>(other)) {
69
+ return _swiftPart.equals(otherCast->_swiftPart);
70
+ }
71
+ return false;
72
+ }
73
+ void dispose() noexcept override {
74
+ _swiftPart.dispose();
75
+ }
76
+ std::string toString() override {
77
+ return _swiftPart.toString();
78
+ }
79
+
80
+ public:
81
+ // Properties
82
+
83
+
84
+ public:
85
+ // Methods
86
+ inline std::shared_ptr<Promise<PixelColorsResult>> analyzeImageAsync(const ImageData& image) override {
87
+ auto __result = _swiftPart.analyzeImageAsync(std::forward<decltype(image)>(image));
88
+ if (__result.hasError()) [[unlikely]] {
89
+ std::rethrow_exception(__result.error());
90
+ }
91
+ auto __value = std::move(__result.value());
92
+ return __value;
93
+ }
94
+
95
+ private:
96
+ CameraVisionPixelColors::HybridCameraVisionPixelColorsSpec_cxx _swiftPart;
97
+ };
98
+
99
+ } // namespace margelo::nitro::cameravisionpixelcolors
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_PixelColorsResult.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ value: PixelColorsResult) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_PixelColorsResult {
16
+ public typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
17
+
18
+ private let closure: (_ value: PixelColorsResult) -> Void
19
+
20
+ public init(_ closure: @escaping (_ value: PixelColorsResult) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(value: PixelColorsResult) -> Void {
26
+ self.closure(value)
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_PixelColorsResult`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_PixelColorsResult>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_PixelColorsResult {
45
+ return Unmanaged<Func_void_PixelColorsResult>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__exception_ptr {
16
+ public typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
17
+
18
+ private let closure: (_ error: Error) -> Void
19
+
20
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(error: std.exception_ptr) -> Void {
26
+ self.closure(RuntimeError.from(cppError: error))
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
45
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -0,0 +1,56 @@
1
+ ///
2
+ /// HybridCameraVisionPixelColorsSpec.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 Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridCameraVisionPixelColorsSpec``
12
+ public protocol HybridCameraVisionPixelColorsSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func analyzeImageAsync(image: ImageData) throws -> Promise<PixelColorsResult>
18
+ }
19
+
20
+ public extension HybridCameraVisionPixelColorsSpec_protocol {
21
+ /// Default implementation of ``HybridObject.toString``
22
+ func toString() -> String {
23
+ return "[HybridObject CameraVisionPixelColors]"
24
+ }
25
+ }
26
+
27
+ /// See ``HybridCameraVisionPixelColorsSpec``
28
+ open class HybridCameraVisionPixelColorsSpec_base {
29
+ private weak var cxxWrapper: HybridCameraVisionPixelColorsSpec_cxx? = nil
30
+ public init() { }
31
+ public func getCxxWrapper() -> HybridCameraVisionPixelColorsSpec_cxx {
32
+ #if DEBUG
33
+ guard self is any HybridCameraVisionPixelColorsSpec else {
34
+ fatalError("`self` is not a `HybridCameraVisionPixelColorsSpec`! Did you accidentally inherit from `HybridCameraVisionPixelColorsSpec_base` instead of `HybridCameraVisionPixelColorsSpec`?")
35
+ }
36
+ #endif
37
+ if let cxxWrapper = self.cxxWrapper {
38
+ return cxxWrapper
39
+ } else {
40
+ let cxxWrapper = HybridCameraVisionPixelColorsSpec_cxx(self as! any HybridCameraVisionPixelColorsSpec)
41
+ self.cxxWrapper = cxxWrapper
42
+ return cxxWrapper
43
+ }
44
+ }
45
+ }
46
+
47
+ /**
48
+ * A Swift base-protocol representing the CameraVisionPixelColors HybridObject.
49
+ * Implement this protocol to create Swift-based instances of CameraVisionPixelColors.
50
+ * ```swift
51
+ * class HybridCameraVisionPixelColors : HybridCameraVisionPixelColorsSpec {
52
+ * // ...
53
+ * }
54
+ * ```
55
+ */
56
+ public typealias HybridCameraVisionPixelColorsSpec = HybridCameraVisionPixelColorsSpec_protocol & HybridCameraVisionPixelColorsSpec_base
@@ -0,0 +1,146 @@
1
+ ///
2
+ /// HybridCameraVisionPixelColorsSpec_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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridCameraVisionPixelColorsSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridCameraVisionPixelColorsSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::cameravisionpixelcolors::bridge::swift`)
23
+ * from `CameraVisionPixelColors-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridCameraVisionPixelColorsSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridCameraVisionPixelColorsSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridCameraVisionPixelColorsSpec_
37
+
38
+ /**
39
+ * Create a new `HybridCameraVisionPixelColorsSpec_cxx` that wraps the given `HybridCameraVisionPixelColorsSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridCameraVisionPixelColorsSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridCameraVisionPixelColorsSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridCameraVisionPixelColorsSpec() -> any HybridCameraVisionPixelColorsSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridCameraVisionPixelColorsSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridCameraVisionPixelColorsSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridCameraVisionPixelColorsSpec_cxx {
70
+ return Unmanaged<HybridCameraVisionPixelColorsSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridCameraVisionPixelColorsSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridCameraVisionPixelColorsSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridCameraVisionPixelColorsSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridCameraVisionPixelColorsSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Compares this object with the given [other] object for reference equality.
101
+ */
102
+ @inline(__always)
103
+ public func equals(other: HybridCameraVisionPixelColorsSpec_cxx) -> Bool {
104
+ return self.__implementation === other.__implementation
105
+ }
106
+
107
+ /**
108
+ * Call dispose() on the Swift class.
109
+ * This _may_ be called manually from JS.
110
+ */
111
+ @inline(__always)
112
+ public func dispose() {
113
+ self.__implementation.dispose()
114
+ }
115
+
116
+ /**
117
+ * Call toString() on the Swift class.
118
+ */
119
+ @inline(__always)
120
+ public func toString() -> String {
121
+ return self.__implementation.toString()
122
+ }
123
+
124
+ // Properties
125
+
126
+
127
+ // Methods
128
+ @inline(__always)
129
+ public final func analyzeImageAsync(image: ImageData) -> bridge.Result_std__shared_ptr_Promise_PixelColorsResult___ {
130
+ do {
131
+ let __result = try self.__implementation.analyzeImageAsync(image: image)
132
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PixelColorsResult__ in
133
+ let __promise = bridge.create_std__shared_ptr_Promise_PixelColorsResult__()
134
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PixelColorsResult__(__promise)
135
+ __result
136
+ .then({ __result in __promiseHolder.resolve(__result) })
137
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
138
+ return __promise
139
+ }()
140
+ return bridge.create_Result_std__shared_ptr_Promise_PixelColorsResult___(__resultCpp)
141
+ } catch (let __error) {
142
+ let __exceptionPtr = __error.toCpp()
143
+ return bridge.create_Result_std__shared_ptr_Promise_PixelColorsResult___(__exceptionPtr)
144
+ }
145
+ }
146
+ }
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// ImageData.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `ImageData`, backed by a C++ struct.
13
+ */
14
+ public typealias ImageData = margelo.nitro.cameravisionpixelcolors.ImageData
15
+
16
+ public extension ImageData {
17
+ private typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `ImageData`.
21
+ */
22
+ init(width: Double, height: Double, data: ArrayBuffer) {
23
+ self.init(width, height, data.getArrayBuffer())
24
+ }
25
+
26
+ @inline(__always)
27
+ var width: Double {
28
+ return self.__width
29
+ }
30
+
31
+ @inline(__always)
32
+ var height: Double {
33
+ return self.__height
34
+ }
35
+
36
+ @inline(__always)
37
+ var data: ArrayBuffer {
38
+ return ArrayBuffer(self.__data)
39
+ }
40
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// MotionResult.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `MotionResult`, backed by a C++ struct.
13
+ */
14
+ public typealias MotionResult = margelo.nitro.cameravisionpixelcolors.MotionResult
15
+
16
+ public extension MotionResult {
17
+ private typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `MotionResult`.
21
+ */
22
+ init(score: Double, hasMotion: Bool) {
23
+ self.init(score, hasMotion)
24
+ }
25
+
26
+ @inline(__always)
27
+ var score: Double {
28
+ return self.__score
29
+ }
30
+
31
+ @inline(__always)
32
+ var hasMotion: Bool {
33
+ return self.__hasMotion
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ ///
2
+ /// PixelColorsResult.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `PixelColorsResult`, backed by a C++ struct.
13
+ */
14
+ public typealias PixelColorsResult = margelo.nitro.cameravisionpixelcolors.PixelColorsResult
15
+
16
+ public extension PixelColorsResult {
17
+ private typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `PixelColorsResult`.
21
+ */
22
+ init(uniqueColorCount: Double, topColors: [RGBColor], brightestColors: [RGBColor], motion: MotionResult?, roiApplied: Bool?) {
23
+ self.init(uniqueColorCount, { () -> bridge.std__vector_RGBColor_ in
24
+ var __vector = bridge.create_std__vector_RGBColor_(topColors.count)
25
+ for __item in topColors {
26
+ __vector.push_back(__item)
27
+ }
28
+ return __vector
29
+ }(), { () -> bridge.std__vector_RGBColor_ in
30
+ var __vector = bridge.create_std__vector_RGBColor_(brightestColors.count)
31
+ for __item in brightestColors {
32
+ __vector.push_back(__item)
33
+ }
34
+ return __vector
35
+ }(), { () -> bridge.std__optional_MotionResult_ in
36
+ if let __unwrappedValue = motion {
37
+ return bridge.create_std__optional_MotionResult_(__unwrappedValue)
38
+ } else {
39
+ return .init()
40
+ }
41
+ }(), { () -> bridge.std__optional_bool_ in
42
+ if let __unwrappedValue = roiApplied {
43
+ return bridge.create_std__optional_bool_(__unwrappedValue)
44
+ } else {
45
+ return .init()
46
+ }
47
+ }())
48
+ }
49
+
50
+ @inline(__always)
51
+ var uniqueColorCount: Double {
52
+ return self.__uniqueColorCount
53
+ }
54
+
55
+ @inline(__always)
56
+ var topColors: [RGBColor] {
57
+ return self.__topColors.map({ __item in __item })
58
+ }
59
+
60
+ @inline(__always)
61
+ var brightestColors: [RGBColor] {
62
+ return self.__brightestColors.map({ __item in __item })
63
+ }
64
+
65
+ @inline(__always)
66
+ var motion: MotionResult? {
67
+ return self.__motion.value
68
+ }
69
+
70
+ @inline(__always)
71
+ var roiApplied: Bool? {
72
+ return { () -> Bool? in
73
+ if bridge.has_value_std__optional_bool_(self.__roiApplied) {
74
+ let __unwrapped = bridge.get_std__optional_bool_(self.__roiApplied)
75
+ return __unwrapped
76
+ } else {
77
+ return nil
78
+ }
79
+ }()
80
+ }
81
+ }
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// RGBColor.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 Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `RGBColor`, backed by a C++ struct.
13
+ */
14
+ public typealias RGBColor = margelo.nitro.cameravisionpixelcolors.RGBColor
15
+
16
+ public extension RGBColor {
17
+ private typealias bridge = margelo.nitro.cameravisionpixelcolors.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `RGBColor`.
21
+ */
22
+ init(r: Double, g: Double, b: Double) {
23
+ self.init(r, g, b)
24
+ }
25
+
26
+ @inline(__always)
27
+ var r: Double {
28
+ return self.__r
29
+ }
30
+
31
+ @inline(__always)
32
+ var g: Double {
33
+ return self.__g
34
+ }
35
+
36
+ @inline(__always)
37
+ var b: Double {
38
+ return self.__b
39
+ }
40
+ }
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridCameraVisionPixelColorsSpec.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 "HybridCameraVisionPixelColorsSpec.hpp"
9
+
10
+ namespace margelo::nitro::cameravisionpixelcolors {
11
+
12
+ void HybridCameraVisionPixelColorsSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("analyzeImageAsync", &HybridCameraVisionPixelColorsSpec::analyzeImageAsync);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::cameravisionpixelcolors
@@ -0,0 +1,67 @@
1
+ ///
2
+ /// HybridCameraVisionPixelColorsSpec.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 `PixelColorsResult` to properly resolve imports.
17
+ namespace margelo::nitro::cameravisionpixelcolors { struct PixelColorsResult; }
18
+ // Forward declaration of `ImageData` to properly resolve imports.
19
+ namespace margelo::nitro::cameravisionpixelcolors { struct ImageData; }
20
+
21
+ #include "PixelColorsResult.hpp"
22
+ #include <NitroModules/Promise.hpp>
23
+ #include "ImageData.hpp"
24
+
25
+ namespace margelo::nitro::cameravisionpixelcolors {
26
+
27
+ using namespace margelo::nitro;
28
+
29
+ /**
30
+ * An abstract base class for `CameraVisionPixelColors`
31
+ * Inherit this class to create instances of `HybridCameraVisionPixelColorsSpec` in C++.
32
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
33
+ * @example
34
+ * ```cpp
35
+ * class HybridCameraVisionPixelColors: public HybridCameraVisionPixelColorsSpec {
36
+ * public:
37
+ * HybridCameraVisionPixelColors(...): HybridObject(TAG) { ... }
38
+ * // ...
39
+ * };
40
+ * ```
41
+ */
42
+ class HybridCameraVisionPixelColorsSpec: public virtual HybridObject {
43
+ public:
44
+ // Constructor
45
+ explicit HybridCameraVisionPixelColorsSpec(): HybridObject(TAG) { }
46
+
47
+ // Destructor
48
+ ~HybridCameraVisionPixelColorsSpec() override = default;
49
+
50
+ public:
51
+ // Properties
52
+
53
+
54
+ public:
55
+ // Methods
56
+ virtual std::shared_ptr<Promise<PixelColorsResult>> analyzeImageAsync(const ImageData& image) = 0;
57
+
58
+ protected:
59
+ // Hybrid Setup
60
+ void loadHybridMethods() override;
61
+
62
+ protected:
63
+ // Tag for logging
64
+ static constexpr auto TAG = "CameraVisionPixelColors";
65
+ };
66
+
67
+ } // namespace margelo::nitro::cameravisionpixelcolors