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

46
LINES

< > BotCompany Repo | #1005386 // Raw Image Search in Screenshot [works]

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

Transpiled version (3030L) is out of date.

!752

lib 1003153 // magic.jar

import prophecy.common.image.ImageSurface;
import prophecy.common.image.RGBImage;
import prophecy.common.image.BWImage;

sclass FoundImg {
  Rectangle r;
  S imageID;
  float sim; // similarity in 0 to 1
  
  *() {}
  *(Rectangle *r, S *imageID, float *sim) {}
}

static new L<FoundImg> found;

static float correctness = 0.99f;

p {
  BWImage big = shootScreenBW();
  S patID = "#1004153";  // Search Button
  BWImage pat = loadBWImage(patID);
  
  long start = now();
  
  int wp = pat.getWidth(), hp = pat.getHeight();
  int w = big.getWidth(), h = big.getHeight();
  float maxError = (1f-correctness)*wp*hp;
  for (int y = 0; y < h-hp; y++)
    for (int x = 0; x < w-wp; x++) {
      float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError);
      if (diff <= maxError) {
        float sim = 1-diff/(wp*hp);
        print("Found at " + x + "/" + y + " [sim: " + formatDouble(sim, 4) + "]");
        Rectangle r = new Rectangle(x, y, wp, hp);
        found.add(new FoundImg(r, patID, sim));
        quickShowZoomedImage(big.clip(r).toRGB());
        //x += wp-1;
      }
    }
    
  done(start);
}

Author comment

Began life as a copy of #1004155

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: #1005386
Snippet name: Raw Image Search in Screenshot [works]
Eternal ID of this version: #1005386/1
Text MD5: ab181e2be1c1408433072aaae38aada3
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-13 20:38:07
Source code size: 1186 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 574 / 680
Referenced in: #1005396 - bwRawImageSearch