Libraryless. Click here for Pure Java version (7505L/44K).
sclass ULetterbox1 implements IIIRecognizer<DoubleRect> { public void run( IProbabilisticScheduler scheduler, URecognizer.Cell cell, IVF1<DoubleRect> valueToAction) { var whole = cell; var middle = cell.slice(1, 1.0/3.0, 2.0/3.0); // We assume the border is black. // 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 wholePixelSum = whole.pixelSum(); double middlePixelSum = middle.pixelSum(); double ratio = doubleRatio(wholePixelSum, middlePixelSum); double borderPos = transformBetweenDoubleRanges_verbose(ratio, doubleRange(3, 1), doubleRange(0, 1/3.0)); printVars(+wholePixelSum, +middlePixelSum, +ratio, +borderPos); DoubleRect rect = cell.slice(1, borderPos, 1-borderPos).rawDoubleRect(); // No probabilities used. scheduler.schedule(1.0, () -> valueToAction.get(rect)); //var antiBorder = cell.slice(1, 1.0/8.0, 1-1/8.0); //var border = whole.pixelSum()-antiBorder.pixelSum(); } }
Began life as a copy of #1032079
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032085 |
Snippet name: | ULetterbox1 - detect a letterbox [pixelSum version, works!] |
Eternal ID of this version: | #1032085/1 |
Text MD5: | 3d6080ce16ba21f23f38a7bc1a5eac37 |
Transpilation MD5: | 4c5c1bd1668c4b321b1f7572016cb38a |
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:37:42 |
Source code size: | 1252 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 154 / 209 |
Referenced in: | -