UNPKG

koishi-plugin-ocr

Version:

本地 OCR 服务,调用 PaddleOCR 或 RapidOCR 进行识别(开坑中,一堆bug,勿用)

37 lines (36 loc) 953 B
import { Context, Schema, Service, Element } from 'koishi'; export declare const name = "ocr"; export interface Config { timeout?: number; exePath?: string; cwd?: string; args?: string[]; debug?: boolean; } export declare const Config: Schema<Config>; declare module 'koishi' { interface Context { ocr: Ocr; } } declare class Ocr extends Service { config: Config; static [Service.provide]: string; static inject: string[]; private ocr; private pid; private initialized; private ocrInitComplete; constructor(ctx: Context, config: Config); start(): Promise<void>; stop(): Promise<void>; isReady(): boolean; /** * 将Element元素转换为统一的base64格式 */ private getImageBase64; private fetchImageFromUrl; recognizeText(imageElement: Element): Promise<string>; } export declare function apply(ctx: Context, config: Config): void; export {};