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

17
LINES

< > BotCompany Repo | #1027280 // bwImageSearch_onFound

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5142L/33K).

1  
svoid bwImageSearch_onFound(BWImage big, BWImage pat, float minSimilarity, IVF2<Rect, Double> onFound) {
2  
  int wp = pat.getWidth(), hp = pat.getHeight();
3  
  int w = big.getWidth(), h = big.getHeight();
4  
  float maxError = (1f-minSimilarity)*wp*hp;
5  
  bigloop: for (int y = 0; y < h-hp; y++)
6  
    for (int x = 0; x < w-wp; x++) {
7  
      float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError);
8  
      if (diff <= maxError) {
9  
        maxError = diff;
10  
        double sim = 1-diff/(wp*hp);
11  
        Rect r = new Rect(x, y, wp, hp);
12  
        onFound.get(r, sim);
13  
        ping();
14  
        //if (diff == 0) break bigloop;
15  
      }
16  
    }
17  
}

Author comment

Began life as a copy of #1006412

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027280
Snippet name: bwImageSearch_onFound
Eternal ID of this version: #1027280/3
Text MD5: 2e892a5a69a7ca81e5f54b7571011f3e
Transpilation MD5: 73fe3e3bc14579e6d8dcb05c549f39a0
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-29 16:01:44
Source code size: 646 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 276
Version history: 2 change(s)
Referenced in: [show references]