sclass MultiLevelRecognizer3 // how big do we think the prototype is in the whole image // (percentage by height) L assumedPrototypeHeightPercentages = ll(70.0, 70.0/sqrt(2), 35.0, 35.0/sqrt(2), 17.0); // widths to scale camera image to transient L widths = ll(32, 64, 128); BWIntegralImage integralInputImage; new Map prototypeImages; // key = height new Map integralImages; // key = width new Map byPrototypeMap; class ByPrototype { } // constructors, addPrototype functions *() {} *(File imgFile) { integralInputImage = loadBWIntegralImage(imgFile); } void addPrototype(BufferedImage img) { prototypeImages.add(bwIntegralImage(img)); } void addPrototype(File imgFile) { addPrototype(loadImage2(imgFile)); } void addPrototypes(Iterable l) { fOr (O o : l) call(this, 'addPrototype, img); } void search(assumedPrototypeHeightPercentage, IVF1 onGuess) { img16 = scaleImageToWidth(inputImage, 16); int assumedPrototypeHeight16 = calculate(percentage, img16); prototype16 = resizeImageToHeight(prototype, assumedPrototypeHeight16); img32 = scaleImageToWidth(inputImage, 32); etc. double minSimilarity = 0.5; L> found16 = bwRawImageSearch(img16, prototype16, minSimilarity); sortScoredDesc_inPlace(found16); candidates16 = getVars(takeFirst(5, found16)); for (Rect candidate16 : candidates16) { candidate32 = scaleRect(candidate16, 2); } } }