[object Object]

← back to Dw Photo Capture

feat: hone in on the text — OCR now reads a centered, upscaled ROI (guide-box region, 5:2, up to 2x) instead of the whole frame, so small printed SKUs read sharper; full frame retained for logo/pattern match

5483a67494baedc368ed3815cc7678c042c11b3a · 2026-07-06 16:01:03 -0700 · Steve Abrams

Files touched

Diff

commit 5483a67494baedc368ed3815cc7678c042c11b3a
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jul 6 16:01:03 2026 -0700

    feat: hone in on the text — OCR now reads a centered, upscaled ROI (guide-box region, 5:2, up to 2x) instead of the whole frame, so small printed SKUs read sharper; full frame retained for logo/pattern match
---
 public/index.html | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/public/index.html b/public/index.html
index 272367b..794fcac 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1103,10 +1103,20 @@ async function scanTick(){
   if(scanBusy)return; scanBusy=true;
   try{
     const v=$('#scanvideo'); if(!v.videoWidth){scanBusy=false;return;}
-    const s=Math.min(1,1280/Math.max(v.videoWidth,v.videoHeight));
-    const c=document.createElement('canvas'); c.width=Math.round(v.videoWidth*s); c.height=Math.round(v.videoHeight*s);
+    const VW=v.videoWidth, VH=v.videoHeight;
+    // full frame — kept for logo-ID + pattern-match (which want the whole swatch, not a text strip)
+    const s=Math.min(1,1280/Math.max(VW,VH));
+    const c=document.createElement('canvas'); c.width=Math.round(VW*s); c.height=Math.round(VH*s);
     c.getContext('2d').drawImage(v,0,0,c.width,c.height);
-    const d=await ocrSmart(c.toDataURL('image/jpeg',0.7));   // front-cam mirror-retry built in
+    // HONE IN ON THE TEXT: crop to the centered guide box (~86% wide, 5:2 like .scan-frame) and
+    // UPSCALE it (up to 2x, cap 1600px) so small printed SKUs get more pixels for OCR and the
+    // surrounding clutter is dropped — a sharper, tighter read than OCRing the whole frame.
+    const roiW=Math.round(VW*0.86), roiH=Math.min(Math.round(roiW*2/5), Math.round(VH*0.92));
+    const roiX=Math.round((VW-roiW)/2), roiY=Math.round((VH-roiH)/2);
+    const TW=Math.min(1600,Math.round(roiW*2));
+    const cRoi=document.createElement('canvas'); cRoi.width=TW; cRoi.height=Math.round(roiH*TW/roiW);
+    cRoi.getContext('2d').drawImage(v, roiX,roiY,roiW,roiH, 0,0,cRoi.width,cRoi.height);
+    const d=await ocrSmart(cRoi.toDataURL('image/jpeg',0.72));   // honed ROI; front-cam mirror-retry built in
     if(d&&d.fields) updateScanFields(d.fields);   // light SKU#/Model#/Name/Color chips green as they're read
     if(d&&d.top){
       _frontHits=0;   // a real code appeared → not the pattern face; cancel any front streak

← 9277da4 fix: dw_unified 'match design' works on Kamatera — drop non-  ·  back to Dw Photo Capture  ·  feat: best-ID identify-first against unified catalog — ident a985673 →