detectFaces static method
Implementation
static Future<List<Map<String, dynamic>>> detectFaces(
Uint8List imageBytes,
) async {
try {
final imgBase64 = base64Encode(imageBytes);
final response = await http
.post(
Uri.parse('$_baseUrl/detect_faces'),
headers: {"Content-Type": "application/json"},
body: jsonEncode({"image": imgBase64}),
)
.timeout(const Duration(seconds: 2));
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
final List faces = data['faces'] ?? [];
return List<Map<String, dynamic>>.from(faces);
} else {
throw Exception('Face detection failed: ${response.statusCode}');
}
} catch (_) {
return [];
}
}