with this line
Code: Select all
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%,*TransWhite ./pictures/piece.png
Code: Select all
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%,*TransWhite ./pictures/piece.png
well this is the original image of itboiler wrote: ↑04 Dec 2021, 08:42Are you sure that each non-white pixel remaining is an exact match for the pixels that make up the black border of the shape? If you used a white paint brush tool to paint over everything up to the border, then you probably left grey pixels where it blends between the two. You have to use a pencil tool that paints only the exact pixel it’s on and leaves the adjacent pixels totally untouched when you get near that black border. That way you are left with only pure white and pixels from the original with their exact color values.
Are the pixels that make up that black border in the image you’re searching for going to be exactly the same no matter what colors surround it? You can’t really answer that by just visual inspection.
hmm then I should go with python to complete my scriptboiler wrote: ↑05 Dec 2021, 02:51That is true, but the image you showed is a white outline, and the outline you are looking for is black. So where does that image of a white outline on a black background come from? Are you saying you just reversed the colors? Does doing that result in an exact match of the black outline's color values as the one you are looking to match? You still need to take into account my earlier comments that the original colors of those pixels can't be different than the ones you are searching for, and you can't tell if that's the case just by looking at it unless you zoom way in on it. They have to match the exact color value at every single pixel location or it will not find a match. Even using an allowable variation won't help if one pixel is gray where it should be white.
When I zoom way in on the black outline on white background you showed earlier, it indeed shows lots of gray colors in the transition from black to white (in fact none or almost none are pure black), so it has no chance of being found. Not only that, the image with the colors in it has those colors bleeding into the outline, so those colors aren't pure black or gray either. Because it's so thin, you don't have enough pure colors in this outline to find it using this method. If it was a thicker border, you could paint over the transitions with white, leaving only the center of the line in pure black to be found. But that's not the case here.
@malcev posted a link to how you can use OpenCV from AutoHotkey. What method were you going to use in Python?99leeroi99 wrote: ↑ hmm then I should go with python to complete my script
Code: Select all
value:= [num1,num2,num3]
value:= Array (num1,num2,num3)
start:
1:
foundX:=foundX
foundY:=foundY
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%,*60 ./targets/1.png
If(ErrorLevel = 1){
gosub,2
}
else{
Array[Index] := 1
ToolTip, 1, %foundX%, %foundY%, 1
gosub,2
}
2:
foundX:=foundX
foundY:=foundY
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%,*60 ./targets/2.png
If(ErrorLevel = 1){
gosub,3
}
else{
Array[Index] := 2
ToolTip, 2, %foundX%, %foundY%, 1
gosub,3
}
3:
foundX:=foundX
foundY:=foundY
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%,*60 ./targets/3.png
If(ErrorLevel = 1){
gosub,4
}
else{
Array[Index] := 3
ToolTip, 3, %foundX%, %foundY%, 1
gosub,4
}
MSGBOX, % value
Code: Select all
value := []
Users browsing this forum: No registered users and 346 guests