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

33
LINES

< > BotCompany Repo | #1006905 // MemorizeBrightBLOB2 (AI) - with similarity threshold (can handle empty solutions)

JavaX fragment (include)

1  
AI > MemorizeBrightBLOB2 {
2  
  float similarityThreshold = 0.9f;
3  
  RGBImage blobImage;
4  
  static ImageSurface is;
5  
6  
  static L<Rect> segment(RGBImage img) {
7  
    ret autoSegment_blackBG(new BWImage(img), 3); // 2 is too small
8  
  }
9  
10  
  void go {
11  
    // guess
12  
    
13  
    L<Rect> myRects = segment(image);
14  
    Rect guess = null;
15  
    if (blobImage != null)
16  
      guess = rgbFindMostSimilarClip(image, blobImage, myRects, similarityThreshold);
17  
      
18  
    // submit
19  
    
20  
    Rect solution = first(submit(guess));
21  
    
22  
    // learn
23  
    
24  
    if (blobImage == null && solution != null) {
25  
      solution = autoCropOfRGBImage_blackBG(image, solution);
26  
      Rect mine = smallestRectContaining(myRects, centerOfRect(solution));
27  
      if (mine != null) {
28  
        blobImage = image.clip(mine);
29  
        is = showZoomedImage(is, "Memorized BLOB", blobImage);
30  
      }
31  
    }
32  
  }
33  
}

Author comment

Began life as a copy of #1006892

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006905
Snippet name: MemorizeBrightBLOB2 (AI) - with similarity threshold (can handle empty solutions)
Eternal ID of this version: #1006905/4
Text MD5: 18ab91038e1ad8aa12504176c33f1164
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-14 23:26:15
Source code size: 887 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 448 / 1009
Version history: 3 change(s)
Referenced in: [show references]