mediversal-rn-image-intelligence 1.0.6 → 1.0.8
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/LICENSE +21 -0
- package/README.md +532 -131
- package/android/build.gradle +4 -6
- package/android/gradle.properties +9 -0
- package/android/src/main/java/com/mediversalrnimagintelligence/ImageIntelligencePackage.kt +1 -2
- package/lib/commonjs/index.js +2 -25
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +2 -25
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +0 -11
- package/lib/typescript/types.d.ts.map +1 -1
- package/mediversal-rn-image-intelligence.podspec +24 -0
- package/package.json +8 -5
- package/src/index.tsx +1 -38
- package/src/types.ts +0 -11
- package/android/src/main/java/com/mediversalrnimagintelligence/HandwritingRecognitionModule.kt +0 -74
- package/ios/HandwritingRecognitionModule.m +0 -14
- package/ios/HandwritingRecognitionModule.swift +0 -53
- package/lib/commonjs/NativeHandwritingRecognitionModule.js +0 -12
- package/lib/commonjs/NativeHandwritingRecognitionModule.js.map +0 -1
- package/lib/module/NativeHandwritingRecognitionModule.js +0 -8
- package/lib/module/NativeHandwritingRecognitionModule.js.map +0 -1
- package/lib/typescript/NativeHandwritingRecognitionModule.d.ts +0 -11
- package/lib/typescript/NativeHandwritingRecognitionModule.d.ts.map +0 -1
- package/src/NativeHandwritingRecognitionModule.ts +0 -16
package/android/build.gradle
CHANGED
|
@@ -6,6 +6,7 @@ buildscript {
|
|
|
6
6
|
|
|
7
7
|
dependencies {
|
|
8
8
|
classpath 'com.android.tools.build:gradle:7.4.2'
|
|
9
|
+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0'
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -35,12 +36,12 @@ android {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
compileOptions {
|
|
38
|
-
sourceCompatibility JavaVersion.
|
|
39
|
-
targetCompatibility JavaVersion.
|
|
39
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
40
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
kotlinOptions {
|
|
43
|
-
jvmTarget =
|
|
44
|
+
jvmTarget = "17"
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -62,9 +63,6 @@ dependencies {
|
|
|
62
63
|
// Google ML Kit - Text Recognition v2 (newer API)
|
|
63
64
|
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:19.0.0'
|
|
64
65
|
|
|
65
|
-
// Google ML Kit - Digital Ink Recognition
|
|
66
|
-
implementation 'com.google.mlkit:digital-ink-recognition:18.1.0'
|
|
67
|
-
|
|
68
66
|
// Coroutines for async operations
|
|
69
67
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
|
|
70
68
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
|
|
@@ -9,8 +9,7 @@ class ImageIntelligencePackage : ReactPackage {
|
|
|
9
9
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
10
|
return listOf(
|
|
11
11
|
FaceDetectionModule(reactContext),
|
|
12
|
-
TextRecognitionModule(reactContext)
|
|
13
|
-
HandwritingRecognitionModule(reactContext)
|
|
12
|
+
TextRecognitionModule(reactContext)
|
|
14
13
|
)
|
|
15
14
|
}
|
|
16
15
|
|
package/lib/commonjs/index.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.isAvailable = isAvailable;
|
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
var _NativeFaceDetectionModule = _interopRequireDefault(require("./NativeFaceDetectionModule"));
|
|
11
11
|
var _NativeTextRecognitionModule = _interopRequireDefault(require("./NativeTextRecognitionModule"));
|
|
12
|
-
var _NativeHandwritingRecognitionModule = _interopRequireDefault(require("./NativeHandwritingRecognitionModule"));
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
// Export types for consumers
|
|
15
14
|
|
|
@@ -19,7 +18,6 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
19
18
|
const DEFAULT_OPTIONS = {
|
|
20
19
|
detectFaces: true,
|
|
21
20
|
detectPrintedText: true,
|
|
22
|
-
detectHandwrittenText: true,
|
|
23
21
|
faceDetectionMode: 'fast',
|
|
24
22
|
minFaceSize: 0.1
|
|
25
23
|
};
|
|
@@ -97,8 +95,7 @@ async function analyzeImage(imageUri, options = {}) {
|
|
|
97
95
|
// Initialize result
|
|
98
96
|
const result = {
|
|
99
97
|
containsFace: false,
|
|
100
|
-
containsPrintedText: false
|
|
101
|
-
containsHandwrittenText: false
|
|
98
|
+
containsPrintedText: false
|
|
102
99
|
};
|
|
103
100
|
|
|
104
101
|
// Create promises array for parallel execution
|
|
@@ -142,25 +139,6 @@ async function analyzeImage(imageUri, options = {}) {
|
|
|
142
139
|
})());
|
|
143
140
|
}
|
|
144
141
|
|
|
145
|
-
// Handwriting Recognition
|
|
146
|
-
if (opts.detectHandwrittenText) {
|
|
147
|
-
promises.push((async () => {
|
|
148
|
-
try {
|
|
149
|
-
const handwritingResult = await _NativeHandwritingRecognitionModule.default.recognizeHandwriting(validatedUri);
|
|
150
|
-
if (handwritingResult.error) {
|
|
151
|
-
result.errors = result.errors || {};
|
|
152
|
-
result.errors.handwritingRecognition = handwritingResult.error;
|
|
153
|
-
} else if (handwritingResult.text && handwritingResult.text.trim().length > 0) {
|
|
154
|
-
result.containsHandwrittenText = true;
|
|
155
|
-
result.handwrittenText = handwritingResult.text;
|
|
156
|
-
}
|
|
157
|
-
} catch (error) {
|
|
158
|
-
result.errors = result.errors || {};
|
|
159
|
-
result.errors.handwritingRecognition = error instanceof Error ? error.message : 'Unknown error';
|
|
160
|
-
}
|
|
161
|
-
})());
|
|
162
|
-
}
|
|
163
|
-
|
|
164
142
|
// Wait for all analyses to complete
|
|
165
143
|
await Promise.all(promises);
|
|
166
144
|
|
|
@@ -179,8 +157,7 @@ async function analyzeImage(imageUri, options = {}) {
|
|
|
179
157
|
*/
|
|
180
158
|
async function isAvailable() {
|
|
181
159
|
try {
|
|
182
|
-
|
|
183
|
-
return !!(_NativeFaceDetectionModule.default && _NativeTextRecognitionModule.default && _NativeHandwritingRecognitionModule.default);
|
|
160
|
+
return !!(_NativeFaceDetectionModule.default && _NativeTextRecognitionModule.default);
|
|
184
161
|
} catch {
|
|
185
162
|
return false;
|
|
186
163
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_NativeFaceDetectionModule","_interopRequireDefault","_NativeTextRecognitionModule","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_NativeFaceDetectionModule","_interopRequireDefault","_NativeTextRecognitionModule","e","__esModule","default","DEFAULT_OPTIONS","detectFaces","detectPrintedText","faceDetectionMode","minFaceSize","validateImageUri","imageUri","Error","trimmedUri","trim","length","Platform","OS","startsWith","analyzeImage","options","validatedUri","opts","result","containsFace","containsPrintedText","promises","push","faceResult","FaceDetectionModule","error","errors","faceDetection","faces","message","textResult","TextRecognitionModule","recognizeText","textRecognition","text","printedText","Promise","all","enabledCount","errorCount","Object","keys","JSON","stringify","isAvailable","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,4BAAA,GAAAD,sBAAA,CAAAF,OAAA;AAAkE,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGlE;;AAQA;AACA;AACA;AACA,MAAMG,eAA0C,GAAG;EACjDC,WAAW,EAAE,IAAI;EACjBC,iBAAiB,EAAE,IAAI;EACvBC,iBAAiB,EAAE,MAAM;EACz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,oCAAqB,CAAC;EACzD,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAEA;AAAA,IAAAc,QAAA,GAAAC,OAAA,CAAA/C,OAAA,GACe;EACbe,YAAY;EACZ8B;AACF,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import FaceDetectionModule from './NativeFaceDetectionModule';
|
|
3
3
|
import TextRecognitionModule from './NativeTextRecognitionModule';
|
|
4
|
-
import HandwritingRecognitionModule from './NativeHandwritingRecognitionModule';
|
|
5
4
|
|
|
6
5
|
// Export types for consumers
|
|
7
6
|
|
|
@@ -11,7 +10,6 @@ import HandwritingRecognitionModule from './NativeHandwritingRecognitionModule';
|
|
|
11
10
|
const DEFAULT_OPTIONS = {
|
|
12
11
|
detectFaces: true,
|
|
13
12
|
detectPrintedText: true,
|
|
14
|
-
detectHandwrittenText: true,
|
|
15
13
|
faceDetectionMode: 'fast',
|
|
16
14
|
minFaceSize: 0.1
|
|
17
15
|
};
|
|
@@ -89,8 +87,7 @@ export async function analyzeImage(imageUri, options = {}) {
|
|
|
89
87
|
// Initialize result
|
|
90
88
|
const result = {
|
|
91
89
|
containsFace: false,
|
|
92
|
-
containsPrintedText: false
|
|
93
|
-
containsHandwrittenText: false
|
|
90
|
+
containsPrintedText: false
|
|
94
91
|
};
|
|
95
92
|
|
|
96
93
|
// Create promises array for parallel execution
|
|
@@ -134,25 +131,6 @@ export async function analyzeImage(imageUri, options = {}) {
|
|
|
134
131
|
})());
|
|
135
132
|
}
|
|
136
133
|
|
|
137
|
-
// Handwriting Recognition
|
|
138
|
-
if (opts.detectHandwrittenText) {
|
|
139
|
-
promises.push((async () => {
|
|
140
|
-
try {
|
|
141
|
-
const handwritingResult = await HandwritingRecognitionModule.recognizeHandwriting(validatedUri);
|
|
142
|
-
if (handwritingResult.error) {
|
|
143
|
-
result.errors = result.errors || {};
|
|
144
|
-
result.errors.handwritingRecognition = handwritingResult.error;
|
|
145
|
-
} else if (handwritingResult.text && handwritingResult.text.trim().length > 0) {
|
|
146
|
-
result.containsHandwrittenText = true;
|
|
147
|
-
result.handwrittenText = handwritingResult.text;
|
|
148
|
-
}
|
|
149
|
-
} catch (error) {
|
|
150
|
-
result.errors = result.errors || {};
|
|
151
|
-
result.errors.handwritingRecognition = error instanceof Error ? error.message : 'Unknown error';
|
|
152
|
-
}
|
|
153
|
-
})());
|
|
154
|
-
}
|
|
155
|
-
|
|
156
134
|
// Wait for all analyses to complete
|
|
157
135
|
await Promise.all(promises);
|
|
158
136
|
|
|
@@ -171,8 +149,7 @@ export async function analyzeImage(imageUri, options = {}) {
|
|
|
171
149
|
*/
|
|
172
150
|
export async function isAvailable() {
|
|
173
151
|
try {
|
|
174
|
-
|
|
175
|
-
return !!(FaceDetectionModule && TextRecognitionModule && HandwritingRecognitionModule);
|
|
152
|
+
return !!(FaceDetectionModule && TextRecognitionModule);
|
|
176
153
|
} catch {
|
|
177
154
|
return false;
|
|
178
155
|
}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","FaceDetectionModule","TextRecognitionModule","
|
|
1
|
+
{"version":3,"names":["Platform","FaceDetectionModule","TextRecognitionModule","DEFAULT_OPTIONS","detectFaces","detectPrintedText","faceDetectionMode","minFaceSize","validateImageUri","imageUri","Error","trimmedUri","trim","length","OS","startsWith","analyzeImage","options","validatedUri","opts","result","containsFace","containsPrintedText","promises","push","faceResult","error","errors","faceDetection","faces","message","textResult","recognizeText","textRecognition","text","printedText","Promise","all","enabledCount","errorCount","Object","keys","JSON","stringify","isAvailable"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,mBAAmB,MAAM,6BAA6B;AAC7D,OAAOC,qBAAqB,MAAM,+BAA+B;;AAGjE;;AAQA;AACA;AACA;AACA,MAAMC,eAA0C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AO,eAAewB,WAAWA,CAAA,EAAqB;EACpD,IAAI;IACF,OAAO,CAAC,EAAE3C,mBAAmB,IAAIC,qBAAqB,CAAC;EACzD,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAEA;AACA,eAAe;EACbc,YAAY;EACZ4B;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/D,YAAY,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,WAAW,GACZ,MAAM,SAAS,CAAC;AA0DjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAqFzB;AAED;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAMpD;;;;;AAGD,wBAGE"}
|
|
@@ -34,19 +34,14 @@ export interface AnalysisResult {
|
|
|
34
34
|
containsFace: boolean;
|
|
35
35
|
/** True if printed text was detected */
|
|
36
36
|
containsPrintedText: boolean;
|
|
37
|
-
/** True if handwritten text was detected */
|
|
38
|
-
containsHandwrittenText: boolean;
|
|
39
37
|
/** Array of detected faces with metadata */
|
|
40
38
|
faces?: FaceData[];
|
|
41
39
|
/** Extracted printed text content */
|
|
42
40
|
printedText?: string;
|
|
43
|
-
/** Extracted handwritten text content */
|
|
44
|
-
handwrittenText?: string;
|
|
45
41
|
/** Error messages if any module failed (won't throw, for graceful degradation) */
|
|
46
42
|
errors?: {
|
|
47
43
|
faceDetection?: string;
|
|
48
44
|
textRecognition?: string;
|
|
49
|
-
handwritingRecognition?: string;
|
|
50
45
|
};
|
|
51
46
|
}
|
|
52
47
|
/**
|
|
@@ -57,8 +52,6 @@ export interface AnalysisOptions {
|
|
|
57
52
|
detectFaces?: boolean;
|
|
58
53
|
/** Enable printed text recognition (default: true) */
|
|
59
54
|
detectPrintedText?: boolean;
|
|
60
|
-
/** Enable handwritten text recognition (default: true) */
|
|
61
|
-
detectHandwrittenText?: boolean;
|
|
62
55
|
/** Face detection performance mode: 'fast' or 'accurate' (default: 'fast') */
|
|
63
56
|
faceDetectionMode?: 'fast' | 'accurate';
|
|
64
57
|
/** Minimum face size relative to image (0.0 to 1.0, default: 0.1) */
|
|
@@ -84,8 +77,4 @@ export interface NativeTextRecognitionResult {
|
|
|
84
77
|
* Internal handwriting recognition result from native module
|
|
85
78
|
* @internal
|
|
86
79
|
*/
|
|
87
|
-
export interface NativeHandwritingRecognitionResult {
|
|
88
|
-
text: string;
|
|
89
|
-
error?: string;
|
|
90
|
-
}
|
|
91
80
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,wCAAwC;IACxC,WAAW,EAAE,WAAW,CAAC;IACzB,wDAAwD;IACxD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,0DAA0D;IAC1D,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,mDAAmD;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MA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,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACxC,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "mediversal-rn-image-intelligence"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "12.0" }
|
|
14
|
+
s.source = { :git => package["repository"], :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
|
+
|
|
18
|
+
s.dependency "React-Core"
|
|
19
|
+
|
|
20
|
+
s.dependency "GoogleMLKit/FaceDetection", "~> 4.0.0"
|
|
21
|
+
s.dependency "GoogleMLKit/TextRecognition", "~> 4.0.0"
|
|
22
|
+
|
|
23
|
+
s.swift_version = "5.0"
|
|
24
|
+
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediversal-rn-image-intelligence",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Production-ready React Native library for intelligent image analysis using Google ML Kit (on-device)",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -45,13 +45,16 @@
|
|
|
45
45
|
"computer-vision",
|
|
46
46
|
"turbomodule"
|
|
47
47
|
],
|
|
48
|
-
"repository":
|
|
49
|
-
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/thisissushant/mediversal-rn-image-intelligence.git"
|
|
51
|
+
},
|
|
52
|
+
"author": "Sushant Singh <sushantbibhu@gmail.com> (https://github.com/thisissushant)",
|
|
50
53
|
"license": "MIT",
|
|
51
54
|
"bugs": {
|
|
52
|
-
"url": "https://github.com/
|
|
55
|
+
"url": "https://github.com/thisissushant/mediversal-rn-image-intelligence/issues"
|
|
53
56
|
},
|
|
54
|
-
"homepage": "https://github.com/
|
|
57
|
+
"homepage": "https://github.com/thisissushant/mediversal-rn-image-intelligence#readme",
|
|
55
58
|
"publishConfig": {
|
|
56
59
|
"registry": "https://registry.npmjs.org/"
|
|
57
60
|
},
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import FaceDetectionModule from './NativeFaceDetectionModule';
|
|
3
3
|
import TextRecognitionModule from './NativeTextRecognitionModule';
|
|
4
|
-
import HandwritingRecognitionModule from './NativeHandwritingRecognitionModule';
|
|
5
4
|
import type { AnalysisResult, AnalysisOptions } from './types';
|
|
6
5
|
|
|
7
6
|
// Export types for consumers
|
|
@@ -18,7 +17,6 @@ export type {
|
|
|
18
17
|
const DEFAULT_OPTIONS: Required<AnalysisOptions> = {
|
|
19
18
|
detectFaces: true,
|
|
20
19
|
detectPrintedText: true,
|
|
21
|
-
detectHandwrittenText: true,
|
|
22
20
|
faceDetectionMode: 'fast',
|
|
23
21
|
minFaceSize: 0.1,
|
|
24
22
|
};
|
|
@@ -116,7 +114,6 @@ export async function analyzeImage(
|
|
|
116
114
|
const result: AnalysisResult = {
|
|
117
115
|
containsFace: false,
|
|
118
116
|
containsPrintedText: false,
|
|
119
|
-
containsHandwrittenText: false,
|
|
120
117
|
};
|
|
121
118
|
|
|
122
119
|
// Create promises array for parallel execution
|
|
@@ -174,35 +171,6 @@ export async function analyzeImage(
|
|
|
174
171
|
);
|
|
175
172
|
}
|
|
176
173
|
|
|
177
|
-
// Handwriting Recognition
|
|
178
|
-
if (opts.detectHandwrittenText) {
|
|
179
|
-
promises.push(
|
|
180
|
-
(async () => {
|
|
181
|
-
try {
|
|
182
|
-
const handwritingResult =
|
|
183
|
-
await HandwritingRecognitionModule.recognizeHandwriting(
|
|
184
|
-
validatedUri
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
if (handwritingResult.error) {
|
|
188
|
-
result.errors = result.errors || {};
|
|
189
|
-
result.errors.handwritingRecognition = handwritingResult.error;
|
|
190
|
-
} else if (
|
|
191
|
-
handwritingResult.text &&
|
|
192
|
-
handwritingResult.text.trim().length > 0
|
|
193
|
-
) {
|
|
194
|
-
result.containsHandwrittenText = true;
|
|
195
|
-
result.handwrittenText = handwritingResult.text;
|
|
196
|
-
}
|
|
197
|
-
} catch (error) {
|
|
198
|
-
result.errors = result.errors || {};
|
|
199
|
-
result.errors.handwritingRecognition =
|
|
200
|
-
error instanceof Error ? error.message : 'Unknown error';
|
|
201
|
-
}
|
|
202
|
-
})()
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
174
|
// Wait for all analyses to complete
|
|
207
175
|
await Promise.all(promises);
|
|
208
176
|
|
|
@@ -225,12 +193,7 @@ export async function analyzeImage(
|
|
|
225
193
|
*/
|
|
226
194
|
export async function isAvailable(): Promise<boolean> {
|
|
227
195
|
try {
|
|
228
|
-
|
|
229
|
-
return !!(
|
|
230
|
-
FaceDetectionModule &&
|
|
231
|
-
TextRecognitionModule &&
|
|
232
|
-
HandwritingRecognitionModule
|
|
233
|
-
);
|
|
196
|
+
return !!(FaceDetectionModule && TextRecognitionModule);
|
|
234
197
|
} catch {
|
|
235
198
|
return false;
|
|
236
199
|
}
|
package/src/types.ts
CHANGED
|
@@ -36,19 +36,14 @@ export interface AnalysisResult {
|
|
|
36
36
|
containsFace: boolean;
|
|
37
37
|
/** True if printed text was detected */
|
|
38
38
|
containsPrintedText: boolean;
|
|
39
|
-
/** True if handwritten text was detected */
|
|
40
|
-
containsHandwrittenText: boolean;
|
|
41
39
|
/** Array of detected faces with metadata */
|
|
42
40
|
faces?: FaceData[];
|
|
43
41
|
/** Extracted printed text content */
|
|
44
42
|
printedText?: string;
|
|
45
|
-
/** Extracted handwritten text content */
|
|
46
|
-
handwrittenText?: string;
|
|
47
43
|
/** Error messages if any module failed (won't throw, for graceful degradation) */
|
|
48
44
|
errors?: {
|
|
49
45
|
faceDetection?: string;
|
|
50
46
|
textRecognition?: string;
|
|
51
|
-
handwritingRecognition?: string;
|
|
52
47
|
};
|
|
53
48
|
}
|
|
54
49
|
|
|
@@ -60,8 +55,6 @@ export interface AnalysisOptions {
|
|
|
60
55
|
detectFaces?: boolean;
|
|
61
56
|
/** Enable printed text recognition (default: true) */
|
|
62
57
|
detectPrintedText?: boolean;
|
|
63
|
-
/** Enable handwritten text recognition (default: true) */
|
|
64
|
-
detectHandwrittenText?: boolean;
|
|
65
58
|
/** Face detection performance mode: 'fast' or 'accurate' (default: 'fast') */
|
|
66
59
|
faceDetectionMode?: 'fast' | 'accurate';
|
|
67
60
|
/** Minimum face size relative to image (0.0 to 1.0, default: 0.1) */
|
|
@@ -90,7 +83,3 @@ export interface NativeTextRecognitionResult {
|
|
|
90
83
|
* Internal handwriting recognition result from native module
|
|
91
84
|
* @internal
|
|
92
85
|
*/
|
|
93
|
-
export interface NativeHandwritingRecognitionResult {
|
|
94
|
-
text: string;
|
|
95
|
-
error?: string;
|
|
96
|
-
}
|
package/android/src/main/java/com/mediversalrnimagintelligence/HandwritingRecognitionModule.kt
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
package com.mediversalrnimagintelligence
|
|
2
|
-
|
|
3
|
-
import android.graphics.Bitmap
|
|
4
|
-
import android.graphics.BitmapFactory
|
|
5
|
-
import android.net.Uri
|
|
6
|
-
import com.facebook.react.bridge.Arguments
|
|
7
|
-
import com.facebook.react.bridge.Promise
|
|
8
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
|
-
import com.facebook.react.bridge.ReactMethod
|
|
11
|
-
import com.facebook.react.bridge.WritableMap
|
|
12
|
-
import com.google.mlkit.vision.digitalink.DigitalInkRecognition
|
|
13
|
-
import com.google.mlkit.vision.digitalink.DigitalInkRecognitionModel
|
|
14
|
-
import com.google.mlkit.vision.digitalink.DigitalInkRecognitionModelIdentifier
|
|
15
|
-
import com.google.mlkit.vision.digitalink.DigitalInkRecognizer
|
|
16
|
-
import com.google.mlkit.vision.digitalink.DigitalInkRecognizerOptions
|
|
17
|
-
import com.google.mlkit.vision.digitalink.Ink
|
|
18
|
-
import java.io.IOException
|
|
19
|
-
import java.io.InputStream
|
|
20
|
-
|
|
21
|
-
class HandwritingRecognitionModule(reactContext: ReactApplicationContext) :
|
|
22
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
23
|
-
|
|
24
|
-
override fun getName(): String {
|
|
25
|
-
return "HandwritingRecognitionModule"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@ReactMethod
|
|
29
|
-
fun recognizeHandwriting(imageUri: String, promise: Promise) {
|
|
30
|
-
try {
|
|
31
|
-
// Note: Digital Ink Recognition in ML Kit is designed for real-time stroke data,
|
|
32
|
-
// not static images. For production use with static images, you would need to:
|
|
33
|
-
// 1. Use a different API (like Cloud Vision API's handwriting detection)
|
|
34
|
-
// 2. Or pre-process the image to extract strokes
|
|
35
|
-
//
|
|
36
|
-
// For this implementation, we'll provide a graceful fallback indicating
|
|
37
|
-
// that handwriting recognition from static images is not fully supported
|
|
38
|
-
// by the on-device Digital Ink API.
|
|
39
|
-
|
|
40
|
-
val result = Arguments.createMap()
|
|
41
|
-
result.putString("text", "")
|
|
42
|
-
result.putString(
|
|
43
|
-
"error",
|
|
44
|
-
"Digital Ink Recognition requires stroke data, not static images. " +
|
|
45
|
-
"For handwriting in static images, consider using Cloud Vision API or " +
|
|
46
|
-
"preprocessing to extract stroke information."
|
|
47
|
-
)
|
|
48
|
-
promise.resolve(result)
|
|
49
|
-
|
|
50
|
-
// Alternative implementation note:
|
|
51
|
-
// If you have stroke data (from a drawing canvas), the proper implementation would be:
|
|
52
|
-
// 1. Create an Ink object from strokes
|
|
53
|
-
// 2. Get recognizer with appropriate model
|
|
54
|
-
// 3. Call recognizer.recognize(ink)
|
|
55
|
-
//
|
|
56
|
-
// Example (commented out as it requires stroke data):
|
|
57
|
-
// val modelIdentifier = DigitalInkRecognitionModelIdentifier.fromLanguageTag("en-US")
|
|
58
|
-
// val model = DigitalInkRecognitionModel.builder(modelIdentifier!!).build()
|
|
59
|
-
// val recognizer = DigitalInkRecognition.getClient(
|
|
60
|
-
// DigitalInkRecognizerOptions.builder(model).build()
|
|
61
|
-
// )
|
|
62
|
-
// recognizer.recognize(ink)
|
|
63
|
-
// .addOnSuccessListener { result ->
|
|
64
|
-
// // Process candidates
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
|
-
} catch (e: Exception) {
|
|
68
|
-
val result = Arguments.createMap()
|
|
69
|
-
result.putString("text", "")
|
|
70
|
-
result.putString("error", e.message ?: "Handwriting recognition failed")
|
|
71
|
-
promise.resolve(result)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
|
|
3
|
-
@interface RCT_EXTERN_MODULE(HandwritingRecognitionModule, NSObject)
|
|
4
|
-
|
|
5
|
-
RCT_EXTERN_METHOD(recognizeHandwriting:(NSString *)imageUri
|
|
6
|
-
resolver:(RCTPromiseResolveBlock)resolve
|
|
7
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
8
|
-
|
|
9
|
-
+ (BOOL)requiresMainQueueSetup
|
|
10
|
-
{
|
|
11
|
-
return NO;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import MLKitDigitalInkRecognition
|
|
3
|
-
import MLKitVision
|
|
4
|
-
|
|
5
|
-
@objc(HandwritingRecognitionModule)
|
|
6
|
-
class HandwritingRecognitionModule: NSObject {
|
|
7
|
-
|
|
8
|
-
@objc
|
|
9
|
-
func recognizeHandwriting(
|
|
10
|
-
_ imageUri: String,
|
|
11
|
-
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
12
|
-
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
13
|
-
) {
|
|
14
|
-
DispatchQueue.main.async {
|
|
15
|
-
// Note: Digital Ink Recognition in ML Kit is designed for real-time stroke data,
|
|
16
|
-
// not static images. For production use with static images, you would need to:
|
|
17
|
-
// 1. Use a different API (like Cloud Vision API's handwriting detection)
|
|
18
|
-
// 2. Or pre-process the image to extract strokes
|
|
19
|
-
//
|
|
20
|
-
// For this implementation, we'll provide a graceful fallback indicating
|
|
21
|
-
// that handwriting recognition from static images is not fully supported
|
|
22
|
-
// by the on-device Digital Ink API.
|
|
23
|
-
|
|
24
|
-
let result: [String: Any] = [
|
|
25
|
-
"text": "",
|
|
26
|
-
"error": "Digital Ink Recognition requires stroke data, not static images. " +
|
|
27
|
-
"For handwriting in static images, consider using Cloud Vision API or " +
|
|
28
|
-
"preprocessing to extract stroke information."
|
|
29
|
-
]
|
|
30
|
-
resolve(result)
|
|
31
|
-
|
|
32
|
-
// Alternative implementation note:
|
|
33
|
-
// If you have stroke data (from a drawing canvas), the proper implementation would be:
|
|
34
|
-
// 1. Create an Ink object from strokes
|
|
35
|
-
// 2. Get recognizer with appropriate model identifier
|
|
36
|
-
// 3. Call recognizer.recognize(ink)
|
|
37
|
-
//
|
|
38
|
-
// Example (commented out as it requires stroke data):
|
|
39
|
-
// let identifier = DigitalInkRecognitionModelIdentifier(forLanguageTag: "en-US")
|
|
40
|
-
// let model = DigitalInkRecognitionModel.modelIdentifier(identifier!)
|
|
41
|
-
// let options = DigitalInkRecognizerOptions(model: model)
|
|
42
|
-
// let recognizer = DigitalInkRecognizer.digitalInkRecognizer(options: options)
|
|
43
|
-
// recognizer.recognize(ink: ink) { result, error in
|
|
44
|
-
// // Process recognition candidates
|
|
45
|
-
// }
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@objc
|
|
50
|
-
static func requiresMainQueueSetup() -> Bool {
|
|
51
|
-
return false
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
/**
|
|
9
|
-
* Handwriting Recognition TurboModule Specification
|
|
10
|
-
*/
|
|
11
|
-
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('HandwritingRecognitionModule');
|
|
12
|
-
//# sourceMappingURL=NativeHandwritingRecognitionModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeHandwritingRecognitionModule.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GASeC,gCAAmB,CAACC,YAAY,CAC7C,8BACF,CAAC","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TurboModuleRegistry } from 'react-native';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Handwriting Recognition TurboModule Specification
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export default TurboModuleRegistry.getEnforcing('HandwritingRecognitionModule');
|
|
8
|
-
//# sourceMappingURL=NativeHandwritingRecognitionModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeHandwritingRecognitionModule.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;AAOA,eAAeA,mBAAmB,CAACC,YAAY,CAC7C,8BACF,CAAC","ignoreList":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native';
|
|
2
|
-
import type { NativeHandwritingRecognitionResult } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Handwriting Recognition TurboModule Specification
|
|
5
|
-
*/
|
|
6
|
-
export interface Spec extends TurboModule {
|
|
7
|
-
recognizeHandwriting(imageUri: string): Promise<NativeHandwritingRecognitionResult>;
|
|
8
|
-
}
|
|
9
|
-
declare const _default: Spec;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=NativeHandwritingRecognitionModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeHandwritingRecognitionModule.d.ts","sourceRoot":"","sources":["../../src/NativeHandwritingRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,oBAAoB,CAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,kCAAkC,CAAC,CAAC;CAChD;;AAED,wBAEU"}
|