Ayesha352 commited on
Commit
e4aeb4c
·
verified ·
1 Parent(s): 15bb55e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -67,7 +67,7 @@ def homography_all_detectors(flat_file, persp_file, json_file, xml_file):
67
  kp1,kp2,good_matches = detect_and_match(flat_gray,persp_gray,method)
68
  if kp1 is None or kp2 is None or len(good_matches)<4: continue
69
 
70
- # Feature matching
71
  match_img = cv2.drawMatches(flat_img,kp1,persp_img,kp2,good_matches,None,flags=2)
72
 
73
  # Homography & ROI mapping
@@ -87,20 +87,20 @@ def homography_all_detectors(flat_file, persp_file, json_file, xml_file):
87
  xml_mapped = cv2.perspectiveTransform(xml_points.reshape(-1,1,2),H).reshape(-1,2)
88
  for px,py in xml_mapped: cv2.circle(xml_gt_img,(int(px),int(py)),5,(0,0,255),-1)
89
 
90
- # Convert to RGB (keep original size)
91
  flat_rgb = cv2.cvtColor(flat_img,cv2.COLOR_BGR2RGB)
92
  match_rgb = cv2.cvtColor(match_img,cv2.COLOR_BGR2RGB)
93
  roi_rgb = cv2.cvtColor(persp_roi,cv2.COLOR_BGR2RGB)
94
  xml_rgb = cv2.cvtColor(xml_gt_img,cv2.COLOR_BGR2RGB)
95
 
96
- # Merge 2x2 grid (maintaining original resolution)
97
  top = np.hstack([flat_rgb, match_rgb])
98
  bottom = np.hstack([roi_rgb, xml_rgb])
99
- combined_grid = np.vstack([top,bottom])
100
 
101
  gallery_images.append((combined_grid,f"{method} Detector"))
102
 
103
- # Save for download
104
  base_name = os.path.splitext(os.path.basename(persp_file))[0]
105
  file_name = f"{base_name}_{method.lower()}.png"
106
  cv2.imwrite(file_name, cv2.cvtColor(combined_grid,cv2.COLOR_RGB2BGR))
@@ -127,7 +127,7 @@ iface = gr.Interface(
127
  gr.File(label="Download AKAZE Result")
128
  ],
129
  title="Homography ROI Projection with Feature Matching & XML GT",
130
- description="Flat + Perspective images with mockup.json & XML. Shows 4 views per detector: Flat, Feature Matches, ROI Projection, XML Ground Truth."
131
  )
132
 
133
  iface.launch()
 
67
  kp1,kp2,good_matches = detect_and_match(flat_gray,persp_gray,method)
68
  if kp1 is None or kp2 is None or len(good_matches)<4: continue
69
 
70
+ # Feature matching image
71
  match_img = cv2.drawMatches(flat_img,kp1,persp_img,kp2,good_matches,None,flags=2)
72
 
73
  # Homography & ROI mapping
 
87
  xml_mapped = cv2.perspectiveTransform(xml_points.reshape(-1,1,2),H).reshape(-1,2)
88
  for px,py in xml_mapped: cv2.circle(xml_gt_img,(int(px),int(py)),5,(0,0,255),-1)
89
 
90
+ # Convert to RGB (original size kept)
91
  flat_rgb = cv2.cvtColor(flat_img,cv2.COLOR_BGR2RGB)
92
  match_rgb = cv2.cvtColor(match_img,cv2.COLOR_BGR2RGB)
93
  roi_rgb = cv2.cvtColor(persp_roi,cv2.COLOR_BGR2RGB)
94
  xml_rgb = cv2.cvtColor(xml_gt_img,cv2.COLOR_BGR2RGB)
95
 
96
+ # Merge 2x2 grid keeping original resolutions
97
  top = np.hstack([flat_rgb, match_rgb])
98
  bottom = np.hstack([roi_rgb, xml_rgb])
99
+ combined_grid = np.vstack([top, bottom])
100
 
101
  gallery_images.append((combined_grid,f"{method} Detector"))
102
 
103
+ # Save combined grid for download
104
  base_name = os.path.splitext(os.path.basename(persp_file))[0]
105
  file_name = f"{base_name}_{method.lower()}.png"
106
  cv2.imwrite(file_name, cv2.cvtColor(combined_grid,cv2.COLOR_RGB2BGR))
 
127
  gr.File(label="Download AKAZE Result")
128
  ],
129
  title="Homography ROI Projection with Feature Matching & XML GT",
130
+ description="Flat + Perspective images with mockup.json & XML. Shows 4 views per detector: Flat, Feature Matches, ROI Projection, XML Ground Truth. Original resolution kept."
131
  )
132
 
133
  iface.launch()