コード例 #1
0
 /// <summary>
 /// Loads default color ranges
 /// </summary>
 private void GetReferenceColors()
 {
     FurnaceIconOrange = RGBHSBRangeFactory.FurnaceIconOrange();
     BankIconDollar    = RGBHSBRangeFactory.BankIconDollar();
     BuildingFloor     = RGBHSBRangeFactory.PhasmatysBuildingFloorLight();
     Furnace           = RGBHSBRangeFactory.Furnace();
     BankBooth         = RGBHSBRangeFactory.BankBoothPhasmatys();
 }
コード例 #2
0
        /// <summary>
        /// Finds the closest bank booth in the Port Phasmatys bank
        /// </summary>
        /// <returns>True if the bank booths are found</returns>
        internal bool LocateBankBoothPhasmatys(out Blob bankBooth)
        {
            bankBooth = null;
            const int    numberOfBankBooths         = 6;
            const double minBoothWidthToHeightRatio = 2.3667;   //ex 2.6667
            const double maxBoothWidthToHeightRatio = 3.1333;   //ex 2.8333
            int          left   = Screen.Center.X - Screen.ArtifactLength(0.5);
            int          right  = Screen.Center.X + Screen.ArtifactLength(0.3);
            int          top    = Screen.Center.Y - Screen.ArtifactLength(0.15);
            int          bottom = Screen.Center.Y + Screen.ArtifactLength(0.2);

            Screen.ReadWindow();
            Point offset;

            bool[,] bankBooths = Vision.ColorFilterPiece(RGBHSBRangeFactory.BankBoothPhasmatys(), left, right, top, bottom, out offset);
            List <Blob> boothBlobs         = new List <Blob>();
            List <Blob> possibleBoothBlobs = ImageProcessing.FindBlobs(bankBooths, false, MinBankBoothSize, MaxBankBoothSize);  //list of blobs from biggest to smallest

            possibleBoothBlobs.Sort(new BlobProximityComparer(Screen.Center));
            double widthToHeightRatio, rectangularity;

            //Remove blobs that aren't bank booths
            foreach (Blob possibleBooth in possibleBoothBlobs)
            {
                widthToHeightRatio = (possibleBooth.Width / (double)possibleBooth.Height);
                rectangularity     = Geometry.Rectangularity(possibleBooth);
                if (Numerical.WithinBounds(widthToHeightRatio, minBoothWidthToHeightRatio, maxBoothWidthToHeightRatio) && rectangularity > 0.75)
                {
                    boothBlobs.Add(possibleBooth);
                }
            }

            if (boothBlobs.Count != numberOfBankBooths)
            {
                return(false);   //We either failed to locate all of the booths or identified something that was not actually a booth.
            }

            //Reduce the blob list to the bank booths
            boothBlobs.Sort(new BlobHorizontalComparer()); //sort from left to right
            boothBlobs.RemoveAt(3);                        //remove the unusable booths without tellers
            boothBlobs.RemoveAt(0);
            bankBooth = Blob.ClosestBlob(new Point(Screen.Center.X - left, Screen.Center.Y - top), boothBlobs);
            bankBooth.ShiftPixels(offset.X, offset.Y);
            return(true);
        }