189 lines
5.9 KiB
C#
189 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
namespace Company.Domain.EmployeeFaceEmbeddingAgg;
|
|
|
|
public class EmployeeFaceEmbedding
|
|
{
|
|
public EmployeeFaceEmbedding()
|
|
{
|
|
EmbeddingHistory = new List<EmbeddingHistoryItem>();
|
|
MetadataHistory = new List<MetadataHistoryItem>();
|
|
}
|
|
|
|
public EmployeeFaceEmbedding(string employeeFullName, long employeeId, long workshopId,
|
|
List<double> embeddings, EmployeeFaceEmbeddingMetadata metadata)
|
|
{
|
|
Id = Guid.NewGuid().ToString();
|
|
EmployeeFullName = employeeFullName;
|
|
EmployeeId = employeeId;
|
|
WorkshopId = workshopId;
|
|
Embeddings = embeddings;
|
|
Metadata = metadata;
|
|
EmbeddingHistory = new List<EmbeddingHistoryItem>();
|
|
MetadataHistory = new List<MetadataHistoryItem>();
|
|
CreatedAt = DateTime.UtcNow;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
[BsonId]
|
|
[BsonRepresentation(BsonType.String)]
|
|
public string Id { get; set; }
|
|
|
|
[BsonElement("employeeFullName")]
|
|
public string EmployeeFullName { get; set; }
|
|
|
|
[BsonElement("employeeId")]
|
|
public long EmployeeId { get; set; }
|
|
|
|
[BsonElement("workshopId")]
|
|
public long WorkshopId { get; set; }
|
|
|
|
[BsonElement("embeddings")]
|
|
public List<double> Embeddings { get; set; }
|
|
|
|
[BsonElement("metadata")]
|
|
public EmployeeFaceEmbeddingMetadata Metadata { get; set; }
|
|
|
|
[BsonElement("embeddingHistory")]
|
|
public List<EmbeddingHistoryItem> EmbeddingHistory { get; set; }
|
|
|
|
[BsonElement("metadataHistory")]
|
|
public List<MetadataHistoryItem> MetadataHistory { get; set; }
|
|
|
|
[BsonElement("createdAt")]
|
|
public DateTime CreatedAt { get; set; }
|
|
|
|
[BsonElement("updatedAt")]
|
|
public DateTime UpdatedAt { get; set; }
|
|
|
|
public void UpdateEmbedding(List<double> newEmbedding, double confidence, double refinementPercentage)
|
|
{
|
|
if (Embeddings != null)
|
|
{
|
|
EmbeddingHistory.Add(new EmbeddingHistoryItem
|
|
{
|
|
Embedding = new List<double>(Embeddings),
|
|
Timestamp = DateTime.UtcNow,
|
|
Confidence = confidence,
|
|
RefinementPercentage = refinementPercentage
|
|
});
|
|
}
|
|
|
|
Embeddings = newEmbedding;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
public void UpdateMetadata(EmployeeFaceEmbeddingMetadata newMetadata, double confidence, double refinementPercentage)
|
|
{
|
|
if (Metadata != null)
|
|
{
|
|
MetadataHistory.Add(new MetadataHistoryItem
|
|
{
|
|
Metadata = Metadata,
|
|
Timestamp = DateTime.UtcNow,
|
|
Confidence = confidence,
|
|
RefinementPercentage = refinementPercentage
|
|
});
|
|
}
|
|
|
|
Metadata = newMetadata;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
public void UpdateEmployeeInfo(string employeeFullName, long workshopId)
|
|
{
|
|
EmployeeFullName = employeeFullName;
|
|
WorkshopId = workshopId;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
}
|
|
|
|
public class EmployeeFaceEmbeddingMetadata
|
|
{
|
|
[BsonElement("avg_eye_distance_normalized")]
|
|
public double AvgEyeDistanceNormalized { get; set; }
|
|
|
|
[BsonElement("avg_eye_to_face_ratio")]
|
|
public double AvgEyeToFaceRatio { get; set; }
|
|
|
|
[BsonElement("avg_face_aspect_ratio")]
|
|
public double AvgFaceAspectRatio { get; set; }
|
|
|
|
[BsonElement("avg_detection_confidence")]
|
|
public double AvgDetectionConfidence { get; set; }
|
|
|
|
[BsonElement("avg_keypoints_normalized")]
|
|
public EmployeeFaceEmbeddingKeypoints AvgKeypointsNormalized { get; set; }
|
|
|
|
[BsonElement("per_image_metadata")]
|
|
public List<ImageMetadata> PerImageMetadata { get; set; }
|
|
}
|
|
|
|
public class EmployeeFaceEmbeddingKeypoints
|
|
{
|
|
[BsonElement("left_eye")]
|
|
public double[] LeftEye { get; set; }
|
|
|
|
[BsonElement("right_eye")]
|
|
public double[] RightEye { get; set; }
|
|
|
|
[BsonElement("nose")]
|
|
public double[] Nose { get; set; }
|
|
|
|
[BsonElement("mouth_left")]
|
|
public double[] MouthLeft { get; set; }
|
|
|
|
[BsonElement("mouth_right")]
|
|
public double[] MouthRight { get; set; }
|
|
}
|
|
|
|
public class ImageMetadata
|
|
{
|
|
[BsonElement("face_aspect_ratio")]
|
|
public double FaceAspectRatio { get; set; }
|
|
|
|
[BsonElement("eye_distance_normalized")]
|
|
public double EyeDistanceNormalized { get; set; }
|
|
|
|
[BsonElement("eye_to_face_ratio")]
|
|
public double EyeToFaceRatio { get; set; }
|
|
|
|
[BsonElement("detection_confidence")]
|
|
public double DetectionConfidence { get; set; }
|
|
|
|
[BsonElement("keypoints_normalized")]
|
|
public EmployeeFaceEmbeddingKeypoints KeypointsNormalized { get; set; }
|
|
}
|
|
|
|
public class EmbeddingHistoryItem
|
|
{
|
|
[BsonElement("embedding")]
|
|
public List<double> Embedding { get; set; }
|
|
|
|
[BsonElement("timestamp")]
|
|
public DateTime Timestamp { get; set; }
|
|
|
|
[BsonElement("confidence")]
|
|
public double Confidence { get; set; }
|
|
|
|
[BsonElement("refinementPercentage")]
|
|
public double RefinementPercentage { get; set; }
|
|
}
|
|
|
|
public class MetadataHistoryItem
|
|
{
|
|
[BsonElement("metadata")]
|
|
public EmployeeFaceEmbeddingMetadata Metadata { get; set; }
|
|
|
|
[BsonElement("timestamp")]
|
|
public DateTime Timestamp { get; set; }
|
|
|
|
[BsonElement("confidence")]
|
|
public double Confidence { get; set; }
|
|
|
|
[BsonElement("refinementPercentage")]
|
|
public double RefinementPercentage { get; set; }
|
|
} |