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)

AI > MemorizeBrightBLOB2 {
  float similarityThreshold = 0.9f;
  RGBImage blobImage;
  static ImageSurface is;

  static L<Rect> segment(RGBImage img) {
    ret autoSegment_blackBG(new BWImage(img), 3); // 2 is too small
  }

  void go {
    // guess
    
    L<Rect> myRects = segment(image);
    Rect guess = null;
    if (blobImage != null)
      guess = rgbFindMostSimilarClip(image, blobImage, myRects, similarityThreshold);
      
    // submit
    
    Rect solution = first(submit(guess));
    
    // learn
    
    if (blobImage == null && solution != null) {
      solution = autoCropOfRGBImage_blackBG(image, solution);
      Rect mine = smallestRectContaining(myRects, centerOfRect(solution));
      if (mine != null) {
        blobImage = image.clip(mine);
        is = showZoomedImage(is, "Memorized BLOB", blobImage);
      }
    }
  }
}

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: 446 / 1006
Version history: 3 change(s)
Referenced in: [show references]