7/17/2
This commit is contained in:
48
lib/controller/functions/face_detect.dart
Normal file
48
lib/controller/functions/face_detect.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'dart:convert';
|
||||
import 'package:SEFER/constant/api_key.dart';
|
||||
import 'package:SEFER/constant/box_name.dart';
|
||||
import 'package:SEFER/main.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../constant/links.dart';
|
||||
import 'upload_image.dart';
|
||||
|
||||
Future<String> faceDetector() async {
|
||||
await ImageController().choosFace(AppLink.uploadEgypt, 'face_detect');
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
var headers = {
|
||||
'Authorization': 'Basic ${AK.basicCompareFaces}',
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
|
||||
var request = http.Request(
|
||||
'POST',
|
||||
Uri.parse(
|
||||
'https://face-detect-f6924392c4c7.herokuapp.com/compare_faces'));
|
||||
|
||||
request.body = json.encode({
|
||||
"url1":
|
||||
"https://api.sefer.live/sefer/card_image/id_front-${box.read(BoxName.driverID)}.jpg",
|
||||
"url2":
|
||||
"https://api.sefer.live/sefer/card_image/face_detect-${box.read(BoxName.driverID)}.jpg"
|
||||
});
|
||||
print('request.body: ${request.body}');
|
||||
request.headers.addAll(headers);
|
||||
|
||||
try {
|
||||
http.StreamedResponse response = await request.send();
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
String result = await response.stream.bytesToString();
|
||||
print('result: ${result}');
|
||||
return result;
|
||||
} else {
|
||||
print('Error: ${response.reasonPhrase}');
|
||||
return 'Error: ${response.reasonPhrase}';
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception occurred: $e');
|
||||
return 'Error: $e';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user