!7 replace Submission with BackgroundPlus. // TODO: print log problem cmodule2 BoxFinder > DynImageSurfaceAndEnabled { switchable int imageSize = 1000; transient Pair actual, recognized; transient BWIntegralImage ii; transient ImageSurface isReconstructed; transient S status; transient new Scorer scorer; visual northAndCenterWithMargin( jhgrid(super, jscroll_centered(isReconstructed = imageSurface())), dm_label status()); start { thread "Calc" enter { while (true) { if (deleted()) ret; if (!enabled) sleepSeconds(1); pcall { makeImage(); recognize(); score(); reconstruct(); status(); } } } } void makeImage { Pt a = randomPt(imageSize), b = randomPt(imageSize); LineWithColor line = new(a, b, Color.black, 1); BufferedImage img = renderBackgroundPlusLines(imageSize, imageSize, new BackgroundPlus(Color.white, line)); ii = new(img); actual = sortedPair(a, b); } void recognize { recognized = sortedPair(bwii_detectSingleLine(ii)); } void score { scorer.add(eq(actual, recognized)); } void reconstruct { renderBackgroundPlusLines(imgW, imgH, new BackgroundPlus(Color.white, line); BufferedImage img = renderBackgroundPlusLines(imageSize, imageSize, new BackgroundPlus(Color.white, LineWithColor(actual.a, actual.b, Color.black, 1))); isReconstructed.setImage(img); } void status { setField(status := str(scorer)); } }