mirror of
https://github.com/ente-io/ente.git
synced 2025-07-01 13:13:35 +00:00
40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
import "dart:convert";
|
|
|
|
import 'package:photos/db/ml/db_fields.dart';
|
|
import "package:photos/generated/protos/ente/common/vector.pb.dart";
|
|
import "package:photos/models/ml/face/detection.dart";
|
|
import "package:photos/models/ml/face/face.dart";
|
|
import "package:photos/models/ml/ml_versions.dart";
|
|
|
|
Map<String, dynamic> mapRemoteToFaceDB(Face face) {
|
|
return {
|
|
faceIDColumn: face.faceID,
|
|
fileIDColumn: face.fileID,
|
|
faceDetectionColumn: json.encode(face.detection.toJson()),
|
|
embeddingColumn: EVector(
|
|
values: face.embedding,
|
|
).writeToBuffer(),
|
|
faceScore: face.score,
|
|
faceBlur: face.blur,
|
|
isSideways: face.detection.faceIsSideways() ? 1 : 0,
|
|
mlVersionColumn: faceMlVersion,
|
|
imageWidth: face.fileInfo?.imageWidth ?? 0,
|
|
imageHeight: face.fileInfo?.imageHeight ?? 0,
|
|
};
|
|
}
|
|
|
|
Face mapRowToFace(Map<String, dynamic> row) {
|
|
return Face(
|
|
row[faceIDColumn] as String,
|
|
row[fileIDColumn] as int,
|
|
EVector.fromBuffer(row[embeddingColumn] as List<int>).values,
|
|
row[faceScore] as double,
|
|
Detection.fromJson(json.decode(row[faceDetectionColumn] as String)),
|
|
row[faceBlur] as double,
|
|
fileInfo: FileInfo(
|
|
imageWidth: row[imageWidth] as int,
|
|
imageHeight: row[imageHeight] as int,
|
|
),
|
|
);
|
|
}
|