protected void UpdateObjHierarchyList(Transform objT) //, SetObjListCallback callback){ { List <Transform> objHList = new List <Transform>(); List <string> objNList = new List <string>(); ObjectHierarchy ObjH = GetTransformInHierarchyRecursively(objT); objHList.Add(null); objHList.Add(objT); objNList.Add(" - "); objNList.Add(" -" + objT.name); for (int i = 0; i < ObjH.listT.Count; i++) { objHList.Add(ObjH.listT[i]); } for (int i = 0; i < ObjH.listName.Count; i++) { while (objNList.Contains(ObjH.listName[i])) { ObjH.listName[i] += "."; } objNList.Add(ObjH.listName[i]); } objHierarchyList = objHList.ToArray(); objHierarchylabel = objNList.ToArray(); }
protected void NotifySuccessor(IDU op, ObjectHierarchy where, string info, object value) { if (_successor != null) { if (!_disableNotifies) _successor.Handle(op, where, info, value); } }
private static bool CheckForBirdRecursive(ObjectHierarchy detectedObject) { if (detectedObject == null) { return(false); } if (detectedObject.ObjectProperty.Equals("bird")) { return(true); } return(detectedObject.Parent != null && CheckForBirdRecursive(detectedObject.Parent)); }
private static ObjectHierarchy GetTransformInHierarchyRecursively(Transform transform, string label = " ") { ObjectHierarchy ObjH = new ObjectHierarchy(); label += " "; foreach (Transform t in transform) { ObjH.listT.Add(t); ObjH.listName.Add(label + "-" + t.name); ObjectHierarchy tempHL = GetTransformInHierarchyRecursively(t, label); foreach (Transform tt in tempHL.listT) { ObjH.listT.Add(tt); } foreach (string ll in tempHL.listName) { ObjH.listName.Add(ll); } } return(ObjH); }
/// <summary> /// Show Analysis Result. /// </summary> /// <param name="result">Analysis result to log.</param> protected void LogAnalysisResult(ImageAnalysis result) { if (result == null) { Log("null"); return; } if (result.Metadata != null) { Log("Metadata : "); Log(Invariant($" Image Format : {result.Metadata.Format}")); Log(Invariant($" Image Dimensions : {result.Metadata.Width} x {result.Metadata.Height}")); } if (result.ImageType != null) { Log("Image Type : "); string clipArtType; switch (result.ImageType.ClipArtType) { case 0: clipArtType = "0 Non-clipart"; break; case 1: clipArtType = "1 ambiguous"; break; case 2: clipArtType = "2 normal-clipart"; break; case 3: clipArtType = "3 good-clipart"; break; default: clipArtType = "Unknown"; break; } Log(Invariant($" Clip Art Type : {clipArtType}")); string lineDrawingType; switch (result.ImageType.LineDrawingType) { case 0: lineDrawingType = "0 Non-LineDrawing"; break; case 1: lineDrawingType = "1 LineDrawing"; break; default: lineDrawingType = "Unknown"; break; } Log(Invariant($" Line Drawing Type : {lineDrawingType}")); } if (result.Adult != null) { Log("Adult : "); Log(Invariant($" Is Adult Content : {result.Adult.IsAdultContent}")); Log(Invariant($" Adult Score : {result.Adult.AdultScore}")); Log(Invariant($" Is Racy Content : {result.Adult.IsRacyContent}")); Log(Invariant($" Racy Score : {result.Adult.RacyScore}")); } if (result.Brands != null) { Log("Brands : "); foreach (var brand in result.Brands) { Log(Invariant($" Brand : {brand.Name}; Confidence : {brand.Confidence}; Bounding Box: {brand.Rectangle.ToReadableString()}")); } } if (result.Objects != null) { Log("Objects : "); foreach (var obj in result.Objects) { Log(Invariant($" Object : Bounding Box : {obj.Rectangle.ToReadableString()}")); var detected = new ObjectHierarchy(obj.ObjectProperty, obj.Confidence, obj.Parent); while (detected != null) { Log(Invariant($" Label : {detected.ObjectProperty}; Confidence : {detected.Confidence}")); detected = detected.Parent; } } } if (result.Categories != null && result.Categories.Count > 0) { Log("Categories : "); foreach (var category in result.Categories) { Log(Invariant($" Name : {category.Name}; Score : {category.Score}")); } } if (result.Faces != null && result.Faces.Count > 0) { Log("Faces : "); foreach (var face in result.Faces) { Log(Invariant($" Age : {face.Age}; Gender : {face.Gender}")); } } if (result.Color != null) { Log("Color : "); Log(Invariant($" AccentColor : {result.Color.AccentColor}")); Log(Invariant($" Dominant Color Background : {result.Color.DominantColorBackground}")); Log(Invariant($" Dominant Color Foreground : {result.Color.DominantColorForeground}")); if (result.Color.DominantColors != null && result.Color.DominantColors.Count > 0) { string colors = "Dominant Colors : "; foreach (var color in result.Color.DominantColors) { colors += color + " "; } Log(colors); } } if (result.Description != null) { Log("Description : "); foreach (var caption in result.Description.Captions) { Log(Invariant($" Caption : {caption.Text}; Confidence : {caption.Confidence}")); } string tags = " Tags : "; foreach (var tag in result.Description.Tags) { tags += tag + ", "; } Log(tags); } if (result.Tags != null) { Log("Tags : "); foreach (var tag in result.Tags) { var hint = string.IsNullOrEmpty(tag.Hint) ? "" : Invariant($"; Hint : {tag.Hint}"); Log(Invariant($" Name : {tag.Name}; Confidence : {tag.Confidence}{hint}")); } } }
private void LogResult(ImageAnalysis result) { if (result == null) { Debug.WriteLine("null"); return; } if (result.Metadata != null) { Debug.WriteLine("Metadata : "); Debug.WriteLine($"Format : {result.Metadata.Format}"); Debug.WriteLine($"Width : {result.Metadata.Width}; Height {result.Metadata.Height}"); } if (result.ImageType != null) { Debug.WriteLine($"Image ClipArtType : { result.ImageType.ClipArtType }"); Debug.WriteLine($"Image LineDrawingType : { result.ImageType.LineDrawingType }"); } if (result.Adult != null) { Debug.WriteLine("Adult : "); Debug.WriteLine($"Is Adult Content : {result.Adult.IsAdultContent}"); Debug.WriteLine($"Adult Score : {result.Adult.AdultScore}"); Debug.WriteLine($"Is Racy Content : {result.Adult.IsRacyContent}"); Debug.WriteLine($"Racy Score : {result.Adult.RacyScore}"); } if (result.Brands != null) { Debug.WriteLine("Brands : "); foreach (var brand in result.Brands) { Debug.WriteLine($"Brand : {brand.Name}; Confidence : {brand.Confidence}; Bounding Box: {brand.Rectangle.ToString()}"); } } if (result.Objects != null) { Debug.WriteLine("Objects : "); foreach (var obj in result.Objects) { Debug.WriteLine($"Object : Bounding Box : {obj.Rectangle.ToString()}"); var detected = new ObjectHierarchy(obj.ObjectProperty, obj.Confidence, obj.Parent); while (detected != null) { Debug.WriteLine($"Label : {detected.ObjectProperty}; Confidence : {detected.Confidence}"); detected = detected.Parent; } } } if (result.Categories != null && result.Categories.Count > 0) { Debug.WriteLine("Categories : "); foreach (var category in result.Categories) { Debug.WriteLine($"Name : {category.Name}; Score : {category.Score}"); } } if (result.Faces != null && result.Faces.Count > 0) { Debug.WriteLine("Faces : "); foreach (var face in result.Faces) { Debug.WriteLine($"Age : {face.Age}; Gender : {face.Gender}"); } } if (result.Color != null) { Debug.WriteLine("Color : "); Debug.WriteLine($" AccentColor : {result.Color.AccentColor}"); Debug.WriteLine($" Dominant Color Background : {result.Color.DominantColorBackground}"); Debug.WriteLine($" Dominant Color Foreground : {result.Color.DominantColorForeground}"); if (result.Color.DominantColors != null && result.Color.DominantColors.Count > 0) { string colors = "Dominant Colors : "; foreach (var color in result.Color.DominantColors) { colors += color + " "; } Debug.WriteLine(colors); } } if (result.Description != null) { Debug.WriteLine("Description : "); foreach (var caption in result.Description.Captions) { Debug.WriteLine($" Caption : {caption.Text}; Confidence : {caption.Confidence}"); } string tags = " Tags : "; foreach (var tag in result.Description.Tags) { tags += tag + ", "; } Debug.WriteLine(tags); } if (result.Tags != null) { Debug.WriteLine("Tags : "); foreach (var tag in result.Tags) { var hint = string.IsNullOrEmpty(tag.Hint) ? "" : ($"; Hint : {tag.Hint}"); Debug.WriteLine($"Name : {tag.Name}; Confidence : {tag.Confidence}{hint}"); } } }
protected virtual void Handle(IDU op, ObjectHierarchy where, string info, object value) { NotifySuccessor(op, where, info, value); }