/// <summary> /// Saves a thumbnail from a source image, using the Face's FaceRectangle and ThumbnailPath. /// </summary> /// <param name="face">The Face to save a thumbnail for.</param> /// <param name="sourceImage">The source image where the thumbnail will be cropped from.</param> public static void SaveThumbnailFromSource(this Model.Face face, UIImage sourceImage) { using (var thumbnail = face.CreateThumbnail(sourceImage)) { face.SaveThumbnail(thumbnail); } }
async Task AddFace(Model.Face face) { try { this.ShowHUD("Adding face"); await FaceClient.Shared.AddFaceForPerson(Person, Group, face, SourceImage.AsJpegStream); face.SaveThumbnailFromSource(SourceImage); //we should be done with the source image now SourceImage.Dispose(); SourceImage = null; this.ShowSimpleHUD("Face added for this person"); PersonFaceCVC.CollectionView.ReloadData(); FaceState.Current.NeedsTraining = true; } catch (Exception) { this.HideHUD().ShowSimpleAlert("Failed to add face."); } }
public void SetFace(Model.Face face, UIImage thumbnail) { TitleLabel.Text = face.Id; SizeLabel.Text = $"Position: {face.FaceRectangle.Left}, {face.FaceRectangle.Top}; Size: {face.FaceRectangle.Width}x{face.FaceRectangle.Height}"; var attrs = face.Attributes; if (attrs != null) { AgeLabel.Text = $"Age: {attrs.Age}"; GenderLabel.Text = $"Gender: {attrs.Gender}"; HairLabel.Text = attrs.Hair?.ToString(); SmileLabel.Text = $"Smile Intensity: {attrs.SmileIntensity}"; FacialHairLabel.Text = attrs.FacialHair?.ToString(); GlassesLabel.Text = $"Glasses: {attrs.Glasses}"; EmotionLabel.Text = attrs.Emotion?.ToString(); MakeupLabel.Text = attrs.Makeup?.ToString(); HeadPoseLabel.Text = attrs.HeadPose?.ToString(); AccessoriesLabel.Text = attrs.Accessories?.ToString(); OcclusionLabel.Text = attrs.Occlusion?.ToString(); BlurLabel.Text = attrs.Blur?.ToString(); NoiseLabel.Text = attrs.Noise?.ToString(); ExposureLabel.Text = attrs.Exposure?.ToString(); } FaceImageView.ContentMode = UIViewContentMode.ScaleAspectFit; FaceImageView.Image = thumbnail; }
/// <summary> /// Gets the thumbnail image for the given Face. This assumes the thumbnail has already been saved using the <see cref="SaveThumbnail"/> method. /// </summary> /// <returns>The thumbnail image.</returns> /// <param name="face">Face.</param> public static Bitmap GetThumbnailImage(this Model.Face face) { if (!string.IsNullOrEmpty(face.ThumbnailPath)) { return(BitmapFactory.DecodeFile(face.ThumbnailPath)); } return(null); }
public UIImage GetThumbnailForFace(Model.Face face) { var index = Faces.IndexOf(face); if (index > -1 && thumbnailImages.Count > index) { return(thumbnailImages [index]); } return(null); }
internal static Model.Face ToFace(this Droid.Contract.PersonFace personFace) { var face = new Model.Face { Id = personFace.PersistedFaceId.ToString(), UserData = personFace.UserData }; face.UpdateThumbnailPath(); return(face); }
internal static Model.Face ToFace(this MPOPersonFace mpoFace) { var face = new Model.Face { Id = mpoFace.PersistedFaceId, UserData = mpoFace.UserData }; face.UpdateThumbnailPath(); return(face); }
private static Face MapToDomain(this Model.Face f) { return(new Face { Id = f.id, Name = f.name, Confidence = f.confidence, Description = f.description, Title = f.title, ThumbnailUrl = f.thumbnailFullUrl, SeenDuration = f.seenDuration, SeenDurationRatio = f.seenDurationRatio, Appearances = f.appearances?.Select(MapToDomain).ToList(), }); }
internal static Model.Face ToFace(this Droid.Contract.Face thisFace, bool adaptLandmarks = false, FaceAttributeType [] attributes = null) { var thatFace = new Model.Face { Id = thisFace.FaceId.ToString(), FaceRectangle = thisFace.FaceRectangle.ToFaceRectangle(), Attributes = thisFace.FaceAttributes?.ToFaceAttributes(attributes) }; if (adaptLandmarks) { thatFace.Landmarks = thisFace.FaceLandmarks?.ToFaceLandmarks(); } thatFace.UpdateThumbnailPath(); return(thatFace); }
internal static Model.Face ToFace(this MPOFace mpoFace, bool adaptLandmarks = false, FaceAttributeType [] attributes = null) { var face = new Model.Face { Id = mpoFace.FaceId, FaceRectangle = mpoFace.FaceRectangle.ToFaceRectangle(), Attributes = mpoFace.Attributes?.ToFaceAttributes(attributes) }; if (adaptLandmarks) { face.Landmarks = mpoFace.FaceLandmarks?.ToFaceLandmarks(); } face.UpdateThumbnailPath(); return(face); }
async Task ExecuteDeleteFace(Model.Face face) { //progressDialog.Show (); AddLog("Request: Deleting face " + face.Id); try { //progressDialog.SetMessage ("Deleting selected faces..."); SetInfo("Deleting selected faces..."); await FaceClient.Shared.DeletePersonFace(Person, Group, face); SetInfo("Face " + face.Id + " successfully deleted"); AddLog("Response: Success. Deleting face " + face.Id + " succeed"); } catch (Exception e) { AddLog(e.Message); SetInfo("Error deleting face with Id " + face.Id); } //progressDialog.Dismiss (); }
/// <summary> /// Resize face rectangle, for better view of the person. /// To make the rectangle larger, faceRectEnlargeRatio should be larger than 1, recommended value (and default) is 1.3. /// </summary> /// <returns>The resized face rectangle.</returns> /// <param name="face">The Face to calculate a new face renctagle for.</param> /// <param name="bitmap">the source Bitmap.</param> /// <param name="faceRectEnlargeRatio">Face rect enlarge ratio.</param> public static System.Drawing.RectangleF CalculateLargeFaceRectangle(this Model.Face face, Bitmap bitmap, double faceRectEnlargeRatio = FACE_RECT_SCALE_RATIO) { // Get the resized side length of the face rectangle double sideLength = face.FaceRectangle.Width * faceRectEnlargeRatio; sideLength = Math.Min(sideLength, bitmap.Width); sideLength = Math.Min(sideLength, bitmap.Height); // Make the left edge to left more. double left = face.FaceRectangle.Left - face.FaceRectangle.Width * (faceRectEnlargeRatio - 1.0) * 0.5; left = Math.Max(left, 0.0); left = Math.Min(left, bitmap.Width - sideLength); // Make the top edge to top more. double top = face.FaceRectangle.Top - face.FaceRectangle.Height * (faceRectEnlargeRatio - 1.0) * 0.5; top = Math.Max(top, 0.0); top = Math.Min(top, bitmap.Height - sideLength); // Shift the top edge to top more, for better view for human double shiftTop = faceRectEnlargeRatio - 1.0; shiftTop = Math.Max(shiftTop, 0.0); shiftTop = Math.Min(shiftTop, 1.0); top -= 0.15 * shiftTop * face.FaceRectangle.Height; top = Math.Max(top, 0.0); return(new System.Drawing.RectangleF { X = (int)left, Y = (int)top, Width = (int)sideLength, Height = (int)sideLength }); }
/// <summary> /// Gets the thumbnail image for the given Face. This assumes the thumbnail has already been saved using the <see cref="SaveThumbnail"/> method. /// </summary> /// <returns>The thumbnail image.</returns> /// <param name="face">Face.</param> public static UIImage GetThumbnailImage(this Model.Face face) { return(UIImage.FromFile(face.ThumbnailPath)); }
/// <summary> /// Updates the thumbnail path of the Face. This will use the current Id to generate the thumbnail path for this Face. /// </summary> /// <param name="face">The <see cref="Face"/>.</param> public static void UpdateThumbnailPath(this Model.Face face) { var filePath = Path.Combine(DocsDir, face.FileName); face.ThumbnailPath = filePath; }
/// <summary> /// Saves the thumbnail image using the Face's current thumbnail path. /// </summary> /// <param name="face">Face.</param> /// <param name="thumbnail">Thumbnail image.</param> public static void SaveThumbnail(this Model.Face face, UIImage thumbnail) { face.UpdateThumbnailPath(); thumbnail.SaveAsJpeg(face.ThumbnailPath); }
/// <summary> /// Creates a thumbnail image for a given Face. /// </summary> /// <returns>The thumbnail image.</returns> /// <param name="face">The Face to generate a thumbnail for.</param> /// <param name="sourceImage">The source image or photo to crop the thumbnail from.</param> public static UIImage CreateThumbnail(this Model.Face face, UIImage sourceImage) { return(sourceImage.Crop(face.FaceRectangle.ToRectangle())); }
public void SetFaceImage(Model.Face face, UIImage image) { this.face = face; FaceImageView.Image = image; }
/// <summary> /// Creates a thumbnail image for a given Face. /// </summary> /// <returns>The thumbnail image.</returns> /// <param name="face">The Face to generate a thumbnail for.</param> /// <param name="sourceImage">The source image or photo to crop the thumbnail from.</param> public static Bitmap CreateThumbnail(this Model.Face face, Bitmap sourceImage) { var largeFaceRect = face.CalculateLargeFaceRectangle(sourceImage); return(sourceImage.Crop(largeFaceRect)); }