Page 2 of 2 FirstFirst 12
Results 26 to 42 of 42

Thread: OCR-engine for OSR (Uptext).

  1. #26
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,691
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    So how does this work in mines where there is no shadow available?

    PS: Didn't know the OCR for OSR was broken that much? It used to work quite well, I believe... Guess Jagex keeps updating the engine... Previously it was mostly 'rt' that were connected...



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  2. #27
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    So how does this work in mines where there is no shadow available?

    PS: Didn't know the OCR for OSR was broken that much? It used to work quite well, I believe... Guess Jagex keeps updating the engine... Previously it was mostly 'rt' that were connected...
    Well, the filters were never done for OSR and even bigger I only just got you to add shadowed fonts

  3. #28
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    So how does this work in mines where there is no shadow available?
    It works fine in mines, even works over pure black. The shadows are available even there, they might not be visible due to blending in to background, but that does not matter.
    The engine first matches the chars color, if they match then it goes on an check if shadow also matches (if the background/shadow-points is darker then a given number).
    !No priv. messages please

  4. #29
    Join Date
    Aug 2012
    Location
    127.0.0.1
    Posts
    74
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Code:
    function ocr_IsTextMulti(TextArr:TStringArray; Chars:TCharsN): Boolean;
    What goes in the Chars parameter?

  5. #30
    Join Date
    Aug 2012
    Location
    127.0.0.1
    Posts
    74
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    So how does this work in mines where there is no shadow available?

    PS: Didn't know the OCR for OSR was broken that much? It used to work quite well, I believe... Guess Jagex keeps updating the engine... Previously it was mostly 'rt' that were connected...
    I've been using WaitUpTextMulti and since yesterday it hasn't worked at all. Not even for detecting a single character. :/

  6. #31
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Millenium View Post
    Code:
    function ocr_IsTextMulti(TextArr:TStringArray; Chars:TCharsN): Boolean;
    What goes in the Chars parameter?
    The example in the main post shows usage, read it. The Font which you have loaded goes in Chars parameter.
    !No priv. messages please

  7. #32
    Join Date
    Aug 2012
    Location
    127.0.0.1
    Posts
    74
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Quote Originally Posted by warpie View Post
    The example in the main post shows usage, read it. The Font which you have loaded goes in Chars parameter.
    Already read it, it still remains unclear.
    Code:
    begin
      ocr_LoadFont(AppPath + 'Fonts\UpChars07_s\', UpFont);
    
      ocr_FreeFont(UpFont);
    end.
    Is that all I need to load the font, but there is no explanation, is UpFont in ocr_LoadFont where the font discovered is stored? Or is it something different?

    EDIT: I added it in like this and it posts an access violation, so I guess that's the wrong way, with UpFont as a global variable and placed in that parameter. Also defined and freed in the exact same way you do.

  8. #33
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Millenium View Post
    Already read it, it still remains unclear.
    Code:
    begin
      ocr_LoadFont(AppPath + 'Fonts\UpChars07_s\', UpFont);
    
      ocr_FreeFont(UpFont);
    end.
    Is that all I need to load the font, but there is no explanation, is UpFont in ocr_LoadFont where the font discovered is stored? Or is it something different?

    EDIT: I added it in like this and it posts an access violation, so I guess that's the wrong way, with UpFont as a global variable and placed in that parameter. Also defined and freed in the exact same way you do.
    My example contains everything you must have. The font must also be in place, it is in the rar you downloaded), it should be placed in Fonts folder.

    IsUpTextMulti, IsUpText, GetUpTextEx:
    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');
    end;

    function RS_IsUpTextMulti(Text: TStringArray): Boolean;
    begin
      //update client
      ocr_SetClient(ClientATIA(7,7,500,16));
      //check for text
      Result := ocr_IsTextMulti(Text, 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
      //At beginning of script call to load the font from path in to UpFont:
      ocr_LoadFont(AppPath + 'Fonts\UpChars07_s\', UpFont);

      //usage in scipt:
      WriteLn(RS_IsUpTextMulti(['hello', 'world']);

      //At end of script call:
      ocr_FreeFont(UpFont);
    end.

    Access violation most likely due to the font not being loaded. That might be caused if you don't load the correct path: AppPath + 'Fonts\UpChars07_s\' - you need to have everything which is in the RAR extracted, this is as simple as extracting the rar directly in to Simba-folder.
    !No priv. messages please

  9. #34
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,691
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Millenium View Post
    I've been using WaitUpTextMulti and since yesterday it hasn't worked at all. Not even for detecting a single character. :/
    Well, that is possible. I never tested the OCR filters and engine against the ``new'' old runescape. It did work quite well before they split, though... Has anyone even looked at making filters? Beyond Olly?
    What I see warpie describe is basically what my engine in Simba does. So I'd be surprised if it wouldn't just work with the right colours and some minor tweaks.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  10. #35
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Well, that is possible. I never tested the OCR filters and engine against the ``new'' old runescape. It did work quite well before they split, though... Has anyone even looked at making filters? Beyond Olly?
    What I see warpie describe is basically what my engine in Simba does. So I'd be surprised if it wouldn't just work with the right colours and some minor tweaks.

    I tried it. Doesn't work:

    Simba Code:
    {$DEFINE SMART}
    {$i SRL/SRL.Simba}

    const
        ocr_Limit_High = 190;
        ocr_Limit_Med = 130;
        ocr_Limit_Low = 65;

        ocr_White = 16777215;  //correct.
        ocr_Green = 65280; //correct.
        ocr_Red = 131800;  //correct.
        ocr_Yellow = 65535; //correct.
        ocr_Blue = 13819407; //correct.
        ocr_ItemC = 3572697; //correct.
        ocr_ItemC2 = ocr_Red or ocr_Green; //dunno what this is.
        ocr_Purple = 8388736; //wrong.. shadow is black.. Fails completely if this changes even by +- 1.

        OF_LN = 256;
        OF_HN = -1;

    function load0(rl, rh, gl, gh, bl, bh, set_col: integer; is_text_color: boolean): TOCRFILTERDATA;
    begin
      result.r_low := rl;
      result.r_high := rh;
      result.g_low := gl;
      result.g_high := gh;
      result.b_low := bl;
      result.b_high := bh;
      result.set_col := set_col;
      result._type := 0;
      result.is_text_color:= is_text_color;
    end;

    procedure filter;
    var filterdata: TOCRFilterDataArray;
    begin
      setlength(filterdata, 9);

      filterdata[0] := load0(OCR_LIMIT_LOW, OF_HN, OF_LN, OCR_LIMIT_HIGH, OF_LN, OCR_LIMIT_HIGH, ocr_Blue, True);
      filterdata[1] := load0(OCR_LIMIT_LOW, OF_HN, OF_LN, OCR_LIMIT_HIGH, OCR_LIMIT_LOW, OF_HN, ocr_Green, True);
      filterdata[2] := load0(OCR_LIMIT_LOW, OF_HN, OF_LN, OCR_LIMIT_HIGH, OCR_LIMIT_LOW, OF_HN, ocr_Green, True);
      filterdata[3] := load0(OF_LN, OCR_LIMIT_HIGH, OF_LN, OCR_LIMIT_HIGH, OCR_LIMIT_LOW, OF_HN, ocr_Yellow, True);
      filterdata[4] := load0(OF_LN, OCR_LIMIT_HIGH, OCR_LIMIT_LOW, OF_HN, OCR_LIMIT_LOW, OF_HN, ocr_Red, True);
      filterdata[5] := load0(OF_LN, OCR_LIMIT_HIGH, OF_LN, OCR_LIMIT_LOW, OCR_LIMIT_LOW, OF_HN, ocr_Red, True);
      filterdata[6] := load0(OCR_LIMIT_HIGH + 10, OCR_LIMIT_MED, OF_LN, OCR_LIMIT_LOW - 10, 20, OF_HN, ocr_Green, True);
      filterdata[7] := load0(OCR_LIMIT_LOW, OF_HN, OF_LN, OCR_LIMIT_HIGH, OCR_LIMIT_LOW, OF_HN, ocr_Green, True);
      filterdata[8] := load0(OCR_LIMIT_LOW, OF_HN, OCR_LIMIT_LOW, OF_HN, OCR_LIMIT_LOW, OF_HN, ocr_Purple, False);

      rs_SetUpTextFilter(filterdata);
    end;

    var
      Smart: TSmart;
      BMP: Integer;
    begin
      Smart.Create(765, 503);
      MoveMouse(620, 233);
      filter;

      BMP := BitmapFromCLient(6, 6, 76, 24);
      FastReplaceColor(BMP, 1068104, 0);
      FastReplaceColor(BMP, 1268309, 0);
      FastReplaceColor(BMP, 1265742, 0);
      FastReplaceColor(BMP, 1267025, 0);
      FastReplaceColor(BMP, 1267020, 0);
      FastReplaceColor(BMP, 1268304, 0);
      DisplayDebugImgWindow(70, 18);
      DrawBitmapDebugImg(Bmp);

      SetTargetBitmap(bmp);
      writeln(rs_GetUpTextAt(0, 0));

      rs_ResetUpTextFilter;
    end.
    Last edited by Brandon; 12-22-2013 at 04:27 PM.
    I am Ggzz..
    Hackintosher

  11. #36
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Well, that is possible. I never tested the OCR filters and engine against the ``new'' old runescape. It did work quite well before they split, though... Has anyone even looked at making filters? Beyond Olly?
    What I see warpie describe is basically what my engine in Simba does. So I'd be surprised if it wouldn't just work with the right colours and some minor tweaks.
    I however do not do any filtering... it's not really needed.. I do no character splitting either.. I look trough the image as it is, from left to right. Don't match to specific colors either.
    I have not read completely trough what you do in yours, but there are some notable differences if I remember correctly.
    !No priv. messages please

  12. #37
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    I tried it. Doesn't work:
    That shouldn't work, rs_getUpTextAt is hardcoded to use the old upchars font (what rs3 is now), for osr you would have to do rs_GetUpTextAtEx with upchars07_s (i think)

  13. #38
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    That shouldn't work, rs_getUpTextAt is hardcoded to use the old upchars font (what rs3 is now), for osr you would have to do rs_GetUpTextAtEx with upchars07_s (i think)
    Well now that really sucks. Should fix the hardcoding :S


    Anyway, in that case, the code works then:

    http://i.imgur.com/ZQ6nrh5.png
    http://i.imgur.com/8KFixcT.png
    http://i.imgur.com/AvnEf0f.png

    And it's flawless.. Only thing is that it shows duplicates but that's nothing a regex can't fix. IIRC, GetUptext using a regex for matching anyway. Well it used to.
    I am Ggzz..
    Hackintosher

  14. #39
    Join Date
    Aug 2012
    Location
    127.0.0.1
    Posts
    74
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Quote Originally Posted by warpie View Post
    My example contains everything you must have. The font must also be in place, it is in the rar you downloaded), it should be placed in Fonts folder.

    IsUpTextMulti, IsUpText, GetUpTextEx:
    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');
    end;

    function RS_IsUpTextMulti(Text: TStringArray): Boolean;
    begin
      //update client
      ocr_SetClient(ClientATIA(7,7,500,16));
      //check for text
      Result := ocr_IsTextMulti(Text, 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
      //At beginning of script call to load the font from path in to UpFont:
      ocr_LoadFont(AppPath + 'Fonts\UpChars07_s\', UpFont);

      //usage in scipt:
      WriteLn(RS_IsUpTextMulti(['hello', 'world']);

      //At end of script call:
      ocr_FreeFont(UpFont);
    end.

    Access violation most likely due to the font not being loaded. That might be caused if you don't load the correct path: AppPath + 'Fonts\UpChars07_s\' - you need to have everything which is in the RAR extracted, this is as simple as extracting the rar directly in to Simba-folder.
    EDIT: It now runs without an access violation, thanks. But it still won't detect the text at all, the client bounds are included and it is loading the right text bmps, could it possibly be becuase of things in the background of the uptext area? like trees, fences ect.

  15. #40
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Millenium View Post
    EDIT: It now runs without an access violation, thanks. But it still won't detect the text at all, the client bounds are included and it is loading the right text bmps, could it possibly be becuase of things in the background of the uptext area? like trees, fences ect.
    Sorry, it's a late replay.. But honestly I don't see why it's not working. I have tested it in the worst possible places, and it works fine.
    Some regular noise should not be enough to upset the process.

    If I am going to guess where the problem lies (as you don't gave me enough info):
    > Wrong font (You are not using the font I added in the RAR).
    > Wrong bounds: the Y-axis need to be perfect.
    > Increase the height for the search area: ocr_SetClient(ClientATIA(7,7,500,25))..


    One of the above is the cause.. Bounds is correct for OSRS. Font is also correct for OSR. Height 16 also works for OSR..
    Honestly if you are trying to use this for OSR, my example should work as is. If you are trying it for some other game, or RSPS, please say so.
    !No priv. messages please

  16. #41
    Join Date
    Apr 2013
    Posts
    57
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    can you please tell me where i should extract this file? to which folder, thanks

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •