react-native-executorch
Version:
An easy way to run AI models in React Native with ExecuTorch
33 lines (30 loc) • 846 B
text/typescript
import { symbols } from '../constants/ocr/symbols';
import { ResourceSource } from '../types/common';
import { OCRLanguage } from '../types/ocr';
import { BaseOCRController } from './BaseOCRController';
export class OCRController extends BaseOCRController {
protected async loadNativeModule(
detectorPath: string,
recognizerPath: string,
language: OCRLanguage
): Promise<any> {
return await global.loadOCR(
detectorPath,
recognizerPath,
symbols[language]
);
}
public load = async (
detectorSource: ResourceSource,
recognizerSource: ResourceSource,
language: OCRLanguage,
onDownloadProgressCallback?: (downloadProgress: number) => void
) => {
await this.internalLoad(
detectorSource,
recognizerSource,
language,
onDownloadProgressCallback
);
};
}