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)

1  
AI > MemorizeArea2 {
2  
  float similarityThreshold = 0.9f;
3  
  int shrinkPixels = 1;
4  
  new L<RGBImage> images;
5  
  static ImageSurface is;
6  
  Pt lastLocation;
7  
8  
  void go {
9  
    // guess
10  
    
11  
    Rect guess = null;
12  
    if (lastLocation != null)
13  
      for (RGBImage blobImage : images) {
14  
        guess = foundImgToRect(rgbRawImageSearch_searchHereOnly(image, blobImage, similarityThreshold, lastLocation));
15  
        if (guess != null)
16  
          break;
17  
      }
18  
    
19  
    if (guess == null)
20  
      for (RGBImage blobImage : images) {
21  
        guess = foundImgToRect(rgbRawImageSearch_searchHereFirst(image, blobImage, similarityThreshold, null));
22  
        if (guess != null) {
23  
          lastLocation = new Pt(guess.x, guess.y);
24  
          break;
25  
        }
26  
      }
27  
28  
    // submit
29  
    
30  
    Rect solution = first(submit(guess));
31  
32  
    // learn
33  
    
34  
    bool correct = solution == null ? guess == null : guess != null && solution.contains(centerOfRect(guess));
35  
    if (solution != null && !correct) {
36  
      images.add(image.clip(growRect(solution, -shrinkPixels)));
37  
      if (visualize)
38  
        is = showZoomedImage(is, "Memorized Areas", mergeImagesHorizontally(images));
39  
    }
40  
  }
41  
}

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: 451 / 799
Version history: 8 change(s)
Referenced in: [show references]