Sarvamangalak commited on
Commit
d6d61bf
·
verified ·
1 Parent(s): e95a235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -153,10 +153,11 @@ def fig2img(fig):
153
 
154
 
155
  # -------------------- OCR Stub --------------------
156
-
157
- def read_plate(crop):
158
- # Placeholder OCR logic
159
- return "KA01AB1234"
 
160
 
161
 
162
  # -------------------- Visualization --------------------
@@ -178,10 +179,10 @@ def visualize_prediction(img, output_dict, threshold=0.5, id2label=None):
178
 
179
  for score, (xmin, ymin, xmax, ymax), label in zip(scores, boxes, labels):
180
  if "plate" in label.lower():
181
- crop = img.crop((int(xmin), int(ymin), int(xmax), int(ymax)))
182
 
183
- plate_text = read_plate(crop)
184
- vehicle_type = classify_plate_color(crop)
185
  toll, discount_msg = compute_discount(vehicle_type)
186
 
187
  cursor.execute(
 
153
 
154
 
155
  # -------------------- OCR Stub --------------------
156
+ def read_plate(plate_img):
157
+ results = reader.readtext(np.array(plate_img))
158
+ if results:
159
+ return results[0][1]
160
+ return "UNKNOWN"
161
 
162
 
163
  # -------------------- Visualization --------------------
 
179
 
180
  for score, (xmin, ymin, xmax, ymax), label in zip(scores, boxes, labels):
181
  if "plate" in label.lower():
182
+ plate_img = img.crop((int(xmin), int(ymin), int(xmax), int(ymax)))
183
 
184
+ plate_text = read_plate(plate_img)
185
+ vehicle_type = classify_plate_color(plate_img)
186
  toll, discount_msg = compute_discount(vehicle_type)
187
 
188
  cursor.execute(