mediversal-rn-image-intelligence 1.0.9 → 1.0.11
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/README.md +328 -36
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/mediversalrnimagintelligence/ImageIntelligencePackage.kt +3 -2
- package/android/src/main/java/com/mediversalrnimagintelligence/ObjectDetectionModule.kt +120 -0
- package/ios/ObjectDetectionModule.m +14 -0
- package/ios/ObjectDetectionModule.swift +129 -0
- package/lib/commonjs/NativeObjectDetectionModule.js +12 -0
- package/lib/commonjs/NativeObjectDetectionModule.js.map +1 -0
- package/lib/commonjs/index.js +24 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeObjectDetectionModule.js +8 -0
- package/lib/module/NativeObjectDetectionModule.js.map +1 -0
- package/lib/module/index.js +24 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeObjectDetectionModule.d.ts +11 -0
- package/lib/typescript/NativeObjectDetectionModule.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +37 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/mediversal-rn-image-intelligence.podspec +2 -0
- package/package.json +1 -2
- package/src/NativeObjectDetectionModule.ts +14 -0
- package/src/index.tsx +35 -1
- package/src/types.ts +40 -0
package/src/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { Platform } from 'react-native';
|
|
|
2
2
|
import FaceDetectionModule from './NativeFaceDetectionModule';
|
|
3
3
|
import TextRecognitionModule from './NativeTextRecognitionModule';
|
|
4
4
|
import type { AnalysisResult, AnalysisOptions } from './types';
|
|
5
|
+
import ObjectDetectionModule from './NativeObjectDetectionModule';
|
|
5
6
|
|
|
6
7
|
// Export types for consumers
|
|
7
8
|
export type {
|
|
@@ -9,6 +10,8 @@ export type {
|
|
|
9
10
|
AnalysisOptions,
|
|
10
11
|
FaceData,
|
|
11
12
|
BoundingBox,
|
|
13
|
+
ObjectData,
|
|
14
|
+
ObjectLabel,
|
|
12
15
|
} from './types';
|
|
13
16
|
|
|
14
17
|
/**
|
|
@@ -17,6 +20,7 @@ export type {
|
|
|
17
20
|
const DEFAULT_OPTIONS: Required<AnalysisOptions> = {
|
|
18
21
|
detectFaces: true,
|
|
19
22
|
detectPrintedText: true,
|
|
23
|
+
detectObjects: true,
|
|
20
24
|
faceDetectionMode: 'fast',
|
|
21
25
|
minFaceSize: 0.1,
|
|
22
26
|
};
|
|
@@ -114,6 +118,7 @@ export async function analyzeImage(
|
|
|
114
118
|
const result: AnalysisResult = {
|
|
115
119
|
containsFace: false,
|
|
116
120
|
containsPrintedText: false,
|
|
121
|
+
containsObjects: false,
|
|
117
122
|
};
|
|
118
123
|
|
|
119
124
|
// Create promises array for parallel execution
|
|
@@ -171,6 +176,31 @@ export async function analyzeImage(
|
|
|
171
176
|
);
|
|
172
177
|
}
|
|
173
178
|
|
|
179
|
+
// Object Detection
|
|
180
|
+
if (opts.detectObjects) {
|
|
181
|
+
promises.push(
|
|
182
|
+
(async () => {
|
|
183
|
+
try {
|
|
184
|
+
const objectResult = await ObjectDetectionModule.detectObjects(
|
|
185
|
+
validatedUri
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
if (objectResult.error) {
|
|
189
|
+
result.errors = result.errors || {};
|
|
190
|
+
result.errors.objectDetection = objectResult.error;
|
|
191
|
+
} else if (objectResult.objects && objectResult.objects.length > 0) {
|
|
192
|
+
result.containsObjects = true;
|
|
193
|
+
result.objects = objectResult.objects;
|
|
194
|
+
}
|
|
195
|
+
} catch (error) {
|
|
196
|
+
result.errors = result.errors || {};
|
|
197
|
+
result.errors.objectDetection =
|
|
198
|
+
error instanceof Error ? error.message : 'Unknown error';
|
|
199
|
+
}
|
|
200
|
+
})()
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
174
204
|
// Wait for all analyses to complete
|
|
175
205
|
await Promise.all(promises);
|
|
176
206
|
|
|
@@ -193,7 +223,11 @@ export async function analyzeImage(
|
|
|
193
223
|
*/
|
|
194
224
|
export async function isAvailable(): Promise<boolean> {
|
|
195
225
|
try {
|
|
196
|
-
return !!(
|
|
226
|
+
return !!(
|
|
227
|
+
FaceDetectionModule &&
|
|
228
|
+
TextRecognitionModule &&
|
|
229
|
+
ObjectDetectionModule
|
|
230
|
+
);
|
|
197
231
|
} catch {
|
|
198
232
|
return false;
|
|
199
233
|
}
|
package/src/types.ts
CHANGED
|
@@ -38,12 +38,17 @@ export interface AnalysisResult {
|
|
|
38
38
|
containsPrintedText: boolean;
|
|
39
39
|
/** Array of detected faces with metadata */
|
|
40
40
|
faces?: FaceData[];
|
|
41
|
+
/** True if object was detected */
|
|
42
|
+
containsObjects: boolean;
|
|
43
|
+
/** Array of detected objects with labels */
|
|
44
|
+
objects?: ObjectData[];
|
|
41
45
|
/** Extracted printed text content */
|
|
42
46
|
printedText?: string;
|
|
43
47
|
/** Error messages if any module failed (won't throw, for graceful degradation) */
|
|
44
48
|
errors?: {
|
|
45
49
|
faceDetection?: string;
|
|
46
50
|
textRecognition?: string;
|
|
51
|
+
objectDetection?: string;
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
54
|
|
|
@@ -57,6 +62,8 @@ export interface AnalysisOptions {
|
|
|
57
62
|
detectPrintedText?: boolean;
|
|
58
63
|
/** Face detection performance mode: 'fast' or 'accurate' (default: 'fast') */
|
|
59
64
|
faceDetectionMode?: 'fast' | 'accurate';
|
|
65
|
+
/** Enable object detection (default: false) */
|
|
66
|
+
detectObjects?: boolean;
|
|
60
67
|
/** Minimum face size relative to image (0.0 to 1.0, default: 0.1) */
|
|
61
68
|
minFaceSize?: number;
|
|
62
69
|
}
|
|
@@ -83,3 +90,36 @@ export interface NativeTextRecognitionResult {
|
|
|
83
90
|
* Internal handwriting recognition result from native module
|
|
84
91
|
* @internal
|
|
85
92
|
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Detected object information
|
|
96
|
+
*/
|
|
97
|
+
export interface ObjectData {
|
|
98
|
+
/** Bounding box of the detected object */
|
|
99
|
+
boundingBox: BoundingBox;
|
|
100
|
+
/** Tracking ID for video sequences */
|
|
101
|
+
trackingId?: number;
|
|
102
|
+
/** Object labels with confidence scores */
|
|
103
|
+
labels: ObjectLabel[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Object label with confidence
|
|
108
|
+
*/
|
|
109
|
+
export interface ObjectLabel {
|
|
110
|
+
/** Label text (e.g., "Dog", "Car", "Person") */
|
|
111
|
+
text: string;
|
|
112
|
+
/** Confidence score (0.0 to 1.0) */
|
|
113
|
+
confidence: number;
|
|
114
|
+
/** Label index */
|
|
115
|
+
index: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Internal object detection result from native module
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export interface NativeObjectDetectionResult {
|
|
123
|
+
objects: ObjectData[];
|
|
124
|
+
error?: string;
|
|
125
|
+
}
|