!7 sclass Entry { RGB color; double maxDistance; } cmodule LearnActiveTab > DynSingleFunctionWithPrintLog { void doIt { LPair data = gatherMarkedThingInImages(listImageFiles( //ai_browserTabsTrainingDataDir() aiImageAlbumDir() ), "Active tab"); pnlStruct(data); int gridSize = 4; new LPair scaledImages; for (Pair p : data) { BufferedImage img = loadImage2(p.a); RGBImage rgb = RGBImage(scaleImageWithFactor(1.0/gridSize, img)); //showImage(rgb); add(scaledImages, pair(rgb, scaleRect(p.b, 1.0/gridSize))); } RandomAndVary_Record rav = new(Entry, color := new RandomAndVary_RGB, maxDistance := new RandomAndVary_Double); Entry e = rav.randomInstance(); print(e); int score = 0, count = 0; for (Pair p : scaledImages) { RGBImage img = p.a; int w = img.getWidth(), h = img.getHeight(); for y to h: for x to w: { bool detected = rgbDistance(img.getPixel(x, y), e.color) <= e.maxDistance; bool real = rectContains(p.b, x, y); score += detected == real ? 1 : 0; } count += w*h; } print("Score: " + doubleRatio(score, count)); } }