Praveen-K-0503 commited on
Commit
630687c
·
1 Parent(s): fb85f93

fix: add missing database tracking for image scans

Browse files
Files changed (1) hide show
  1. api.py +16 -0
api.py CHANGED
@@ -524,6 +524,22 @@ async def process_image_api(
524
  _, buffer = cv2.imencode('.jpg', img_bgr)
525
  encoded_img = base64.b64encode(buffer).decode('utf-8')
526
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527
  return {
528
  "count": count, "elapsed": elapsed,
529
  "usedBatchSize": used_batch_size, "imageB64": encoded_img
 
524
  _, buffer = cv2.imencode('.jpg', img_bgr)
525
  encoded_img = base64.b64encode(buffer).decode('utf-8')
526
 
527
+ # Save to database
528
+ try:
529
+ with Session(engine) as session:
530
+ report = FlightReport(
531
+ filename=file.filename,
532
+ max_capacity_breached=False, # We don't have capacity from frontend here natively, but let's record the scan
533
+ peak_crowd_count=count,
534
+ duration_frames=1,
535
+ chaos_anomalies=0
536
+ )
537
+ session.add(report)
538
+ session.commit()
539
+ except Exception as e:
540
+ print(f"Failed to save to db: {e}")
541
+ pass
542
+
543
  return {
544
  "count": count, "elapsed": elapsed,
545
  "usedBatchSize": used_batch_size, "imageB64": encoded_img