react-native-text-reader 1.2.0 → 1.4.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.
@@ -118,30 +118,26 @@ class TextReaderModule(reactContext: ReactApplicationContext) :
118
118
  else -> TextRecognizerOptions.DEFAULT_OPTIONS
119
119
  }
120
120
  }
121
-
121
+
122
122
  @ReactMethod
123
123
  fun read(url: String, options: ReadableMap?, promise: Promise) {
124
124
  try {
125
125
  val script = options?.getString("script")
126
126
 
127
127
  val image = getInputImage(reactApplicationContext, url)
128
-
129
128
  val options = getScriptTextRecognizerOptions(script)
130
129
 
131
130
  val recognizer: TextRecognizer = TextRecognition.getClient(options)
132
131
 
133
132
  recognizer.process(image)
134
133
  .addOnSuccessListener { visionText ->
135
- val result = Arguments.createMap()
136
- result.putString("text", visionText.text)
137
-
138
- val blocksArray = Arguments.createArray()
134
+ val linesArray = Arguments.createArray()
139
135
  visionText.textBlocks.forEach { block ->
140
- blocksArray.pushMap(blockToMap(block))
136
+ block.lines.forEach { line ->
137
+ linesArray.pushString(line.text)
138
+ }
141
139
  }
142
- result.putArray("blocks", blocksArray)
143
-
144
- promise.resolve(result)
140
+ promise.resolve(linesArray)
145
141
  }
146
142
  .addOnFailureListener { e ->
147
143
  e.printStackTrace()
@@ -36,6 +36,7 @@ class TextReader: NSObject {
36
36
  if #available(iOS 16.0, *) {
37
37
  ocrRequest.automaticallyDetectsLanguage = true
38
38
  }
39
+ ocrRequest.recognitionLevel = .accurate
39
40
 
40
41
  try requestHandler.perform([ocrRequest])
41
42
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-text-reader",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "A React Native library for OCR (Optical Character Recognition) using Vision Framework on iOS and Firebase ML Kit on Android.",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",