コード例 #1
0
        public List <CardRegion> identifyRegions(Image screenImage)
        {
            List <CardRegion> regions = new List <CardRegion>();

            // scan horizontal
            int reachableScanWidth = screenImage.width - maxCardWidth;

            for (int x = 0; x < reachableScanWidth; x++)
            {
                foreach (CardPattern card in cards)
                {
                    // card image
                    Image cardImage = card.Image;

                    // compare
                    bool[] matches = compare(cardImage, screenImage, x);
                    float  overlap = percent(matches);

                    // region
                    CardRegion region = new CardRegion(card, x, overlap);
                    regions.Add(region);

                    // skip if mininum overlap reached
                    if (overlap >= GetMinimumOverlaphForCard(region))
                    {
                        x += cardImage.width + REGIONS_MIN_SPACE_BETWEEN_CARDS;
                        break;
                    }
                }
            }
            return(regions);
        }
コード例 #2
0
 private double GetMinimumOverlaphForCard(CardRegion card)
 {
     if (card.card.Rank == Card.RankEnum.Five ||
         card.card.Rank == Card.RankEnum.Six ||
         card.card.Rank == Card.RankEnum.Eigth ||
         card.card.Rank == Card.RankEnum.Nine)
     {
         return(REGIONS_X_SCAN_MIN_MATCH_5_6_OR_8_9);
     }
     else
     {
         return(REGIONS_X_SCAN_MIN_MATCH);
     }
 }