11-18-2022, 09:08 PM (This post was last modified: 11-18-2022, 09:09 PM by Kernelpanic.)
Quote:That's what I'm wondering.
Maybe there's some magic "compare object" command that I don't know about.
Evidently comparing it pixel-by-pixel, or a representative sampling of pixels, is a way to do it.
But see my reply to Pete above to see why I'm asking this, there might be a better approach than comparing images...
Your image comparison is a core problem of the AI: Pattern recognition/comparison, or something. I don't know the exact name at the moment.
The problem was already described by Hubert L. Dreyfus in his first book in 1972: "What Computers Can't Do: The Limits of Artificial Intelligence".
This pattern recognition is essential for the survival of all living beings. For example: A deer must recognize at first glance whether what it sees is harmless or dangerous (such as a wolf).
All the best! Really! - Show the eggheads what basic programmers can do.
(11-18-2022, 09:08 PM)Kernelpanic Wrote: A deer must recognize at first glance whether what it sees is harmless or dangerous (such as a wolf)
I don't know, man. Deer are quite retarded. A deer will jump at the slightest twig movement but will watch a 2,000 pound metal machine roar towards it and not budge an inch.
Ask me about Windows API and maybe some Linux stuff
11-18-2022, 09:15 PM (This post was last modified: 11-18-2022, 09:21 PM by Kernelpanic.)
(11-18-2022, 09:10 PM)Spriggsy Wrote:
(11-18-2022, 09:08 PM)Kernelpanic Wrote: A deer must recognize at first glance whether what it sees is harmless or dangerous (such as a wolf)
I don't know, man. Deer are quite retarded. A deer will jump at the slightest twig movement but will watch a 2,000 pound metal machine roar towards it and not budge an inch.
Because the machine doesn't know it and therefore can't classify it (first time): dangerous or not
PS:
There is a video (but where now), about twelve years old, that shows the German Bundeswehr during target practice with howitzers - and about 200 to 300 meters away deer are grazing peacefully. Why? Because they've realized by now that the banging isn't aimed at them.
squish the two images down to a really small image. If they don't match when they are 2 by 2 pixels they sure aren't going to match when they are say 200 by 200 pixels.
if it matches keep comparing pixels by pixel in slightly larger scaled image until back up to original size.
file1 = "C:\Users\zspriggs\Documents\QB64\qb64pe.exe"
'file2 = "C:\Users\zspriggs\Documents\QB64\pipecomqb64.bas"
file2 = file1 'You can comment this line and uncomment the one above. Obviously, you'll replace the paths with ones you have.
hash1 = GetHash(file1)
hash2 = GetHash(file2)
If hash1 = hash2 Then Print "Same" Else Print "Different"
Function GetHash$ (filename As String)
Dim As String filecopy: filecopy = "\" + Chr$(34) + filename + "\" + Chr$(34)
GetHash = pipecom_lite("PowerShell -NoProfile Get-FileHash -Path " + filecopy + " ^| foreach {$_.Hash}")
End Function
'$Include:'pipecomqb64.bas'
This might work for ya.
Ask me about Windows API and maybe some Linux stuff
(11-18-2022, 09:08 PM)Spriggsy Wrote: Or, very simply, MEM both images and compare the data within for equality by putting the data into a string and checking image1$ = image2$
So far, this sounds pretty workable.
Thanks!
(I could just manually include fill points in the shape data, but it's fun to solve problems like this!)
'let's make this an unique and pretty image!
For i = 1 To 100
Line (Rnd * _Width, Rnd * _Height)-(Rnd * width, Rnd * _Height), &HFF000000 + Rnd * &HFFFFFF, BF
Next
image2 = _CopyImage(0) 'identical copies for testing
image3 = _CopyImage(0) 'identical copy... BUT
_Dest image3
PSet (Rnd * _Width, Rnd * _Height), &HFF000000 + Rnd * &HFFFFFF 'We've just tweaked it so that there's no way in hell it's the same as the other two now!
_Dest 0 'image3 is EXACTLY one pixel different from the other two. Can we detect that?
image4 = _CopyImage(0) 'an identical copy once again, because 0 will change once we print the results
Print "Current Screen and Image 1 Compare: "; result1
Print "Current Screen and Image 2 Compare: "; result2
Print "Image1 and Image 2 Compare : "; result3
Print
Print "Press <ANY KEY> for a speed test!"
Sleep
t# = Timer
Limit = 1000
For i = 1 To Limit
result = CompareImages(image2, image3)
result = CompareImages(image2, image4)
Next
Print
Print Using "####.####### seconds to do"; Timer - t#;
Print Limit * 2; "comparisons."
Function CompareImages (handle1 As Long, handle2 As Long)
$Checking:Off
Static m(1) As _MEM
Dim s(1) As String
m(0) = _MemImage(handle1): m(1) = _MemImage(handle2)
If m(0).SIZE <> m(1).SIZE Then Exit Function 'not identical
If m(0).ELEMENTSIZE <> m(1).ELEMENTSIZE Then Exit Function 'not identical
s(0) = Space$(m(0).SIZE): s(1) = Space$(m(1).SIZE)
_MemGet m(0), m(0).OFFSET, s(0): _MemGet m(1), m(1).OFFSET, s(1)
If s(0) = s(1) Then CompareImages = -1
$Checking:On
End Function
(11-18-2022, 09:30 PM)Pete Wrote: If the images are in a file, just open each into a variable with BINARY.
If the variables are equal, the images are the same....
Pete
This may not work for a variety of reasons. Different formats of the same image. One was saved compressed, the other wasn't. One has additional file attributes attached to it, that the other doesn't. You'd want to load the files into memory and compare the contents of the image once they're loaded. After all, you want to know if the IMAGES are identical; not the files which contain them.