Verdrahte Barcode-Codeabgleich und OCR-Kurzschluss in main.js

processCapture() reicht der Pipeline jetzt eine isKnownCode-Abhaengigkeit
herein, die gegen die Codes der Stapel der aktuellen Sitzung prueft, und
gibt die von recognize() gelieferten Rohcodes an proposeAssignment und
commitAssignment weiter, damit ein bereits bekannter Barcode-Inhalt die
Stapelzuordnung entscheidet.
This commit is contained in:
vchuser
2026-07-29 09:05:29 +02:00
parent 61dde3eb08
commit c9084830b8
+16 -3
View File
@@ -4,6 +4,7 @@ import { startCamera, grabFrame, imageDataFromFile } from './camera.js';
import { decodeBarcodes } from './barcode.js';
import { runOcr, isOcrAvailable } from './ocr.js';
import { recognize } from './pipeline.js';
import { normalizeToken } from './spec.js';
import {
createSession, proposeAssignment, commitAssignment,
undoLast, moveEntry, removeEntry, nextStackId,
@@ -88,9 +89,21 @@ async function processCapture(getFrame) {
try {
const frame = await getFrame();
const { spec, source, confidence } = await recognize(frame, { decodeBarcodes, runOcr });
// Ist einer der gleich gelesenen Codes bereits einem Stapel dieser
// Sitzung bekannt, kann die Pipeline die bis zu 20 Sekunden dauernde
// Texterkennung ueberspringen (siehe recognize() in pipeline.js).
const isKnownCode = (code) => {
const normalized = normalizeToken(code);
return targetSession.stacks.some(
(stack) => Array.isArray(stack.codes) && stack.codes.includes(normalized),
);
};
const { spec, source, confidence, codes } = await recognize(
frame,
{ decodeBarcodes, runOcr, isKnownCode },
);
const plan = proposeAssignment(targetSession, spec);
const plan = proposeAssignment(targetSession, spec, codes);
let stackId = plan.stackId;
if (confidence === 'red' || plan.kind === 'ambiguous') {
@@ -118,7 +131,7 @@ async function processCapture(getFrame) {
// Sitzung bucht das Ergebnis nicht mehr nach.
if (targetSession !== session) return;
const entry = commitAssignment(targetSession, spec, source, stackId);
const entry = commitAssignment(targetSession, spec, source, stackId, codes);
view.setLast(describeEntry(spec, entry.stackId));
syncView();