Deprecated use https://villavu.com/forum/showthread.php?t=111156
Someone told me that the current OCR-engine for UpText is OSR was somewhat unreliable, so I figured I could make a little something. So I made a plugin wrapping up my RS OCR-engine, hoping that somebody would find use for it. It should be noted that this is for RS shadow fonts only.
New build: Support for PS!
I did not do many tests where I compared it to the current GetUpText found in SRL-OSR, but a few. Performance varies a bit (could still use some tweaking), but should generally be more robust the what is now. Here are some BAD CASE SCENARIO examples of performance:
Code:
[NEW] Talk-to Duke Horacio / 7 more options
[OLD] TNlk-t# - @uke Horaci
[NEW] Walk here / 1 more options
[OLD] Walk here r '
[NEW] Walk here chaos combos (level-63) / 3 more options .
[OLD] Walk here c
[NEW] Open Large door / 2 more options
[OLD] @' 0@-'-r Larg e door
[NEW] Attack Man (le..el-2) / 4 more options
[OLD] @BE[ llan
[NEW] Walk here lady vx (level-54) / 3 more options
[OLD] Walk here l
[NEW] Adjust Screen Brightness
[OLD] Ad'lust Scr
[NEW] Talk-to Osman / 2 more options
[OLD] Talk-t@ Dsman7r
[NEW] Walk here A A R 0 N (level-95) / 3 more options '
[OLD] Walk here F
[NEW] Talk-to Al the Camel / 2 more options
[OLD] Talk-to Al lh' i'l
Quite decent, but not perfect. Usually it does read the text quite flawlessly.
It's speed is very optimal, running in just a few ms usually around 2-10ms.
The functions which are exposed to the user:
Simba Code:
//Import / Load the uptext font (must have shadows).
procedure ocr_LoadFont(FontPath:String; var Font:TCharsN);
//Release the fonts, should be called at end of script.
procedure ocr_FreeFont(var Font:TCharsN);
//Important, must be used before everytime you try to read the uptext (see example)
procedure ocr_SetClient(ATIA:T2DIntegerArray);
//Makes it simple.. Everything is hardcoded in the engine
function ocr_ReadText(Font:TCharsN): AnsiString;
//Read text in client, allows to modify spacers.
function ocr_ReadTextEx(Font:TCharsN, SpaceMod,MaxSpace:Integer): AnsiString;
//Reads the text in the client and directly stops if "EndAt"-string is matched, it makes it a bit faster, and removes some "end noise".
function ocr_ReadTextEnd(Font:TCharsN, SpaceMod,MaxSpace:Integer; EndAt:String): AnsiString; overload;
//Simple regular IsUpText
function ocr_IsText(Text:String; Chars:TCharsN): Boolean;
//Same/comparable to IsUpTextMulti
function ocr_IsTextMulti(TextArr:TStringArray; Chars:TCharsN): Boolean;
//IsTextEx matches the string by also allowing you to use the "*"-sign to make it "skip".
//IE: TextPtrn := 'Attack * (level*)'; which would result True if a text like: 'Attack Giant Rat (level-19)' was found.
function ocr_IsTextEx(TextPtrn:String; Sensitive:Boolean; Chars:TCharsN): Boolean;
Example usage:
Simba Code:
program new;
{$loadlib rstext.dll}
var UpFont:TCharsN;
function ClientATIA(x1,y1,width,height: Integer): T2DIntegerArray;
var bmp:Integer;
begin
bmp := BitmapFromClient(x1,y1,x1+width,y1+height);
Result := GetBitmapAreaColors(bmp, 0,0,width,height);
FreeBitmap(bmp);
end;
function RS_GetUpText2: String;
begin
ocr_SetClient(ClientATIA(7,7,500,16));
Result := ocr_ReadTextEnd(UpFont,0,200,'more options');
//Result := ocr_ReadText(UpFont);
end;
function RS_IsUpText(Text:String): Boolean;
begin
ocr_SetClient(ClientATIA(7,7,500,16));
Result := ocr_IsTextEx(Text, True, UpFont);
end;
var
t,i: Integer;
text: String;
begin
ocr_LoadFont(AppPath + 'Fonts\UpChars07_s\', UpFont);
WriteLn(RS_GetUpText2);
ocr_FreeFont(UpFont);
end.
If there should be any problems, please give me some feedback with relative info (EG: Where you whare when it happened).
A thanks to Janilabo for making am string functions used internally, and Olly for doing some extra testing!