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

50
LINES

< > BotCompany Repo | #1035852 // IG22MasksHolder - interface to masks holders

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

Libraryless. Click here for Pure Java version (29432L/179K).

interface IG22MasksHolder<A> {
  replace Mask with IG22Mask<A>.
  
  WidthAndHeight maskSize();
  L<Image2B> maskImages();
  //LPair<Image2B, A> maskImagesWithLabels();
  L<? extends Mask> masks();
  G22GhostImage ghost();
  double certainty();
  default int nMasks() { ret l(masks()); }
  
  default S renderCountAndCertainty() {
    ret main nMasks(nMasks()) + " with c=" + formatDouble3(certainty());
  }
  
  default bool canSplit() { ret nMasks() > 1; }
  
  default L<IG22MasksHolder<A>> subHolders() { null; }
  default void transformSubHolders(IF1<IG22MasksHolder<A>> f) {}
  
  default PStackComputable<Void> findSimilarMasks(G22FindSimilarMasksTask<A> task) {
    ret new FindSimilarMasks_BruteForce<A>(this, task);
  }

  srecord noeq FindSimilarMasks_BruteForce<A>(IG22MasksHolder<A> masksHolder, G22FindSimilarMasksTask<A> task) extends PStackComputableWithStep<Void> {
    Mask maskBeingTested;
    
    toString { ret formatFunctionCall(shortClassName(this), masksHolder, "step=" + step); }
    
    void step(IPStack stack) {
      if (task.ended()) ret with stack.ret();
      if (step == 0) {
        ++step;
        stack.optionsOrReturn(this, map(masksHolder.masks(), mask ->
          self -> self.maskBeingTested = mask));
      } else {
        task.tryMask(maskBeingTested);
        stack.ret();
      }
    }
  }
  
  <B> IG22MasksHolder<B> cloneTreeWithLabelTransform(IF1<A, B> transformLabel);
  
  default L<A> labels() { ret map(masks(), -> .label()); }
  
  default Image2B regionToMaskImage(IImageRegion region) {
    ret region == null ?: g22standardRegionToMaskImage(region, maskSize());
  }
}

Author comment

Began life as a copy of #1035849

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035852
Snippet name: IG22MasksHolder - interface to masks holders
Eternal ID of this version: #1035852/44
Text MD5: 967e3b71dce6528418e81d880297cf11
Transpilation MD5: 64c3d5f7bd55d908281d4ef5ee30aa5a
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-02-13 22:56:55
Source code size: 1675 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 221 / 417
Version history: 43 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)