Ejemplo 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);
        }
Ejemplo n.º 2
0
 private void OnImageChanged(Image image, PictureBox pictureBox)
 {
     if (pictureBox == imageAPictureBox)
     {
         var hash = ImageHashing.AverageHash(imageAPictureBox.Image);
         imageAHashTextBox.Text = hash.ToString();
     }
     else if (pictureBox == imageBPictureBox)
     {
         var hash = ImageHashing.AverageHash(imageBPictureBox.Image);
         imageBHashTextBox.Text = hash.ToString();
     }
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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);
        }