refactor
This commit is contained in:
parent
2d6a6bd3a1
commit
d80e723b94
28 changed files with 1801 additions and 352 deletions
|
|
@ -24,6 +24,10 @@ internal class WallColorTracker
|
|||
private readonly int[] _pendV = new int[256];
|
||||
private int _pendCount;
|
||||
|
||||
// Generation counter: prevents committing samples from a previous mode after Reset()
|
||||
private int _generation;
|
||||
private int _pendGeneration;
|
||||
|
||||
private const int MinSamples = 3000;
|
||||
private const double LoPercentile = 0.05;
|
||||
private const double HiPercentile = 0.95;
|
||||
|
|
@ -51,6 +55,7 @@ internal class WallColorTracker
|
|||
Array.Clear(_pendS);
|
||||
Array.Clear(_pendV);
|
||||
_pendCount = 0;
|
||||
_pendGeneration = _generation;
|
||||
|
||||
// Downsample: every 4th pixel in each direction (~10K samples for 400x400)
|
||||
for (var r = 0; r < hsv.Rows; r += 4)
|
||||
|
|
@ -72,6 +77,7 @@ internal class WallColorTracker
|
|||
public void Commit()
|
||||
{
|
||||
if (_pendCount == 0) return;
|
||||
if (_pendGeneration != _generation) return; // stale cross-mode samples
|
||||
|
||||
for (var i = 0; i < 180; i++) _hHist[i] += _pendH[i];
|
||||
for (var i = 0; i < 256; i++) _sHist[i] += _pendS[i];
|
||||
|
|
@ -144,5 +150,6 @@ internal class WallColorTracker
|
|||
_pendCount = 0;
|
||||
AdaptedLo = null;
|
||||
AdaptedHi = null;
|
||||
_generation++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue