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,91 @@
1
+ ///
2
+ /// ImageData.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 <NitroModules/ArrayBuffer.hpp>
34
+
35
+ namespace margelo::nitro::cameravisionpixelcolors {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (ImageData).
39
+ */
40
+ struct ImageData final {
41
+ public:
42
+ double width SWIFT_PRIVATE;
43
+ double height SWIFT_PRIVATE;
44
+ std::shared_ptr<ArrayBuffer> data SWIFT_PRIVATE;
45
+
46
+ public:
47
+ ImageData() = default;
48
+ explicit ImageData(double width, double height, std::shared_ptr<ArrayBuffer> data): width(width), height(height), data(data) {}
49
+
50
+ public:
51
+ friend bool operator==(const ImageData& lhs, const ImageData& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::cameravisionpixelcolors
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ ImageData <> JS ImageData (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::cameravisionpixelcolors::ImageData> final {
61
+ static inline margelo::nitro::cameravisionpixelcolors::ImageData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::cameravisionpixelcolors::ImageData(
64
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
66
+ JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::cameravisionpixelcolors::ImageData& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.data));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
85
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
86
+ if (!JSIConverter<std::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// MotionResult.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
+
34
+
35
+ namespace margelo::nitro::cameravisionpixelcolors {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (MotionResult).
39
+ */
40
+ struct MotionResult final {
41
+ public:
42
+ double score SWIFT_PRIVATE;
43
+ bool hasMotion SWIFT_PRIVATE;
44
+
45
+ public:
46
+ MotionResult() = default;
47
+ explicit MotionResult(double score, bool hasMotion): score(score), hasMotion(hasMotion) {}
48
+
49
+ public:
50
+ friend bool operator==(const MotionResult& lhs, const MotionResult& rhs) = default;
51
+ };
52
+
53
+ } // namespace margelo::nitro::cameravisionpixelcolors
54
+
55
+ namespace margelo::nitro {
56
+
57
+ // C++ MotionResult <> JS MotionResult (object)
58
+ template <>
59
+ struct JSIConverter<margelo::nitro::cameravisionpixelcolors::MotionResult> final {
60
+ static inline margelo::nitro::cameravisionpixelcolors::MotionResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
61
+ jsi::Object obj = arg.asObject(runtime);
62
+ return margelo::nitro::cameravisionpixelcolors::MotionResult(
63
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "score"))),
64
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasMotion")))
65
+ );
66
+ }
67
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::cameravisionpixelcolors::MotionResult& arg) {
68
+ jsi::Object obj(runtime);
69
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "score"), JSIConverter<double>::toJSI(runtime, arg.score));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "hasMotion"), JSIConverter<bool>::toJSI(runtime, arg.hasMotion));
71
+ return obj;
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isObject()) {
75
+ return false;
76
+ }
77
+ jsi::Object obj = value.getObject(runtime);
78
+ if (!nitro::isPlainObject(runtime, obj)) {
79
+ return false;
80
+ }
81
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "score")))) return false;
82
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hasMotion")))) return false;
83
+ return true;
84
+ }
85
+ };
86
+
87
+ } // namespace margelo::nitro
@@ -0,0 +1,105 @@
1
+ ///
2
+ /// PixelColorsResult.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
+ // Forward declaration of `RGBColor` to properly resolve imports.
32
+ namespace margelo::nitro::cameravisionpixelcolors { struct RGBColor; }
33
+ // Forward declaration of `MotionResult` to properly resolve imports.
34
+ namespace margelo::nitro::cameravisionpixelcolors { struct MotionResult; }
35
+
36
+ #include "RGBColor.hpp"
37
+ #include <vector>
38
+ #include "MotionResult.hpp"
39
+ #include <optional>
40
+
41
+ namespace margelo::nitro::cameravisionpixelcolors {
42
+
43
+ /**
44
+ * A struct which can be represented as a JavaScript object (PixelColorsResult).
45
+ */
46
+ struct PixelColorsResult final {
47
+ public:
48
+ double uniqueColorCount SWIFT_PRIVATE;
49
+ std::vector<RGBColor> topColors SWIFT_PRIVATE;
50
+ std::vector<RGBColor> brightestColors SWIFT_PRIVATE;
51
+ std::optional<MotionResult> motion SWIFT_PRIVATE;
52
+ std::optional<bool> roiApplied SWIFT_PRIVATE;
53
+
54
+ public:
55
+ PixelColorsResult() = default;
56
+ explicit PixelColorsResult(double uniqueColorCount, std::vector<RGBColor> topColors, std::vector<RGBColor> brightestColors, std::optional<MotionResult> motion, std::optional<bool> roiApplied): uniqueColorCount(uniqueColorCount), topColors(topColors), brightestColors(brightestColors), motion(motion), roiApplied(roiApplied) {}
57
+
58
+ public:
59
+ friend bool operator==(const PixelColorsResult& lhs, const PixelColorsResult& rhs) = default;
60
+ };
61
+
62
+ } // namespace margelo::nitro::cameravisionpixelcolors
63
+
64
+ namespace margelo::nitro {
65
+
66
+ // C++ PixelColorsResult <> JS PixelColorsResult (object)
67
+ template <>
68
+ struct JSIConverter<margelo::nitro::cameravisionpixelcolors::PixelColorsResult> final {
69
+ static inline margelo::nitro::cameravisionpixelcolors::PixelColorsResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
70
+ jsi::Object obj = arg.asObject(runtime);
71
+ return margelo::nitro::cameravisionpixelcolors::PixelColorsResult(
72
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uniqueColorCount"))),
73
+ JSIConverter<std::vector<margelo::nitro::cameravisionpixelcolors::RGBColor>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "topColors"))),
74
+ JSIConverter<std::vector<margelo::nitro::cameravisionpixelcolors::RGBColor>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "brightestColors"))),
75
+ JSIConverter<std::optional<margelo::nitro::cameravisionpixelcolors::MotionResult>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "motion"))),
76
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "roiApplied")))
77
+ );
78
+ }
79
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::cameravisionpixelcolors::PixelColorsResult& arg) {
80
+ jsi::Object obj(runtime);
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "uniqueColorCount"), JSIConverter<double>::toJSI(runtime, arg.uniqueColorCount));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "topColors"), JSIConverter<std::vector<margelo::nitro::cameravisionpixelcolors::RGBColor>>::toJSI(runtime, arg.topColors));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "brightestColors"), JSIConverter<std::vector<margelo::nitro::cameravisionpixelcolors::RGBColor>>::toJSI(runtime, arg.brightestColors));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "motion"), JSIConverter<std::optional<margelo::nitro::cameravisionpixelcolors::MotionResult>>::toJSI(runtime, arg.motion));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "roiApplied"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.roiApplied));
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, "uniqueColorCount")))) return false;
97
+ if (!JSIConverter<std::vector<margelo::nitro::cameravisionpixelcolors::RGBColor>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "topColors")))) return false;
98
+ if (!JSIConverter<std::vector<margelo::nitro::cameravisionpixelcolors::RGBColor>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "brightestColors")))) return false;
99
+ if (!JSIConverter<std::optional<margelo::nitro::cameravisionpixelcolors::MotionResult>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "motion")))) return false;
100
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "roiApplied")))) return false;
101
+ return true;
102
+ }
103
+ };
104
+
105
+ } // namespace margelo::nitro
@@ -0,0 +1,91 @@
1
+ ///
2
+ /// RGBColor.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
+
34
+
35
+ namespace margelo::nitro::cameravisionpixelcolors {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (RGBColor).
39
+ */
40
+ struct RGBColor final {
41
+ public:
42
+ double r SWIFT_PRIVATE;
43
+ double g SWIFT_PRIVATE;
44
+ double b SWIFT_PRIVATE;
45
+
46
+ public:
47
+ RGBColor() = default;
48
+ explicit RGBColor(double r, double g, double b): r(r), g(g), b(b) {}
49
+
50
+ public:
51
+ friend bool operator==(const RGBColor& lhs, const RGBColor& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::cameravisionpixelcolors
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ RGBColor <> JS RGBColor (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::cameravisionpixelcolors::RGBColor> final {
61
+ static inline margelo::nitro::cameravisionpixelcolors::RGBColor fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::cameravisionpixelcolors::RGBColor(
64
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "r"))),
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "g"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "b")))
67
+ );
68
+ }
69
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::cameravisionpixelcolors::RGBColor& arg) {
70
+ jsi::Object obj(runtime);
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "r"), JSIConverter<double>::toJSI(runtime, arg.r));
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "g"), JSIConverter<double>::toJSI(runtime, arg.g));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "b"), JSIConverter<double>::toJSI(runtime, arg.b));
74
+ return obj;
75
+ }
76
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
77
+ if (!value.isObject()) {
78
+ return false;
79
+ }
80
+ jsi::Object obj = value.getObject(runtime);
81
+ if (!nitro::isPlainObject(runtime, obj)) {
82
+ return false;
83
+ }
84
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "r")))) return false;
85
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "g")))) return false;
86
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "b")))) return false;
87
+ return true;
88
+ }
89
+ };
90
+
91
+ } // namespace margelo::nitro
package/package.json ADDED
@@ -0,0 +1,143 @@
1
+ {
2
+ "name": "react-native-camera-vision-pixel-colors",
3
+ "version": "0.1.0",
4
+ "description": "Vision Camera Frame Processor plugin for real-time pixel color analysis - extract dominant colors, brightness, ROI, motion detection",
5
+ "main": "./lib/commonjs/index.js",
6
+ "module": "./lib/module/index.js",
7
+ "types": "./lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "scripts": {
11
+ "typecheck": "tsc --noEmit",
12
+ "clean": "git clean -dfX",
13
+ "release": "semantic-release",
14
+ "build": "npm run typecheck && bob build",
15
+ "codegen": "nitrogen --logLevel=\"debug\" && npm run build && node post-script.js",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "keywords": [
19
+ "react-native",
20
+ "vision-camera",
21
+ "frame-processor",
22
+ "pixel-colors",
23
+ "color-analysis",
24
+ "image-processing",
25
+ "nitro-modules",
26
+ "expo",
27
+ "ios",
28
+ "android"
29
+ ],
30
+ "files": [
31
+ "src",
32
+ "react-native.config.js",
33
+ "lib",
34
+ "nitrogen",
35
+ "cpp",
36
+ "nitro.json",
37
+ "android/build.gradle",
38
+ "android/fix-prefab.gradle",
39
+ "android/gradle.properties",
40
+ "android/CMakeLists.txt",
41
+ "android/src",
42
+ "ios/**/*.h",
43
+ "ios/**/*.m",
44
+ "ios/**/*.mm",
45
+ "ios/**/*.cpp",
46
+ "ios/**/*.swift",
47
+ "app.plugin.js",
48
+ "plugin",
49
+ "*.podspec",
50
+ "README.md"
51
+ ],
52
+ "workspaces": [
53
+ "example"
54
+ ],
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "https://github.com/yevhenjl/react-native-camera-vision-pixel-colors.git"
58
+ },
59
+ "author": "Yevhen Lahodiuk",
60
+ "license": "MIT",
61
+ "bugs": "https://github.com/yevhenjl/react-native-camera-vision-pixel-colors/issues",
62
+ "homepage": "https://github.com/yevhenjl/react-native-camera-vision-pixel-colors#readme",
63
+ "publishConfig": {
64
+ "access": "public",
65
+ "provenance": true,
66
+ "registry": "https://registry.npmjs.org/"
67
+ },
68
+ "dependencies": {
69
+ "@expo/config-plugins": "^54.0.4"
70
+ },
71
+ "devDependencies": {
72
+ "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
73
+ "@semantic-release/changelog": "^6.0.3",
74
+ "@semantic-release/git": "^10.0.1",
75
+ "@types/jest": "^29.5.12",
76
+ "@types/react": "19.1.0",
77
+ "nitrogen": "0.33.2",
78
+ "react": "19.1.0",
79
+ "react-native": "0.81.5",
80
+ "react-native-builder-bob": "^0.40.17",
81
+ "react-native-nitro-modules": "0.33.2",
82
+ "react-native-vision-camera": "^4.7.3",
83
+ "react-native-worklets-core": "^1.6.2",
84
+ "conventional-changelog-conventionalcommits": "^9.1.0",
85
+ "semantic-release": "^25.0.2",
86
+ "typescript": "^5.9.3"
87
+ },
88
+ "peerDependencies": {
89
+ "react": "*",
90
+ "react-native": "*",
91
+ "react-native-nitro-modules": "*",
92
+ "react-native-vision-camera": ">=4.0.0",
93
+ "react-native-worklets-core": ">=1.0.0"
94
+ },
95
+ "eslintConfig": {
96
+ "root": true,
97
+ "extends": [
98
+ "@react-native",
99
+ "prettier"
100
+ ],
101
+ "plugins": [
102
+ "prettier"
103
+ ],
104
+ "rules": {
105
+ "prettier/prettier": [
106
+ "warn",
107
+ {
108
+ "quoteProps": "consistent",
109
+ "singleQuote": true,
110
+ "tabWidth": 2,
111
+ "trailingComma": "es5",
112
+ "useTabs": false
113
+ }
114
+ ]
115
+ }
116
+ },
117
+ "eslintIgnore": [
118
+ "node_modules/",
119
+ "lib/"
120
+ ],
121
+ "prettier": {
122
+ "quoteProps": "consistent",
123
+ "singleQuote": true,
124
+ "tabWidth": 2,
125
+ "trailingComma": "es5",
126
+ "useTabs": false,
127
+ "semi": false
128
+ },
129
+ "react-native-builder-bob": {
130
+ "source": "src",
131
+ "output": "lib",
132
+ "targets": [
133
+ "commonjs",
134
+ "module",
135
+ [
136
+ "typescript",
137
+ {
138
+ "project": "tsconfig.json"
139
+ }
140
+ ]
141
+ ]
142
+ }
143
+ }
@@ -0,0 +1,12 @@
1
+ const { withPlugins } = require('@expo/config-plugins');
2
+ const withPixelColorsIOS = require('./withPixelColorsIOS');
3
+ const withPixelColorsAndroid = require('./withPixelColorsAndroid');
4
+
5
+ const withPixelColors = (config) => {
6
+ return withPlugins(config, [
7
+ withPixelColorsIOS,
8
+ withPixelColorsAndroid,
9
+ ]);
10
+ };
11
+
12
+ module.exports = withPixelColors;
@@ -0,0 +1,11 @@
1
+ const { withAndroidManifest } = require('@expo/config-plugins');
2
+
3
+ const withPixelColorsAndroid = (config) => {
4
+ return withAndroidManifest(config, (config) => {
5
+ // Camera permission is handled by react-native-vision-camera plugin
6
+ // This plugin is a pass-through for Android as VisionCamera handles permissions
7
+ return config;
8
+ });
9
+ };
10
+
11
+ module.exports = withPixelColorsAndroid;
@@ -0,0 +1,11 @@
1
+ const { withInfoPlist } = require('@expo/config-plugins');
2
+
3
+ const withPixelColorsIOS = (config) => {
4
+ return withInfoPlist(config, (config) => {
5
+ // Camera usage description is handled by react-native-vision-camera plugin
6
+ // This plugin is a pass-through for iOS as VisionCamera handles permissions
7
+ return config;
8
+ });
9
+ };
10
+
11
+ module.exports = withPixelColorsIOS;
package/src/index.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { NitroModules } from 'react-native-nitro-modules'
2
+ import { VisionCameraProxy, type Frame } from 'react-native-vision-camera'
3
+ import type {
4
+ CameraVisionPixelColors as CameraVisionPixelColorsSpec,
5
+ PixelColorsResult,
6
+ RGBColor,
7
+ ImageData,
8
+ ROIConfig,
9
+ AnalysisOptions,
10
+ MotionResult,
11
+ } from './specs/camera-vision-pixel-colors.nitro'
12
+
13
+ // Nitro HybridObject for async image analysis
14
+ export const CameraVisionPixelColors =
15
+ NitroModules.createHybridObject<CameraVisionPixelColorsSpec>(
16
+ 'CameraVisionPixelColors'
17
+ )
18
+
19
+ // Frame Processor plugin for real-time analysis
20
+ const plugin = VisionCameraProxy.initFrameProcessorPlugin('pixelColors', {})
21
+
22
+ export function analyzePixelColors(
23
+ frame: Frame,
24
+ options?: AnalysisOptions
25
+ ): PixelColorsResult {
26
+ 'worklet'
27
+ if (!plugin) {
28
+ throw new Error('pixelColors frame processor plugin is not available')
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ return plugin.call(frame, { options } as any) as unknown as PixelColorsResult
32
+ }
33
+
34
+ // Re-export types
35
+ export type {
36
+ PixelColorsResult,
37
+ RGBColor,
38
+ ImageData,
39
+ ROIConfig,
40
+ AnalysisOptions,
41
+ MotionResult,
42
+ }
@@ -0,0 +1,40 @@
1
+ import { type HybridObject } from 'react-native-nitro-modules'
2
+
3
+ export type RGBColor = { r: number; g: number; b: number }
4
+
5
+ export type ROIConfig = {
6
+ x: number // 0-1 normalized
7
+ y: number // 0-1 normalized
8
+ width: number // 0-1 normalized
9
+ height: number // 0-1 normalized
10
+ }
11
+
12
+ export type AnalysisOptions = {
13
+ enableMotionDetection?: boolean // default: false
14
+ motionThreshold?: number // default: 0.1
15
+ roi?: ROIConfig // if provided, analyze only this region
16
+ }
17
+
18
+ export type MotionResult = {
19
+ score: number // 0-1
20
+ hasMotion: boolean // score > threshold
21
+ }
22
+
23
+ export type PixelColorsResult = {
24
+ uniqueColorCount: number
25
+ topColors: RGBColor[]
26
+ brightestColors: RGBColor[]
27
+ motion?: MotionResult // always present if enableMotionDetection=true
28
+ roiApplied?: boolean // true if ROI config was provided
29
+ }
30
+
31
+ export type ImageData = {
32
+ width: number
33
+ height: number
34
+ data: ArrayBuffer
35
+ }
36
+
37
+ export interface CameraVisionPixelColors
38
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
39
+ analyzeImageAsync(image: ImageData): Promise<PixelColorsResult>
40
+ }