Libraryless. Click here for Pure Java version (7511L/44K).
sclass ULetterbox1 implements IIIRecognizer<DoubleRect> { public void run( IProbabilisticScheduler scheduler, URecognizer.Cell cell, IVF1<DoubleRect> 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)); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032079 |
Snippet name: | ULetterbox1 - detect a letterbox |
Eternal ID of this version: | #1032079/20 |
Text MD5: | 250e7e9f4db95622ac35479d9cdfd4f7 |
Transpilation MD5: | 39588b0d6ec4fff99013eb7d20639678 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-11 13:48:47 |
Source code size: | 1276 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 229 / 424 |
Version history: | 19 change(s) |
Referenced in: | #1032085 - ULetterbox1 - detect a letterbox [pixelSum version, works!] #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |