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).

1  
!7
2  
3  
module WebCamToImageBuckets > DynPrintLogAndEnabled {
4  
  transient int width = 16;
5  
  transient float minScore = 0.99f;
6  
  transient int maxImages = 1000;
7  
  transient BufferedImage lastImage;
8  
  transient new LL<RGBImage> buckets;
9  
  transient int images;
10  
  
11  
  S switchableFields() { ret 'width; }
12  
  
13  
  start { doEvery(1000, rstUpdate()); }
14  
  
15  
  void update {
16  
    if (!enabled || images >= maxImages) ret;
17  
    final BufferedImage img = dm_webCamImage();
18  
    afterwards { lastImage = img }
19  
    if (img == null || img == lastImage) ret;
20  
    RGBImage pat = RGBImage(resizeImage(img, width));
21  
    long time = sysNow();
22  
    new Best<Int> best;
23  
    for i over buckets: {
24  
      Pair<RGBImage, Float> p = rgbMostSimilarImage(pat, buckets.get(i), 0);
25  
      best.put(i, p.b);
26  
    }
27  
    done2_always_timeFirst(time, "Images/buckets: " + images + "/" + l(buckets) + ". Best bucket: " + best + " (" + map l(buckets) + ")");
28  
    ++images;
29  
    if (best.score() < minScore) {
30  
      print("Opening new bucket");
31  
      buckets.add(ll(pat));
32  
    } else
33  
      buckets.get(best!).add(pat);
34  
  }
35  
}

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: 445 / 579
Version history: 10 change(s)
Referenced in: [show references]