Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #1005442 // Test alternative image comparator

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (5825L/38K/126K).

!752

static class MyComparator implements BWImageSectionComparator {
  int step = 5;
  public float compare(BWImage big, BWImage pat, int x, int y, float max) {
    int wp = pat.getWidth(), hp = pat.getHeight();
    int w = big.getWidth(), h = big.getHeight();
    float diff = 0;
    final int _step = step;
    for sx to _step:
      for sy to _step:
        for (int xx = sx; xx < wp; xx += _step)
          for (int yy = sy; yy < hp; yy += _step) {
            diff += abs(big.getPixel(x+xx, y+yy)-pat.getPixel(xx, yy));
            if (diff > max) ret max+1;
          }
    ret diff;
  }
}

concepts.

!include #1005393 // Marked Screenshot Classes

p {
  bwRawImageSearch_comparator = new MyComparator;
  BWImage screen = shootScreenBW();
  loadConceptsFrom("#1005389");
  float similarity = 0.999f;
  long start = now();
  for (MarkedClip clip) time {
    print("Searching: " + clip.description + "...");
    bwRawImageSearch_verbose = true;
    bwRawImageSearch(screen, clip.img, similarity);
  }
  done(start, "Total for " + n(countConcepts(MarkedClip), "images"));
}

Author comment

Began life as a copy of #1005395

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1005442
Snippet name: Test alternative image comparator
Eternal ID of this version: #1005442/1
Text MD5: 99b29c3c16f054897e6e76d88564cd1c
Transpilation MD5: 919946cc520f7f624a2d04e455f4a716
Author: stefan
Category: javax / ocr
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-18 18:50:17
Source code size: 1116 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 480 / 600
Referenced in: