PDA

View Full Version : bitmap tolerance not working?



Grand
08-31-2012, 06:20 PM
hi
I'm using FindBitmapToleranceIn to find bitmap and it works fine for any image.. But I have two almost exact same images but the function cannot find both of the images from the game by using either one of the images..

the tolerance parameter is supposed to give the tolerance but well it isn't working. If theres two almost identical images in game i still need two searches with FindBitmapToleranceIn to find them both.

i tried using SetColorToleranceSpeed but not sure did it make any difference...

help apreciated

thx

Le Jingle
08-31-2012, 06:24 PM
Are you trying to find a static bitmap (i.e. inventory), or a main screen bitmap?

There's also other bitmap finding functions such as:
http://docs.villavu.com/simba/scriptref/bitmaps.html

masterBB
08-31-2012, 06:45 PM
the tolerance parameter is supposed to give the tolerance

No, it doesn't give the tolerance. It doesn't return anything. It is input from you side. So just give it a value, if it doesn't find the bitmap, give it a higher value till it returns true.

Grand
08-31-2012, 07:35 PM
No, it doesn't give the tolerance. It doesn't return anything. It is input from you side. So just give it a value, if it doesn't find the bitmap, give it a higher value till it returns true.

actually I just meant it doesnt seem to add any tolerance to the search. I tried from 0-100 already...

Grand
08-31-2012, 07:38 PM
Are you trying to find a static bitmap (i.e. inventory), or a main screen bitmap?

There's also other bitmap finding functions such as:
http://docs.villavu.com/simba/scriptref/bitmaps.html

it's button bitmap. and it maybe little transparent which probably makes the search fail with other of the two (almost identical) reference bitmaps.

masterBB
08-31-2012, 07:41 PM
Mind posting the bitmaps and piece of code, prefer < 30 lines, where you utilize them? It seems I don't fully understand you.

Grand
08-31-2012, 08:08 PM
ok i made these functions to help finding images:



function findImage(bitmap:Integer;var ipos:TPoint):Boolean;
var rx,ry,w,h,tol:Integer;

begin
Result := False;

tol := 50;

//if(FindBitmap(bitmap,rx,ry)) then
if(FindBitmapToleranceIn(bitmap,rx,ry,0,0,winSize. X-1,winSize.Y-1, tol )) then
begin
ipos := Point(rx,ry);
Result := True;
end;

end;


function findImageL(pngstr:String;var ipos:TPoint):Boolean;
var bitmap:Integer;
begin
bitmap := LoadBitmap(pngstr+'.png');

Result := findImage(bitmap,ipos);

FreeBitmap(bitmap);
end;


and then call it:


findImageL('OKButton',ipos);


the function finds the OKButton on certain game screen but when i call it again (when the same button is on other screen) it can't find it....

riwu
09-01-2012, 12:18 AM
What is ur interpretation of 'tolerance'? You seem to understand it as it giving you 2 images?
FindBitmapToleranceIn will always return the first bitmap it finds (starting from the xs,ys) hence even if you have 2 bitmap, if your search parameters are identical, it will still return only the first bitmap even if u search a thousand times.

You'll have to use FindBitmapsSpiralTolerance if you want to get all the bitmaps found on the screen, and the points of matches will be stored in the TPA.

This is similar concept to using FindColors instead of FindColor. (and hence the popularity of TPA finding ;))

Grand
09-01-2012, 01:11 AM
yes I know. What im doing is trying to find the image from any screen it appears in.

once the button appears i click it and its dismissed. once it appears again i click it again to dismiss it.

problem is FindBitmapToleranceIn doesn't always find that image/button when it popups on the screen. i think this is because of transparency.

riwu
09-01-2012, 01:19 AM
yes I know. What im doing is trying to find the image from any screen it appears in.

once the button appears i click it and its dismissed. once it appears again i click it again to dismiss it.

problem is FindBitmapToleranceIn doesn't always find that image/button when it popups on the screen. i think this is because of transparency.
Did you use a loop to continuously call it? You should color those unwanted parts black and use FindDeformedBitmapToleranceIn for better accuracy.

Grand
09-01-2012, 01:22 AM
i will try FindDeformedBitmapToleranceIn next if that other function doesn't work as i expected.
yep im running loops ..

thx

Grand
09-02-2012, 10:37 PM
well the FindDeformedBitmapToleranceIn works but its really slow. takes about 10 secs to find the 20X20 image on 800x600 window

riwu
09-03-2012, 12:16 AM
well the FindDeformedBitmapToleranceIn works but its really slow. takes about 10 secs to find the 20X20 image on 800x600 window
Make the bitmap smaller (but still large enough remain as a distinct obj). Also you can lower the search region if the bitmap won't appear anywhere within the 800x600.

Grand
09-03-2012, 03:14 AM
ok I will try that thank you.

can you tell me whats the difference with Tolerance parameter and partial accuracy parameter in FindDeformedBitmapToleranceIn please?

riwu
09-03-2012, 03:22 AM
Tolerance is the difference in color that it allows, while partial accuracy is the extent in which the bitmap is difference from the input ('deformed').
You can refer to http://villavu.com/forum/showthread.php?t=47374 and check out the Advanced use of bitmaps.