@cardscan.ai/insurance-cardscan-react
Version:
A library that makes it easy to add health insurance card scanning to any web application
62 lines (61 loc) • 2.12 kB
TypeScript
import { DetectionResults } from "./types/Detector";
declare global {
interface Window {
cardDetector?: CardDetector;
}
}
declare class CardDetector {
static IMG_SIZE: number;
private model;
private customModelPath;
private model_name;
private cdnPath;
isFlippedSession: boolean;
private statusCallback;
private _modelState;
private laplaceFilter;
/** 5x5 Gaussian-like blur kernel for RGB images used in blur detection */
private blurKernel;
private embedModel;
private referenceEmbedding;
constructor(modelPath?: string);
setModelStatusCallback(callback: (state: string) => void): void;
private setModelState;
get modelState(): string;
private load_model;
private detectDistanceProblems;
private warm_model;
private tf_mem_log;
private setupEmbeddingModel;
private extractEmbedding;
private setReferenceCard;
private calculateCardSimilarity;
private processCardSimilarity;
cleanupEmbeddings(): void;
disposeAll(): void;
/**
* Detects image blur by comparing embeddings of original vs artificially blurred image.
*
* @param imgTensor - Input image tensor [1, 224, 224, 3]
* @returns Blur detection results or null if embeddings not available
*
* @description
* - Blur score: 0.0 (very sharp) to 1.0 (very blurry)
* - Sharp images change significantly when blurred → low score
* - Blurry images barely change when blurred more → high score
* - Current threshold: < 0.90 = sharp, ≥ 0.90 = blurry
*/
private detectBlur;
private prepare_results;
predict_image(canvas: HTMLCanvasElement, flipHorizontal: boolean, flipVertical: boolean): Promise<DetectionResults | null>;
}
declare class DetectorWrapper {
static image_size: number;
static get(): CardDetector;
static init(modelPath?: string): void;
static cleanUp(): void;
}
export declare class CardScanModel {
static warm(modelPath?: string): void;
}
export default DetectorWrapper;