This commit is contained in:
Hamza-Ayed
2024-07-19 00:47:02 +03:00
parent 53f3114ed1
commit 1fe98b698b
8 changed files with 144 additions and 86 deletions

View File

@@ -55,8 +55,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 23
targetSdkVersion 34
versionCode 59
versionName '1.5.59'
versionCode 60
versionName '1.5.60'
// manifestPlaceholders = [mapsApiKey: 'android/app/src/main/AndroidManifest.xml']
}

View File

@@ -83,6 +83,10 @@ PODS:
- google_mlkit_commons (0.7.1):
- Flutter
- MLKitVision
- google_mlkit_face_detection (0.11.0):
- Flutter
- google_mlkit_commons
- GoogleMLKit/FaceDetection (~> 6.0.0)
- google_mlkit_text_recognition (0.13.0):
- Flutter
- google_mlkit_commons
@@ -102,6 +106,9 @@ PODS:
- GoogleMaps/Base (7.4.0)
- GoogleMaps/Maps (7.4.0):
- GoogleMaps/Base
- GoogleMLKit/FaceDetection (6.0.0):
- GoogleMLKit/MLKitCore
- MLKitFaceDetection (~> 5.0.0)
- GoogleMLKit/MLKitCore (6.0.0):
- MLKitCommon (~> 11.0.0)
- GoogleMLKit/TextRecognition (6.0.0):
@@ -185,6 +192,9 @@ PODS:
- GoogleUtilities/UserDefaults (< 8.0, >= 7.13.0)
- GoogleUtilitiesComponents (~> 1.0)
- GTMSessionFetcher/Core (< 4.0, >= 3.3.2)
- MLKitFaceDetection (5.0.0):
- MLKitCommon (~> 11.0)
- MLKitVision (~> 7.0)
- MLKitTextRecognition (4.0.0):
- MLKitCommon (~> 11.0)
- MLKitTextRecognitionCommon (= 3.0.0)
@@ -293,6 +303,7 @@ DEPENDENCIES:
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
- google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`)
- google_mlkit_commons (from `.symlinks/plugins/google_mlkit_commons/ios`)
- google_mlkit_face_detection (from `.symlinks/plugins/google_mlkit_face_detection/ios`)
- google_mlkit_text_recognition (from `.symlinks/plugins/google_mlkit_text_recognition/ios`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
@@ -338,6 +349,7 @@ SPEC REPOS:
- Mantle
- MLImage
- MLKitCommon
- MLKitFaceDetection
- MLKitTextRecognition
- MLKitTextRecognitionCommon
- MLKitVision
@@ -387,6 +399,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/google_maps_flutter_ios/ios"
google_mlkit_commons:
:path: ".symlinks/plugins/google_mlkit_commons/ios"
google_mlkit_face_detection:
:path: ".symlinks/plugins/google_mlkit_face_detection/ios"
google_mlkit_text_recognition:
:path: ".symlinks/plugins/google_mlkit_text_recognition/ios"
google_sign_in_ios:
@@ -453,6 +467,7 @@ SPEC CHECKSUMS:
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
google_maps_flutter_ios: 590249c67f34f422122c232f2a626192adbc78ee
google_mlkit_commons: 96aaca445520311b84a2da013dedf3427fe4cc69
google_mlkit_face_detection: b760d6035222630f347352b3b13f4a23ea9fb994
google_mlkit_text_recognition: 393c2526da49aa6c9c883e6d69100f54af011e24
google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
@@ -473,6 +488,7 @@ SPEC CHECKSUMS:
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
MLImage: 1824212150da33ef225fbd3dc49f184cf611046c
MLKitCommon: afec63980417d29ffbb4790529a1b0a2291699e1
MLKitFaceDetection: 7c0e8bf09ddd27105da32d088fca978a99fc30cc
MLKitTextRecognition: c83c18ad25496f2077f6ec93c5940487ff2eb343
MLKitTextRecognitionCommon: c0b3a63d529296a19bce1f8bc8a513644ed4d1f6
MLKitVision: e858c5f125ecc288e4a31127928301eaba9ae0c1

View File

@@ -467,6 +467,10 @@ class AI extends GetxController {
try {
await ImageController().choosImage(linkPHP, imagePath);
// if (imagePath == 'driver_license') {
// await ImageController().choosFaceFromDriverLicense(linkPHP, 'face');
// }
await Future.delayed(const Duration(seconds: 2));
var extractedString =

View File

@@ -1,13 +1,11 @@
import 'dart:convert';
import 'dart:io';
import 'package:SEFER/constant/api_key.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:image_cropper/image_cropper.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path/path.dart';
import 'package:image/image.dart' as image_package;
import 'package:image/image.dart' as img;
import 'package:flutter_image_compress/flutter_image_compress.dart';
@@ -164,62 +162,47 @@ class ImageController extends GetxController {
}
}
choosImage1(String link, String imageType) async {
final pickedImage = await picker.pickImage(
source: ImageSource.camera,
preferredCameraDevice: CameraDevice.rear,
// maxHeight: Get.height * .3,
// maxWidth: Get.width * .9,
// imageQuality: 100,
);
image = File(pickedImage!.path);
// choosFaceFromDriverLicense(String link, String imageType) async {
// final pickedImage = await picker.pickImage(
// source: ImageSource.camera,
// preferredCameraDevice: CameraDevice.rear,
// );
croppedFile = await ImageCropper().cropImage(
sourcePath: image!.path,
aspectRatioPresets: [
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.original,
CropAspectRatioPreset.ratio4x3,
CropAspectRatioPreset.ratio16x9
],
uiSettings: [
AndroidUiSettings(
toolbarTitle: 'Cropper'.tr,
toolbarColor: AppColor.blueColor,
toolbarWidgetColor: AppColor.yellowColor,
initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: false),
IOSUiSettings(
title: 'Cropper'.tr,
),
],
);
myImage = File(pickedImage.path);
isloading = true;
update();
// Save the cropped image
// File savedCroppedImage = File(croppedFile!.path);
File compressedImage = await compressImage(File(croppedFile!.path));
print('link =$link');
try {
await uploadImage(
compressedImage,
{
'driverID':
box.read(BoxName.driverID) ?? box.read(BoxName.passengerID),
'imageType': imageType
},
link,
);
} catch (e) {
Get.snackbar('Image Upload Failed'.tr, e.toString(),
backgroundColor: AppColor.redColor);
} finally {
isloading = false;
update();
}
}
// if (pickedImage == null) return;
// image = File(pickedImage.path);
// File? processedImage;
// // For face images, use face detection and cropping
// processedImage = await detectAndCropFace(image!);
// if (processedImage == null) {
// Get.snackbar('Face Detection Failed', 'No face detected in the image.');
// return;
// }
// isloading = true;
// update();
// File compressedImage = await compressImage(processedImage);
// try {
// await uploadImage(
// compressedImage,
// {
// 'driverID': box.read(BoxName.driverID).toString(),
// 'imageType': imageType
// },
// link,
// );
// } catch (e) {
// Get.snackbar('Image Upload Failed'.tr, e.toString(),
// backgroundColor: AppColor.redColor);
// } finally {
// isloading = false;
// update();
// }
// }
choosFace(String link, String imageType) async {
final pickedImage = await picker.pickImage(
@@ -408,3 +391,63 @@ Future<File> compressImage(File file) async {
return File(result!.path);
}
// Future<File> detectAndCropFace(File imageFile) async {
// final inputImage = InputImage.fromFilePath(imageFile.path);
// final options = FaceDetectorOptions(
// enableClassification: false,
// enableLandmarks: false,
// enableTracking: false,
// minFaceSize: 0.15,
// performanceMode: FaceDetectorMode.accurate,
// );
// final faceDetector = FaceDetector(options: options);
// try {
// final List<Face> faces = await faceDetector.processImage(inputImage);
// final image = img.decodeImage(await imageFile.readAsBytes());
// if (image == null) throw Exception('Unable to decode image');
// int left, top, width, height;
// if (faces.isNotEmpty) {
// // Face detected, crop around the face
// final face = faces[0];
// double padding = 0.2; // 20% padding
// int paddingX = (face.boundingBox.width * padding).round();
// int paddingY = (face.boundingBox.height * padding).round();
// left = (face.boundingBox.left - paddingX).round();
// top = (face.boundingBox.top - paddingY).round();
// width = (face.boundingBox.width + 2 * paddingX).round();
// height = (face.boundingBox.height + 2 * paddingY).round();
// } else {
// // No face detected, crop the center of the image
// int size = min(image.width, image.height);
// left = (image.width - size) ~/ 2;
// top = (image.height - size) ~/ 2;
// width = size;
// height = size;
// }
// // Ensure dimensions are within image bounds
// left = left.clamp(0, image.width - 1);
// top = top.clamp(0, image.height - 1);
// width = width.clamp(1, image.width - left);
// height = height.clamp(1, image.height - top);
// final croppedImage =
// img.copyCrop(image, x: left, y: top, width: width, height: height);
// // Save the cropped image
// final tempDir = await path_provider.getTemporaryDirectory();
// final tempPath = tempDir.path;
// final croppedFile = File('$tempPath/cropped_image.jpg');
// await croppedFile.writeAsBytes(img.encodeJpg(croppedImage, quality: 100));
// return croppedFile;
// } finally {
// faceDetector.close();
// }
// }

View File

@@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/firebase/firbase_messge.dart';
import 'package:SEFER/controller/home/captin/home_captain_controller.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -136,7 +135,7 @@ class CaptainWalletController extends GetxController {
// update();
walletDriverPointsDate = jsonDecode(res);
if (walletDriverPointsDate['message'][0]['driverID'].toString() ==
box.read(BoxName.driverID)) {
box.read(BoxName.driverID).toString()) {
double totalPointsDouble = double.parse(
walletDriverPointsDate['message'][0]['total_amount'].toString());
totalPoints = totalPointsDouble.toStringAsFixed(0);

View File

@@ -10,6 +10,7 @@ import '../../../../constant/colors.dart';
import '../../../../constant/links.dart';
import '../../../../constant/style.dart';
import '../../../../controller/functions/package_info.dart';
import '../../../../controller/functions/upload_image.dart';
import '../../../widgets/my_scafold.dart';
class EgyptCardAI extends StatelessWidget {
@@ -97,6 +98,7 @@ class EgyptCardAI extends StatelessWidget {
]),
child: VideoButton()),
),
egyptDriverLicense(),
egyptCarLicenceFront(),
egyptCarLicenceBack(),

View File

@@ -1,12 +1,5 @@
import 'dart:convert';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/functions/face_detect.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/auth/captin/cards/egypt_card_a_i.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/mydialoug.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:get/get.dart';
@@ -179,24 +172,24 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
),
),
),
AnimatedContainer(
duration: const Duration(microseconds: 200),
width: controller.widthMapTypeAndTraffic,
decoration: BoxDecoration(
color: AppColor.secondaryColor,
border: Border.all(color: AppColor.blueColor),
borderRadius: BorderRadius.circular(15)),
child: IconButton(
onPressed: () async {
Get.to(() => EgyptCardAI());
},
icon: const Icon(
FontAwesome5.grin_tears,
size: 29,
color: AppColor.blueColor,
),
),
),
// AnimatedContainer(
// duration: const Duration(microseconds: 200),
// width: controller.widthMapTypeAndTraffic,
// decoration: BoxDecoration(
// color: AppColor.secondaryColor,
// border: Border.all(color: AppColor.blueColor),
// borderRadius: BorderRadius.circular(15)),
// child: IconButton(
// onPressed: () async {
// Get.to(() => EgyptCardAI());
// },
// icon: const Icon(
// FontAwesome5.grin_tears,
// size: 29,
// color: AppColor.blueColor,
// ),
// ),
// ),
],
)),
);

View File

@@ -68,6 +68,7 @@ dependencies:
firebase_auth: ^4.19.6
package_info_plus: ^8.0.0
flutter_image_compress: ^2.3.0
# google_mlkit_face_detection: ^0.11.0
dev_dependencies:
flutter_test: