!7 cmodule LearnDogsVsCats > DynSingleFunctionWithPrintLog { /*switchable*/ transient File dir = userDir("dev/dogs-vs-cats/train"); LPair scaledImages; transient int eyeWidth = 16; start { if (!dm_osBooting()) thread { doIt(); } } void doIt { // load scaled down test images L allImageFiles = listImageFiles(dir); Map> markingsMap = new Map; for (File f : allImageFiles) mapPutIfNemptyValue(markingsMap, f, loadImageFileMarkings(f)); pnlStruct(markingsMap); if (empty(markingsMap)) ret with print("No marked images found in " + dir); new Map iImages; for (File f : keys(markingsMap)) iImages.put(f, BWIntegralImage(f)); print("Have " + n2(iImages, "integral image") + ", total size: " + str_toM(deepObjectSize(iImages))); new L allEyeImages; for (File f : keys(markingsMap)) if (fileNameContains(f, "cat")) for (Pair mark : markingsMap.get(f)) if (eqic(mark.b, "eye")) allEyeImages.add(bwResizeSmooth(iBWImageToBWImage(clipIBWImage(virtualScaledIntegralImageBW(iImages.get(f)), mark.a)), eyeWidth)); showImage(mergeBWImagesVertically(allEyeImages)); //showImage(scaleDownUsingIntegralImageBW(random(values(iImages)), 256)); //showImage(iBWImageToBWImage(virtualScaledIntegralImageBW(random(values(iImages)), 256))); //File f = random(allImageFiles); File f = firstFileWithName(allImageFiles, "cat.2516.jpg"); print(f); BWIntegralImage ii = new(f); IBWImage scaled = virtualScaledIntegralImageBW(ii, 256); float similarity = 0; FoundImg found = null; ImageSurface is = showImage(iBWImageToBWImage(scaled)); Rect r = null; for (BWImage pat : allEyeImages) { found = or(bwImageSearch_best_virtualBig(scaled, pat, found == null ? 0f : found.sim), found); if (neq(foundImgRect(found), r)) { r = foundImgRect(found); overlaySelectionsOnImageSurface(is, ll(r)); } } print(found); } }