Merge branch 'mobile_face' of https://github.com/ente-io/auth into mobile_face
This commit is contained in:
commit
e9be2b46a1
4 changed files with 27 additions and 12 deletions
|
@ -306,7 +306,7 @@ class _FaceWidgetState extends State<FaceWidget> {
|
|||
return {widget.face.faceID: data};
|
||||
}
|
||||
|
||||
final result = await pool.withResource(
|
||||
final result = await poolFullFileFaceGenerations.withResource(
|
||||
() async => await getFaceCrops(
|
||||
widget.file,
|
||||
{
|
||||
|
|
|
@ -198,7 +198,7 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
|
|||
return faceIdToCrop;
|
||||
}
|
||||
|
||||
final result = await pool.withResource(
|
||||
final result = await poolFullFileFaceGenerations.withResource(
|
||||
() async => await getFaceCrops(
|
||||
widget.file,
|
||||
facesWithoutCrops,
|
||||
|
|
|
@ -15,6 +15,7 @@ import "package:photos/ui/viewer/file_details/face_widget.dart";
|
|||
import "package:photos/ui/viewer/people/cropped_face_image_view.dart";
|
||||
import "package:photos/utils/face/face_box_crop.dart";
|
||||
import "package:photos/utils/thumbnail_util.dart";
|
||||
import "package:pool/pool.dart";
|
||||
|
||||
class PersonFaceWidget extends StatelessWidget {
|
||||
final EnteFile file;
|
||||
|
@ -155,7 +156,13 @@ class PersonFaceWidget extends StatelessWidget {
|
|||
return null;
|
||||
}
|
||||
|
||||
final result = await pool.withResource(
|
||||
late final Pool relevantResourcePool;
|
||||
if (useFullFile) {
|
||||
relevantResourcePool = poolFullFileFaceGenerations;
|
||||
} else {
|
||||
relevantResourcePool = poolThumbnailFaceGenerations;
|
||||
}
|
||||
final result = await relevantResourcePool.withResource(
|
||||
() async => await getFaceCrops(
|
||||
fileForFaceCrop!,
|
||||
{
|
||||
|
@ -226,7 +233,13 @@ class PersonFaceWidget extends StatelessWidget {
|
|||
return null;
|
||||
}
|
||||
|
||||
final result = await pool.withResource(
|
||||
late final Pool relevantResourcePool;
|
||||
if (useFullFile) {
|
||||
relevantResourcePool = poolFullFileFaceGenerations;
|
||||
} else {
|
||||
relevantResourcePool = poolThumbnailFaceGenerations;
|
||||
}
|
||||
final result = await relevantResourcePool.withResource(
|
||||
() async => await getFaceCrops(
|
||||
fileForFaceCrop!,
|
||||
{
|
||||
|
|
|
@ -13,13 +13,15 @@ import "package:pool/pool.dart";
|
|||
|
||||
final LRUMap<String, Uint8List?> faceCropCache = LRUMap(1000);
|
||||
final LRUMap<String, Uint8List?> faceCropThumbnailCache = LRUMap(1000);
|
||||
final pool = Pool(10, timeout: const Duration(seconds: 15));
|
||||
final poolFullFileFaceGenerations =
|
||||
Pool(20, timeout: const Duration(seconds: 15));
|
||||
final poolThumbnailFaceGenerations =
|
||||
Pool(100, timeout: const Duration(seconds: 15));
|
||||
Future<Map<String, Uint8List>?> getFaceCrops(
|
||||
EnteFile file,
|
||||
Map<String, FaceBox> faceBoxeMap, {
|
||||
bool useFullFile = true,
|
||||
}
|
||||
) async {
|
||||
}) async {
|
||||
late String? imagePath;
|
||||
if (useFullFile && file.fileType != FileType.video) {
|
||||
final File? ioFile = await getFile(file);
|
||||
|
@ -28,11 +30,11 @@ Future<Map<String, Uint8List>?> getFaceCrops(
|
|||
}
|
||||
imagePath = ioFile.path;
|
||||
} else {
|
||||
final thumbnail = await getThumbnailForUploadedFile(file);
|
||||
if (thumbnail == null) {
|
||||
return null;
|
||||
}
|
||||
imagePath = thumbnail.path;
|
||||
final thumbnail = await getThumbnailForUploadedFile(file);
|
||||
if (thumbnail == null) {
|
||||
return null;
|
||||
}
|
||||
imagePath = thumbnail.path;
|
||||
}
|
||||
final List<String> faceIds = [];
|
||||
final List<FaceBox> faceBoxes = [];
|
||||
|
|
Loading…
Reference in a new issue