public void ProcessAnnotations(AnnotationArgs args) { //This is where we are going to look at the annotation library //to learn from the examples. try { List <Ptype> lib = new List <Ptype>(); bool needsUpdate = ptypeUtil.UpdatePtypes(args.AnnotatedNodes, lib); if (needsUpdate) { shared[SHARED_PTYPES_KEY] = lib; featureTree = FeatureTree.FeatureTree.BuildTree(GetFeatures(lib)); } } catch (Exception e) { Console.WriteLine(e.StackTrace); } }
public void Init(Dictionary<string, object> parameters) { intent = (IRuntimeStorage)parameters["intent"]; shared = (Dictionary<string,object>)parameters["shared"]; libraries = new List<string>(); if(parameters.ContainsKey("library")) libraries.Add( (string)parameters["library"] ); try{ ptypeUtil = new PtypeSerializationUtility(); List<Ptype> lib = ptypeUtil.LoadPtypes(intent); shared[SHARED_PTYPES_KEY] = lib; this.featureTree = FeatureTree.FeatureTree.BuildTree(GetFeatures(lib)); }catch(Exception e){ Console.Error.WriteLine(e.StackTrace); } }
/// <summary> /// Builds a tree using the given features and the /// default optimizations. The default optimizations are that /// the hotspots are Assigned as the least common pixels out of /// any pixels in the corpus, and the offset chosen at a given node /// is the offset that maximizes information gain. /// </summary> /// <param name="features">The features that will be used to build the tree.</param> /// <returns>A FeatureTree that can locate the given features.</returns> public static FeatureTree BuildTree(IEnumerable <Feature> features) { if (features == null || features.Count() == 0) { return(null); } List <FeatureWrapper> featuresWithHotspots = AssignHotspotsByPixelFrequency(features); System.Drawing.Rectangle hotspotCoordinates = GetFeatureHotspotCoordinates(featuresWithHotspots); List <Point> validOffsets = GetAllPossibleOffsetsFromHotspotCoords(hotspotCoordinates); int farthestup = GetFarthestUpHotspotXFromItsBottom(featuresWithHotspots); int farthestleft = GetFarthestLeftHotspotXFromItsRight(featuresWithHotspots); int farthestdown = GetFarthestDownHotspotY(featuresWithHotspots); int farthestright = GetFarthestRightHotspotX(featuresWithHotspots); FeatureTree tree = new FeatureTree(BuildTreeHelper(featuresWithHotspots, validOffsets, true), farthestup, farthestleft, farthestdown, farthestright); return(tree); }
public void Init(Dictionary <string, object> parameters) { intent = (IRuntimeStorage)parameters["intent"]; shared = (Dictionary <string, object>)parameters["shared"]; libraries = new List <string>(); if (parameters.ContainsKey("library")) { libraries.Add((string)parameters["library"]); } try{ ptypeUtil = new PtypeSerializationUtility(); List <Ptype> lib = ptypeUtil.LoadPtypes(intent); shared[SHARED_PTYPES_KEY] = lib; this.featureTree = FeatureTree.FeatureTree.BuildTree(GetFeatures(lib)); }catch (Exception e) { Console.Error.WriteLine(e.StackTrace); } }
public void ProcessAnnotations(AnnotationArgs args) { //This is where we are going to look at the annotation library //to learn from the examples. try { List<Ptype> lib = new List<Ptype>(); bool needsUpdate = ptypeUtil.UpdatePtypes(args.AnnotatedNodes, lib); if(needsUpdate){ shared[SHARED_PTYPES_KEY] = lib; featureTree = FeatureTree.FeatureTree.BuildTree( GetFeatures(lib) ); } } catch (Exception e) { Console.WriteLine (e.StackTrace); } }
/// <summary> /// Builds a tree using the given features and the /// default optimizations. The default optimizations are that /// the hotspots are Assigned as the least common pixels out of /// any pixels in the corpus, and the offset chosen at a given node /// is the offset that maximizes information gain. /// </summary> /// <param name="features">The features that will be used to build the tree.</param> /// <returns>A FeatureTree that can locate the given features.</returns> public static FeatureTree BuildTree(IEnumerable<Feature> features) { if (features == null || features.Count() == 0) return null; List<FeatureWrapper> featuresWithHotspots = AssignHotspotsByPixelFrequency (features); System.Drawing.Rectangle hotspotCoordinates = GetFeatureHotspotCoordinates (featuresWithHotspots); List<Point> validOffsets = GetAllPossibleOffsetsFromHotspotCoords (hotspotCoordinates); int farthestup = GetFarthestUpHotspotXFromItsBottom (featuresWithHotspots); int farthestleft = GetFarthestLeftHotspotXFromItsRight (featuresWithHotspots); int farthestdown = GetFarthestDownHotspotY (featuresWithHotspots); int farthestright = GetFarthestRightHotspotX (featuresWithHotspots); FeatureTree tree = new FeatureTree (BuildTreeHelper (featuresWithHotspots, validOffsets, true), farthestup, farthestleft, farthestdown, farthestright); return tree; }