passnger/5/3/4
This commit is contained in:
@@ -106,7 +106,36 @@ class CRUD {
|
||||
Future.delayed(const Duration(seconds: 2));
|
||||
String extracted =
|
||||
await arabicTextExtractByVisionAndAI(imagePath: imagePath);
|
||||
await AI().geminiAiExtraction(prompt, extracted);
|
||||
|
||||
Map<String, dynamic> extractedData = extractText(extracted);
|
||||
print(extractedData);
|
||||
// await AI().geminiAiExtraction(prompt, extractedData);
|
||||
}
|
||||
|
||||
Map<String, dynamic> extractText(String jsonData) {
|
||||
Map<String, dynamic> data = jsonDecode(jsonData);
|
||||
List<List<String>> textLines = [];
|
||||
|
||||
for (var region in data['regions']) {
|
||||
List<String> lineTexts = [];
|
||||
for (var line in region['lines']) {
|
||||
String lineText = "";
|
||||
for (var word in line['words']) {
|
||||
lineText += word['text'] + " ";
|
||||
}
|
||||
lineText = lineText.trim();
|
||||
lineTexts.add(lineText);
|
||||
}
|
||||
textLines.add(lineTexts);
|
||||
}
|
||||
|
||||
// You can choose between returning a new JSON or a List based on your needs
|
||||
|
||||
// Option 1: Return a new JSON with "textLines" key
|
||||
return {"textLines": textLines};
|
||||
|
||||
// Option 2: Return a List of List<String> (lines with words)
|
||||
// return textLines;
|
||||
}
|
||||
|
||||
Future<dynamic> arabicTextExtractByVisionAndAI({
|
||||
@@ -122,7 +151,7 @@ class CRUD {
|
||||
String imagePathFull =
|
||||
'${AppLink.server}card_image/$imagePath-${box.read(BoxName.driverID) ?? box.read(BoxName.passengerID)}.jpg';
|
||||
|
||||
print('imagePath=$imagePathFull');
|
||||
// print('imagePath=$imagePathFull');
|
||||
var requestBody = {"url": imagePathFull};
|
||||
var response = await http.post(
|
||||
url,
|
||||
@@ -132,7 +161,7 @@ class CRUD {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
var responseBody = jsonDecode(response.body);
|
||||
// print(decode);
|
||||
print(responseBody);
|
||||
print('imagePath=$imagePathFull');
|
||||
return responseBody.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user