Hayk Arutyunyan commited on
Commit
9eebbbf
·
1 Parent(s): c3db5ed

Add print of results

Browse files
Files changed (2) hide show
  1. src/ocr_utils_demo.py +1 -0
  2. src/pipeline_hf.py +7 -3
src/ocr_utils_demo.py CHANGED
@@ -64,6 +64,7 @@ def ocr_sensors(rois: list[np.ndarray]) -> list[dict]:
64
  for roi in rois:
65
  try:
66
  result = paddle_ocr.ocr(roi)
 
67
  except Exception as e:
68
  print(f"⚠ Ошибка OCR.ocr: {e}")
69
  return [{"text": "?", "score": 0.0} for _ in rois]
 
64
  for roi in rois:
65
  try:
66
  result = paddle_ocr.ocr(roi)
67
+ print(result) # для отладки
68
  except Exception as e:
69
  print(f"⚠ Ошибка OCR.ocr: {e}")
70
  return [{"text": "?", "score": 0.0} for _ in rois]
src/pipeline_hf.py CHANGED
@@ -39,6 +39,9 @@ def process_single_image(img: np.ndarray, color_ranges: dict):
39
  print("Contour bbox:", x, y, ww, hh) # для отладки
40
  if ww < 90 or hh < 17:
41
  continue
 
 
 
42
  print("ROI accepted:", ww, hh) # для отладки
43
  hh_clamped = min(hh, 17)
44
  roi = img[y:y + hh_clamped, x:x + ww]
@@ -50,11 +53,12 @@ def process_single_image(img: np.ndarray, color_ranges: dict):
50
  sensors = []
51
  if rois:
52
  ocr_results = ocr_sensors(rois)
 
53
 
54
- for (x, y, ww, hh), r in zip(positions, ocr_results):
55
  sensors.append({
56
- "text": r["text"],
57
- "score": r["score"],
58
  "x": x,
59
  "y": y,
60
  "w": ww,
 
39
  print("Contour bbox:", x, y, ww, hh) # для отладки
40
  if ww < 90 or hh < 17:
41
  continue
42
+ if hh / ww > 1.5:
43
+ continue
44
+
45
  print("ROI accepted:", ww, hh) # для отладки
46
  hh_clamped = min(hh, 17)
47
  roi = img[y:y + hh_clamped, x:x + ww]
 
53
  sensors = []
54
  if rois:
55
  ocr_results = ocr_sensors(rois)
56
+ print(ocr_results) # для отладки
57
 
58
+ for (x, y, ww, hh), result in zip(positions, ocr_results):
59
  sensors.append({
60
+ "text": result[0],
61
+ "score": result[1],
62
  "x": x,
63
  "y": y,
64
  "w": ww,