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

41
LINES

< > BotCompany Repo | #1007099 // MemorizeArea2 (AI) - takes multiple images

JavaX fragment (include)

AI > MemorizeArea2 {
  float similarityThreshold = 0.9f;
  int shrinkPixels = 1;
  new L<RGBImage> images;
  static ImageSurface is;
  Pt lastLocation;

  void go {
    // guess
    
    Rect guess = null;
    if (lastLocation != null)
      for (RGBImage blobImage : images) {
        guess = foundImgToRect(rgbRawImageSearch_searchHereOnly(image, blobImage, similarityThreshold, lastLocation));
        if (guess != null)
          break;
      }
    
    if (guess == null)
      for (RGBImage blobImage : images) {
        guess = foundImgToRect(rgbRawImageSearch_searchHereFirst(image, blobImage, similarityThreshold, null));
        if (guess != null) {
          lastLocation = new Pt(guess.x, guess.y);
          break;
        }
      }

    // submit
    
    Rect solution = first(submit(guess));

    // learn
    
    bool correct = solution == null ? guess == null : guess != null && solution.contains(centerOfRect(guess));
    if (solution != null && !correct) {
      images.add(image.clip(growRect(solution, -shrinkPixels)));
      if (visualize)
        is = showZoomedImage(is, "Memorized Areas", mergeImagesHorizontally(images));
    }
  }
}

Author comment

Began life as a copy of #1006912

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007099
Snippet name: MemorizeArea2 (AI) - takes multiple images
Eternal ID of this version: #1007099/9
Text MD5: f4f7f1e47975e8d1a7d524bdc40bff91
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-03 01:22:17
Source code size: 1203 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 519 / 869
Version history: 8 change(s)
Referenced in: [show references]