Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15634

Faster find image on screen?

$
0
0
EDIT: Never mind... it won't work. The images I'm looking at are all 'slightly different', so each one would need its own search picture, and given the point of the thing was to, effectively, play a 'Memory' type game (card matching), this approach won't even come close as I have no good reason to think the 'turned over' images are any less 'different' than the backs of those same cards. :(
I'd need some way to find 'similar' images, and as far as I know that's a huge undertaking. No idea why the images are even different. Screen resolution changes, maybe? Something like that. *sigh* Looks like I'm doing it by hand still. :mad:

========

Okay, so... after fiddling with the problem I posted yesterday, I came up with this:
'screen' is a Bitmap holding the screen image (as yet untested for actual screen image, just using a .png I got via screen capture at one point for testing.
'bPic' is the thing I'm looking for (which should appear multiple times on screen.

Code:

        Dim thePoints As New List(Of Point)
        Dim p As Point
        For xS = 0 To screen.Width - bPic.Width - 1
            For yS = 0 To screen.Height - bPic.Height - 1
                p = New Point(xS, yS)
                For xB = 0 To bPic.Width - 1
                    For yB = 0 To bPic.Height - 1
                        Dim c1 As Color = bPic.GetPixel(xB, yB)
                        Dim c2 As Color = screen.GetPixel(xS + xB, yS + yB)
                        If c1.A = c2.A And c1.R = c2.R And c1.G = c2.G And c1.B = c2.B Then
                            'Matching so far
                        Else
                            'Not Matching
                            p = Nothing
                            Exit For
                        End If
                    Next
                    If p = Nothing Then Exit For
                Next
                If Not p = Nothing Then thePoints.Add(p)
            Next
        Next

Is this as good as it'll get for searching? Is there a better (by which I mostly mean faster, but more elegant while maintaining speed would be awesome, too) way of doing this?

Viewing all articles
Browse latest Browse all 15634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>