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

26
LINES

< > BotCompany Repo | #1034422 // G22ColorWalker - G22Walker for IRGBImage

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

Transpiled version (6082L) is out of date.

1  
sclass G22ColorWalker > G22Walker<IRGBImage> {
2  
  // the ideal image it is looking for (set/get)
3  
  int[] rememberedImage; // size visionW*visionH
4  
  
5  
  // only works when we already have a rememberedImage
6  
  double scorePosition(Pt pos, IRGBImage image) {
7  
    int vx = pos.x-visionW, vy = pos.y-visionH, i = 0;
8  
    int diff = 0;
9  
    for y to visionH:
10  
      for x to visionW:
11  
        diff += colorDistance(rememberedImage[i++], image.getIntPixel(vx+x, vy+y));
12  
    ret -diff;
13  
  }
14  
  
15  
  bool hasRememberedImage() { ret rememberedImage != null; }
16  
  
17  
  void rememberImage(IRGBImage image) {
18  
    if (rememberedImage == null)
19  
      rememberedImage = new int[visionW*visionH];
20  
      
21  
    int vx = visionX1(), vy = visionY1(), i = 0;
22  
    for y to visionH:
23  
      for x to visionW:
24  
        rememberedImage[i++] = image.getIntPixel(vx+x, vy+y);
25  
  }
26  
}

Author comment

Began life as a copy of #1034119

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034422
Snippet name: G22ColorWalker - G22Walker for IRGBImage
Eternal ID of this version: #1034422/5
Text MD5: 1194fac1b46bdca2e2960d5e234ecb00
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-14 15:31:41
Source code size: 859 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 144 / 224
Version history: 4 change(s)
Referenced in: [show references]