de.niklasfi.rx.ThrottlerFlowable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aocr Show documentation
Show all versions of aocr Show documentation
Swiftly add ocr layers to scanned pdf files.
Unfortunately existing open source ocr solutions (tesseract) pale in comparison with the ones commercially
available. The azure read api provides particularly good results. It is also easy to set up, but while it can
annotate text in images, there is no easy way to upload and ocr a full pdf document.
That is, until now. aocr provides an easy way to ocr full pdf documents.
package de.niklasfi.rx;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.functions.Function;
import org.reactivestreams.Publisher;
import java.time.temporal.TemporalAmount;
import java.util.concurrent.TimeUnit;
public class ThrottlerFlowable extends ThrottlerBase implements Function> {
public ThrottlerFlowable(TemporalAmount minInterval) {
super(minInterval);
}
@Override
public Publisher extends R> apply(R r) {
final var delayMs = getNextSlotDelay();
return Flowable.just(r).delay(delayMs, TimeUnit.MILLISECONDS);
}
}