Warning: session_start(): open(/var/lib/php/sessions/sess_o864cav3tu99q9prf1u1kg24kp, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
static int topTenSize = 1000;
static MultiSetAndTopTen mstt; // holds md5
p {
mstt = new MultiSetAndTopTen(
l_persistentTreeMap("Images + count"),
l_persistentList("Top Ten"));
f (l(mstt.topTen() != topTenSize) mstt.newTopTenSize(topTenSize);
thread "Collect" {
repeat with sleep 10 {
collectIt();
}
}
showButtons("Show Top Ten", f showTopTen);
}
svoid collectIt {
print("Collecting...");
BWImage img = shootScreenBW();
L segments = autoSegment(img);
for (Rect r : segments) {
RGBImage clip = img.clip(r).toRGB();
S md5 = rgbMD5(clip);
mstt.add(md5);
File f = imgFile(md5);
if (!f.exists())
savePNG(f, clip);
}
print(n(segments, "segment") + " on screen. " + n(mstt.numEntries(), "image") + " in DB. " + n(mstt.numOccurrences(), "occurrence") + " recorded.");
}
static File imgFile(S md5) {
ret getProgramFile(md5 + ".png");
}
svoid showTopTen {
showTable(map(mstt.topTen(), func(S md5) {
litorderedmap("Image" := loadBufferedImageOpt(imgFile(md5)), "MD5" := md5, "Occurrences" := mstt.get(md5))
}), "Top Ten");
}