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