Exemplo n.º 1
0
        public bool MatchTemplate(Rectangle rect, ulong targetHash, double similarity = DEFAULT_RECT_TOLERANCE)
        {
            if (CurrentFrame == null)
            {
                return(false);
            }

            var cropped = CropFrame(rect);
            var hash    = ImageHashing.AverageHash(cropped);

            return(ImageHashing.Similarity(hash, targetHash) >= similarity);
        }
Exemplo n.º 2
0
        private void CompareImages()
        {
            if (imageAPictureBox.Image == null || imageBPictureBox.Image == null)
            {
                return;
            }

            var hashA = ImageHashing.AverageHash(imageAPictureBox.Image);
            var hashB = ImageHashing.AverageHash(imageBPictureBox.Image);

            //var similarity = ImageHashing.Similarity(imageAPictureBox.Image, imageBPictureBox.Image);
            var similarity = ImageHashing.Similarity(hashA, hashB);

            var message = String.Format("SIMILARITY: {0}%", similarity);

            //MessageBox.Show(message);
            compareButton.Text = message;
        }
Exemplo n.º 3
0
        public static bool MatchTemplate(this ScriptBase script, MatchedValue matchedValue)
        {
            bool matched = script.MatchTemplate(matchedValue.Position, matchedValue.Hash, matchedValue.Similarity);

#if DEBUG
            if (Settings.Default.CreateDebugScreenshots)
            {
                var cropped    = script.CropFrame(script.CurrentFrame, matchedValue.Position);
                var hash       = ImageHashing.AverageHash(cropped);
                var similarity = ImageHashing.Similarity(hash, matchedValue.Hash);
                if (!matched)
                {
                    cropped.Save($"lastnotmatch_{matchedValue.ID}.png");
                }
            }
#endif
            return(matched);
        }