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

34
LINES

< > BotCompany Repo | #1024988 // AOA_CompareImagesToProtos

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

Libraryless. Click here for Pure Java version (3620L/22K).

sclass AOA_CompareImagesToProtos implements Steppable {
  new Map<S, BWImage> images;
  new Map<S, BWImage> protos;
  
  new AllOnAll<S> allOnAll;
  new Map<S, Scored<S>> bestProtoForImage;
  new Map<S, Scored<S>> bestImageForProto;
  
  void addImages(Map<S, BWImage> images) {
    putAll(this.images, images);
    for (S id : keys(images)) allOnAll.newA(id);
  }
  
  void addProtos(Map<S, BWImage> protos) {
    putAll(this.protos, protos);
    for (S id : keys(protos)) allOnAll.newB(id);
  }
  
  public bool step() {
    PairS p = allOnAll.next();
    if (p == null) false;
    BWImage img1 = images.get(p.a);
    BWImage img2 = protos.get(p.b);
    Scored<S> bestProto = bestProtoForImage.get(p.a);
    float sim = bwImageSimilarityResized(img1, img2, score(bestProto));
    scoredMapPut(bestProtoForImage, p.a, p.b, sim);
    scoredMapPut(bestImageForProto, p.b, p.a, sim);
    true;
  }
  
  Map<S, Double> scoresForProtos() {
    ret mapValues doubleScore(bestImageForProto);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024988
Snippet name: AOA_CompareImagesToProtos
Eternal ID of this version: #1024988/8
Text MD5: 5878cca9b168ee38cbb375085117632c
Transpilation MD5: 2a758fbb17634ab7c38fc9a0b829cb2a
Author: stefan
Category: javax / visual bots
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-31 23:47:40
Source code size: 1024 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 254 / 680
Version history: 7 change(s)
Referenced in: [show references]