SRL Archive - Non-RuneScape Scripts

bitmap tolerance not working?


Grand

2012-08-31 14:20:03

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

2012-08-31 14:24:51

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

2012-08-31 14:45:54

From: Grand
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

2012-08-31 15:35:59

From: masterBB
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

2012-08-31 15:38:08

From: Le Jingle
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

2012-08-31 15:41:28

Mind posting the bitmaps and piece of code, prefer < 30 lines, where you utilize them? It seems I don't fully understand you.

Grand

2012-08-31 16:08:20

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

2012-08-31 20:18:39

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

2012-08-31 21:11:30

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

2012-08-31 21:19:51

From: Grand
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

2012-08-31 21:22:13

i will try FindDeformedBitmapToleranceIn next if that other function doesn't work as i expected.
yep im running loops ..

thx

Grand

2012-09-02 18:37:50

well the FindDeformedBitmapToleranceIn works but its really slow. takes about 10 secs to find the 20X20 image on 800x600 window

riwu

2012-09-02 20:16:43

From: Grand
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

2012-09-02 23:14:38

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

2012-09-02 23:22:58

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.