sclass ULetterbox1 implements IIIRecognizer { public void run( IProbabilisticScheduler scheduler, URecognizer.Cell cell, IVF1 valueToAction) { // We inquire 2 pixels from the image. var whole = cell; var middle = cell.slice(1, 1.0/3.0, 2.0/3.0); double wholeColor = whole!; double middleColor = middle!; // Inquiry done. In ULetterbox1, we assume the border is black. // (We could verify this by doing a third pixel query, // but surely that's too slow.!) // Here's the logic. // If the picture fills the whole screen, it will tend // to equal brightness everywhere. Thus whole = middle*3 // (because it's 3 times as large). // If only "middle" is not black, we have whole = middle. // Thus the border position can be estimated as: double ratio = doubleRatio(wholeColor, middleColor); double borderPos = transformBetweenDoubleRanges_verbose(ratio, 1, 1/3.0, 0, 1/3.0); printVars(+wholeColor, +middleColor, +ratio, +borderPos); DoubleRect rect = cell.slice(1, borderPos, 1-borderPos).rawDoubleRect(); // No probabilities used. scheduler.schedule(1.0, () -> valueToAction.get(rect)); } }