@cardscan.ai/insurance-cardscan-react
Version:
A library that makes it easy to add health insurance card scanning to any web application
61 lines (60 loc) • 2.06 kB
TypeScript
export type Thresholds = {
cardThreshold: number;
laplacianThreshold: number;
};
export type ScanAttempt = {
timestamp: number;
elapsed: number;
cardScore: number;
laplacianValue: number;
captured: boolean;
adjustmentCount: number;
thresholds: Thresholds;
side: Side;
};
export type Side = "front" | "back";
export type AdaptiveThresholdProps = {
initialCardThreshold?: number;
initialLaplacianThreshold?: number;
minCardThreshold?: number;
minLaplacianThreshold?: number;
backsideMultiplier?: number;
stabilizationPeriod?: number;
adjustmentInterval?: number;
reductionPerInterval?: number;
maxAdjustments?: number;
minAttemptsToReduceFront?: number;
minAttemptsToReduceBack?: number;
};
export default class AdaptiveThreshold {
private initialThresholds;
currentThresholds: Thresholds;
private intervalId?;
private stabilizationPeriod;
private adjustmentInterval;
private maxAdjustments;
private minAttemptsToReduceFront;
private minAttemptsToReduceBack;
private backsideMultiplier;
private minCardThreshold;
private minLaplacianThreshold;
private scanAttempts;
private scanStartTime;
private isScanning;
private adjustmentCount;
private currentSide;
private adjustmentMultiplier;
private stabilizationTimerId?;
private didCapture;
private intervalCount;
private now;
private frontSuccessThresholds?;
constructor({ initialCardThreshold, adjustmentInterval, backsideMultiplier, initialLaplacianThreshold, minCardThreshold, minLaplacianThreshold, reductionPerInterval, stabilizationPeriod, maxAdjustments, minAttemptsToReduceFront, minAttemptsToReduceBack, }: AdaptiveThresholdProps);
startSession(side?: Side): void;
getCurrent(): Thresholds;
stopSession(): void;
recordAttempt(cardScore: number, laplacian: number, captured: boolean): void;
private reduce;
private tick;
private clearTimers;
}