Add store header OCR and market observation outbox

This commit is contained in:
2026-08-11 17:29:41 +03:00
parent d6e0ba466b
commit f87a65bb04
13 changed files with 1110 additions and 182 deletions
+14 -15
View File
@@ -16,15 +16,6 @@ export function resolveFieldRect(anchorPosition, field) {
};
}
export function resolveScreenRect(region, width, height) {
return {
x: Math.round(region.xRatio * width),
y: Math.round(region.yRatio * height),
width: Math.round(region.widthRatio * width),
height: Math.round(region.heightRatio * height),
};
}
export function normalizeOcrText(text) {
return text.replace(/\s+/g, " ").trim();
}
@@ -40,11 +31,19 @@ export function parseFieldValue(type, text) {
return digits ? Number(digits) : null;
}
export function parseMerchantText(text) {
return text
.split(/\r?\n/)
.map(normalizeOcrText)
.find(Boolean) ?? "";
export function parseStoreHeaderText(text) {
const normalized = normalizeOcrText(text);
const match = normalized.match(
/private\s*store.*?\b(buy|sell)\b.*?[-–—]\s*(.+)$/i,
);
if (!match?.[2]?.trim()) return null;
return {
side: match[1].toLowerCase(),
merchant: match[2].trim(),
rawText: normalized,
};
}
export function parseTooltipText(text) {
@@ -75,7 +74,7 @@ export function isCalibrationReady(calibration) {
calibration?.saleAnchor?.image &&
calibration.saleAnchor.width >= 4 &&
calibration.saleAnchor.height >= 4 &&
calibration.merchantRegion &&
calibration.storeHeaderRegion &&
calibration.tooltipSearchRegion &&
calibration.tooltipAnchor?.image &&
calibration.itemNameRegion &&