Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 61ec764

Browse files
Merge pull request #1047 from apopiidoru/ml_kit_ocr
Added confidence property to blocks and lines
2 parents ec660ee + 57bad83 commit 61ec764

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/mlkit/textrecognition/index.android.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ function getResult(firebaseVisionText: any): MLKitRecognizeTextResult {
8383

8484
lns.push({
8585
text: line.getText(),
86+
confidence: line.getConfidence(),
8687
bounds: boundingBoxToBounds(line.getBoundingBox()),
8788
elements: elms
8889
});
8990
}
9091

9192
result.blocks.push({
9293
text: textBlock.getText(),
94+
confidence: textBlock.getConfidence(),
9395
bounds: boundingBoxToBounds(textBlock.getBoundingBox()),
9496
lines: lns
9597
});

src/mlkit/textrecognition/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ export interface MLKitRecognizeTextResultElement {
1818

1919
export interface MLKitRecognizeTextResultLine {
2020
text: string;
21+
confidence: number;
2122
bounds: MLKitRecognizeTextResultBounds;
2223
elements: Array<MLKitRecognizeTextResultElement>;
2324
}
2425

2526
export interface MLKitRecognizeTextResultBlock {
2627
text: string;
28+
confidence: number;
2729
bounds: MLKitRecognizeTextResultBounds;
2830
lines: Array<MLKitRecognizeTextResultLine>;
2931
}

src/mlkit/textrecognition/index.ios.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ function getResult(visionText: FIRVisionText): MLKitRecognizeTextResult {
4444
const feature: FIRVisionTextBlock = visionText.blocks.objectAtIndex(i);
4545
const resultFeature = <MLKitRecognizeTextResultBlock>{
4646
text: feature.text,
47+
confidence: feature.confidence,
4748
bounds: feature.frame,
4849
lines: []
4950
};
5051

5152
const addLineToResult = (line: FIRVisionTextLine): void => {
5253
const resultLine = <MLKitRecognizeTextResultLine>{
5354
text: feature.text,
55+
confidence: line.confidence,
5456
bounds: line.frame,
5557
elements: []
5658
};

0 commit comments

Comments
 (0)