/// <summary> /// Finds the closest trunk for a climbable tree /// </summary> /// <param name="trunkColor">color range defining a climbable tree trunk</param> /// <param name="trunk">returns a climbable tree trunk if found</param> /// <param name="minimumSize">not used</param> /// <returns>true if a climbable tree trunk is found</returns> private bool FindTreeTrunk(ColorFilter trunkColor, out Blob trunk, int minimumSize = 1, int maximumSize = int.MaxValue) { trunk = null; Screen.ReadWindow(); bool[,] objectPixels = Vision.ColorFilter(trunkColor); Vision.EraseClientUIFromMask(ref objectPixels); List <Blob> possibleTrunks = ImageProcessing.FindBlobs(objectPixels, false, MinTreeTrunkSize, MaxTreeTrunkSize); if (possibleTrunks.Count == 0) { return(false); } trunk = possibleTrunks[0]; double rectangularity; double mostRectangular = Geometry.Rectangularity(trunk); for (int i = 1; i < possibleTrunks.Count; i++) { rectangularity = Geometry.Rectangularity(possibleTrunks[i]); if (rectangularity > mostRectangular) { trunk = possibleTrunks[i]; mostRectangular = rectangularity; } } return(true); }
/// <summary> /// Finds the closest climbable tree /// </summary> /// <param name="treeColor">color range defining tree branches</param> /// <param name="tree">returns the tree blob if founf</param> /// <param name="minimumSize">not used</param> /// <returns>true if a set of branches is found</returns> private bool FindTreeBranches(out Blob tree, Point treeTrunk) { tree = null; Screen.ReadWindow(); bool[,] objectPixels = Vision.ColorFilter(TreeBranch); Vision.EraseClientUIFromMask(ref objectPixels); List <Blob> branches = ImageProcessing.FindBlobs(objectPixels, false, MinTreeBranchSize); if (branches.Count == 0) { return(false); } tree = branches[0]; double offset; double closestOffset = Geometry.DistanceBetweenPoints(treeTrunk, branches[0].GetBottom()); for (int i = 1; i < branches.Count; i++) { offset = Geometry.DistanceBetweenPoints(treeTrunk, branches[i].GetBottom()); if (offset < closestOffset) { tree = branches[i]; closestOffset = offset; } } return(true); }
/// <summary> /// Finds the possible kebbits. /// </summary> /// <returns>A list of kebbits in the order that they should be checked.</returns> protected List <Kebbit> LocateKebbits() { Screen.ReadWindow(); bool[,] blackSpotMatches = Vision.ColorFilter(Kebbit.KebbitBlackSpot); Vision.EraseClientUIFromMask(ref blackSpotMatches); List <Blob> blackSpots = ImageProcessing.FindBlobs(blackSpotMatches, false, 1, Screen.ArtifactArea(0.00002183)); //ex 1-11 (0.000000992-0.00001091) List <Cluster> kebbitLocations = ImageProcessing.ClusterBlobs(blackSpots, Screen.ArtifactLength(0.0349)); List <Kebbit> kebbits = new List <Kebbit>(); foreach (Cluster kebbitSpots in kebbitLocations) { kebbits.Add(new Kebbit(Screen, kebbitSpots, Screen.Center)); } return(kebbits); }
/// <summary> /// Locates the top of the frame of the middle cargo net of the closest group of three /// </summary> /// <param name="cargoNetFrameColor">defines the top of a cargo net color</param> /// <param name="cargoNet">returns the top of the middle cargo net</param> /// <param name="minimumSize">conservative size floor</param> /// <returns>true if a set of cargo nets is found</returns> private bool LocateMiddleCargoNet(ColorFilter cargoNetFrameColor, out Blob cargoNet, int minimumSize = 1, int maximumSize = int.MaxValue) { cargoNet = null; Screen.ReadWindow(); bool[,] cargoNetFrame = Vision.ColorFilter(CargoNet); Vision.EraseClientUIFromMask(ref cargoNetFrame); List <Blob> cargoNetFrames = ImageProcessing.FindBlobs(cargoNetFrame, false, MinCargoNetSize); if (cargoNetFrames.Count < 3) { return(false); } else { cargoNetFrames = ClosestFrameSet(cargoNetFrames); cargoNet = MiddleCargoNet(cargoNetFrames); return(true); } }