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

35
LINES

< > BotCompany Repo | #1020130 // WebCam To Image Buckets (OK, but doesn't save to disk)

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (15856L/110K).

!7

module WebCamToImageBuckets > DynPrintLogAndEnabled {
  transient int width = 16;
  transient float minScore = 0.99f;
  transient int maxImages = 1000;
  transient BufferedImage lastImage;
  transient new LL<RGBImage> buckets;
  transient int images;
  
  S switchableFields() { ret 'width; }
  
  start { doEvery(1000, rstUpdate()); }
  
  void update {
    if (!enabled || images >= maxImages) ret;
    final BufferedImage img = dm_webCamImage();
    afterwards { lastImage = img }
    if (img == null || img == lastImage) ret;
    RGBImage pat = RGBImage(resizeImage(img, width));
    long time = sysNow();
    new Best<Int> best;
    for i over buckets: {
      Pair<RGBImage, Float> p = rgbMostSimilarImage(pat, buckets.get(i), 0);
      best.put(i, p.b);
    }
    done2_always_timeFirst(time, "Images/buckets: " + images + "/" + l(buckets) + ". Best bucket: " + best + " (" + map l(buckets) + ")");
    ++images;
    if (best.score() < minScore) {
      print("Opening new bucket");
      buckets.add(ll(pat));
    } else
      buckets.get(best!).add(pat);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020130
Snippet name: WebCam To Image Buckets (OK, but doesn't save to disk)
Eternal ID of this version: #1020130/11
Text MD5: 98adc5773e8441e29d668a72bfa80e7c
Transpilation MD5: 00e44082d26c61f9480bd1a6d96f70a6
Author: stefan
Category: javax / image recognition
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-08 23:41:58
Source code size: 1107 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 314 / 429
Version history: 10 change(s)
Referenced in: [show references]