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:
+16
-3
@@ -4,6 +4,7 @@ import { startCamera, grabFrame, imageDataFromFile } from './camera.js';
|
|||||||
import { decodeBarcodes } from './barcode.js';
|
import { decodeBarcodes } from './barcode.js';
|
||||||
import { runOcr, isOcrAvailable } from './ocr.js';
|
import { runOcr, isOcrAvailable } from './ocr.js';
|
||||||
import { recognize } from './pipeline.js';
|
import { recognize } from './pipeline.js';
|
||||||
|
import { normalizeToken } from './spec.js';
|
||||||
import {
|
import {
|
||||||
createSession, proposeAssignment, commitAssignment,
|
createSession, proposeAssignment, commitAssignment,
|
||||||
undoLast, moveEntry, removeEntry, nextStackId,
|
undoLast, moveEntry, removeEntry, nextStackId,
|
||||||
@@ -88,9 +89,21 @@ async function processCapture(getFrame) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const frame = await getFrame();
|
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;
|
let stackId = plan.stackId;
|
||||||
|
|
||||||
if (confidence === 'red' || plan.kind === 'ambiguous') {
|
if (confidence === 'red' || plan.kind === 'ambiguous') {
|
||||||
@@ -118,7 +131,7 @@ async function processCapture(getFrame) {
|
|||||||
// Sitzung bucht das Ergebnis nicht mehr nach.
|
// Sitzung bucht das Ergebnis nicht mehr nach.
|
||||||
if (targetSession !== session) return;
|
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));
|
view.setLast(describeEntry(spec, entry.stackId));
|
||||||
syncView();
|
syncView();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user