kopia lustrzana https://github.com/xdsopl/robot36
reduce pixel width for fast scan lines
rodzic
7766ee26ba
commit
e1cebdab3c
|
@ -66,7 +66,7 @@ public class Decoder {
|
||||||
double scanLineToleranceSeconds = 0.001;
|
double scanLineToleranceSeconds = 0.001;
|
||||||
scanLineToleranceSamples = (int) Math.round(scanLineToleranceSeconds * sampleRate);
|
scanLineToleranceSamples = (int) Math.round(scanLineToleranceSeconds * sampleRate);
|
||||||
scanLineReserveSamples = sampleRate;
|
scanLineReserveSamples = sampleRate;
|
||||||
rawMode = new RawDecoder();
|
rawMode = new RawDecoder(sampleRate);
|
||||||
lastMode = rawMode;
|
lastMode = rawMode;
|
||||||
lastScanLineSamples = (int) Math.round(0.150 * sampleRate);
|
lastScanLineSamples = (int) Math.round(0.150 * sampleRate);
|
||||||
syncPulse5msModes = new ArrayList<>();
|
syncPulse5msModes = new ArrayList<>();
|
||||||
|
|
|
@ -8,8 +8,12 @@ package xdsopl.robot36;
|
||||||
|
|
||||||
public class RawDecoder implements Mode {
|
public class RawDecoder implements Mode {
|
||||||
private final ExponentialMovingAverage lowPassFilter;
|
private final ExponentialMovingAverage lowPassFilter;
|
||||||
|
private final int smallPictureMaxSamples;
|
||||||
|
private final int mediumPictureMaxSamples;
|
||||||
|
|
||||||
RawDecoder() {
|
RawDecoder(int sampleRate) {
|
||||||
|
smallPictureMaxSamples = (int) Math.round(0.125 * sampleRate);
|
||||||
|
mediumPictureMaxSamples = (int) Math.round(0.175 * sampleRate);
|
||||||
lowPassFilter = new ExponentialMovingAverage();
|
lowPassFilter = new ExponentialMovingAverage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +36,10 @@ public class RawDecoder implements Mode {
|
||||||
if (syncPulseIndex < 0 || syncPulseIndex + scanLineSamples > scanLineBuffer.length)
|
if (syncPulseIndex < 0 || syncPulseIndex + scanLineSamples > scanLineBuffer.length)
|
||||||
return false;
|
return false;
|
||||||
int horizontalPixels = pixelBuffer.width;
|
int horizontalPixels = pixelBuffer.width;
|
||||||
|
if (scanLineSamples < smallPictureMaxSamples)
|
||||||
|
horizontalPixels /= 2;
|
||||||
|
if (scanLineSamples < mediumPictureMaxSamples)
|
||||||
|
horizontalPixels /= 2;
|
||||||
lowPassFilter.cutoff(horizontalPixels, 2 * scanLineSamples, 2);
|
lowPassFilter.cutoff(horizontalPixels, 2 * scanLineSamples, 2);
|
||||||
lowPassFilter.reset();
|
lowPassFilter.reset();
|
||||||
for (int i = 0; i < scanLineSamples; ++i)
|
for (int i = 0; i < scanLineSamples; ++i)
|
||||||
|
@ -43,6 +51,7 @@ public class RawDecoder implements Mode {
|
||||||
int position = (i * scanLineSamples) / horizontalPixels;
|
int position = (i * scanLineSamples) / horizontalPixels;
|
||||||
pixelBuffer.pixels[i] = ColorConverter.GRAY(scratchBuffer[position]);
|
pixelBuffer.pixels[i] = ColorConverter.GRAY(scratchBuffer[position]);
|
||||||
}
|
}
|
||||||
|
pixelBuffer.width = horizontalPixels;
|
||||||
pixelBuffer.height = 1;
|
pixelBuffer.height = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue