P6
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { acquireQvac, releaseQvac, loadAuxiliaryModel, qvacSdk, withQvacMaster } from './qvac-master.js';
|
||||
|
||||
export class QvacPerception {
|
||||
constructor({ model = process.env.JARVIS_OCR_MODEL || 'OCR_LATIN' } = {}) { this.model = model; this.modelId = null; }
|
||||
async ocr(image) {
|
||||
await acquireQvac();
|
||||
try {
|
||||
this.modelId ||= await loadAuxiliaryModel(this.model, {});
|
||||
const sdk = await qvacSdk();
|
||||
const result = await withQvacMaster(() => sdk.ocr({ modelId: this.modelId, image, stream: false }));
|
||||
return result.blocks;
|
||||
} finally { releaseQvac(); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user