Skip to content

Commit

Permalink
Merge branch 'master' into update_commons
Browse files Browse the repository at this point in the history
  • Loading branch information
fbernaly committed Jun 29, 2023
2 parents 9f04047 + c72e94d commit df79ff9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ class DetectedObject {

/// Returns an instance of [DetectedObject] from a given [json].
factory DetectedObject.fromJson(Map<dynamic, dynamic> json) {
final rect = RectJson.fromJson(json['rect']);
final boundingBox = RectJson.fromJson(json['rect']);
final trackingId = json['trackingId'];
final labels = <Label>[];
for (final dynamic label in json['labels']) {
labels.add(Label.fromJson(label));
}
return DetectedObject(
boundingBox: rect,
boundingBox: boundingBox,
labels: labels,
trackingId: trackingId,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ class SegmentationMask {

/// Returns an instance of [SegmentationMask] from a given [json].
factory SegmentationMask.fromJson(Map<dynamic, dynamic> json) {
final values = json['confidences'];
final List<double> confidences = [];
for (final item in values) {
confidences.add(double.parse(item.toString()));
}
return SegmentationMask(
width: json['width'] as int,
height: json['height'] as int,
confidences: json['confidences'] as List<double>,
confidences: confidences,
);
}
}
32 changes: 16 additions & 16 deletions packages/google_mlkit_text_recognition/lib/src/text_recognizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ class TextBlock {
/// Returns an instance of [TextBlock] from a given [json].
factory TextBlock.fromJson(Map<dynamic, dynamic> json) {
final text = json['text'];
final rect = RectJson.fromJson(json['rect']);
final boundingBox = RectJson.fromJson(json['rect']);
final recognizedLanguages =
_listToRecognizedLanguages(json['recognizedLanguages']);
final points = _listToCornerPoints(json['points']);
final cornerPoints = _listToCornerPoints(json['points']);
final lines = <TextLine>[];
for (final line in json['lines']) {
final textLine = TextLine.fromJson(line);
Expand All @@ -107,9 +107,9 @@ class TextBlock {
return TextBlock(
text: text,
lines: lines,
boundingBox: rect,
boundingBox: boundingBox,
recognizedLanguages: recognizedLanguages,
cornerPoints: points,
cornerPoints: cornerPoints,
);
}
}
Expand Down Expand Up @@ -153,12 +153,12 @@ class TextLine {
/// Returns an instance of [TextLine] from a given [json].
factory TextLine.fromJson(Map<dynamic, dynamic> json) {
final text = json['text'];
final rect = RectJson.fromJson(json['rect']);
final boundingBox = RectJson.fromJson(json['rect']);
final confidence = json['confidence'];
final angle = json['angle'];
final recognizedLanguages =
_listToRecognizedLanguages(json['recognizedLanguages']);
final points = _listToCornerPoints(json['points']);
final cornerPoints = _listToCornerPoints(json['points']);
final elements = <TextElement>[];
for (final element in json['elements']) {
final textElement = TextElement.fromJson(element);
Expand All @@ -167,9 +167,9 @@ class TextLine {
return TextLine(
text: text,
elements: elements,
boundingBox: rect,
boundingBox: boundingBox,
recognizedLanguages: recognizedLanguages,
cornerPoints: points,
cornerPoints: cornerPoints,
confidence: confidence,
angle: angle,
);
Expand Down Expand Up @@ -216,10 +216,10 @@ class TextElement {
/// Returns an instance of [TextElement] from a given [json].
factory TextElement.fromJson(Map<dynamic, dynamic> json) {
final text = json['text'];
final rect = RectJson.fromJson(json['rect']);
final boundingBox = RectJson.fromJson(json['rect']);
final recognizedLanguages =
_listToRecognizedLanguages(json['recognizedLanguages']);
final points = _listToCornerPoints(json['points']);
final cornerPoints = _listToCornerPoints(json['points']);
final confidence = json['confidence'];
final angle = json['angle'];
final symbols = <TextSymbol>[];
Expand All @@ -230,9 +230,9 @@ class TextElement {
return TextElement(
text: text,
symbols: symbols,
boundingBox: rect,
boundingBox: boundingBox,
recognizedLanguages: recognizedLanguages,
cornerPoints: points,
cornerPoints: cornerPoints,
confidence: confidence,
angle: angle,
);
Expand Down Expand Up @@ -274,17 +274,17 @@ class TextSymbol {
/// Returns an instance of [TextSymbol] from a given [json].
factory TextSymbol.fromJson(Map<dynamic, dynamic> json) {
final text = json['text'];
final rect = RectJson.fromJson(json['rect']);
final boundingBox = RectJson.fromJson(json['rect']);
final recognizedLanguages =
_listToRecognizedLanguages(json['recognizedLanguages']);
final points = _listToCornerPoints(json['points']);
final cornerPoints = _listToCornerPoints(json['points']);
final confidence = json['confidence'];
final angle = json['angle'];
return TextSymbol(
text: text,
boundingBox: rect,
boundingBox: boundingBox,
recognizedLanguages: recognizedLanguages,
cornerPoints: points,
cornerPoints: cornerPoints,
confidence: confidence,
angle: angle,
);
Expand Down

0 comments on commit df79ff9

Please sign in to comment.