Improve OCR preprocessing and normalize merchant names
This commit is contained in:
@@ -12,6 +12,13 @@ import {
|
||||
rectFromPoints,
|
||||
resolveFieldRect,
|
||||
} from "../src/parser.js";
|
||||
import { isWhiteTextPixel } from "../src/vision.js";
|
||||
|
||||
test("keeps white text pixels and removes colored or dark pixels", () => {
|
||||
assert.equal(isWhiteTextPixel(220, 215, 195), true);
|
||||
assert.equal(isWhiteTextPixel(210, 165, 80), false);
|
||||
assert.equal(isWhiteTextPixel(120, 120, 120), false);
|
||||
});
|
||||
|
||||
test("keeps only letters, digits and spaces in OCR item names", () => {
|
||||
assert.equal(cleanItemName(" ~~ Soulshot: S-grade ` "), "Soulshot S grade");
|
||||
@@ -139,5 +146,6 @@ test("parses trade side and merchant from the store header", () => {
|
||||
merchant: "Dwa",
|
||||
rawText: "Private Store({Sell) - Dwa",
|
||||
});
|
||||
assert.equal(parseStoreHeaderText("Private Store(Buy) - Hik vision")?.merchant, "Hikvision");
|
||||
assert.equal(parseStoreHeaderText("Items on Sale"), null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user