alanbarret commited on
Commit
d8ff59f
·
1 Parent(s): 87a0be7

Update density calculation in image processing and enhance detection info format

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -158,14 +158,15 @@ def process_image(image, show_boxes=True):
158
  area_cm2 = (width * height * 0.0264 * 0.0264)
159
  density = total_knots / area_cm2 if area_cm2 > 0 else 0
160
 
161
- cv2.putText(padded_img, f"{int(total_knots)} knots/sqcm",
162
  (padding + width//2 - 100, height + padding + padding//2 + 30),
163
  cv2.FONT_HERSHEY_DUPLEX, 0.7, (0, 0, 0), 2)
164
 
165
  # Prepare detection information
 
166
  detection_info += f"Rows: {len(rows)}\n"
167
  detection_info += f"Columns: {len(cols)}\n"
168
- detection_info += f"Density: {int(total_knots)} knots/cm²"
169
 
170
  return padded_img, detection_info
171
 
 
158
  area_cm2 = (width * height * 0.0264 * 0.0264)
159
  density = total_knots / area_cm2 if area_cm2 > 0 else 0
160
 
161
+ cv2.putText(padded_img, f"{density:.2f} knots/sqcm",
162
  (padding + width//2 - 100, height + padding + padding//2 + 30),
163
  cv2.FONT_HERSHEY_DUPLEX, 0.7, (0, 0, 0), 2)
164
 
165
  # Prepare detection information
166
+ detection_info = f"Total Knots: {int(total_knots)}\n"
167
  detection_info += f"Rows: {len(rows)}\n"
168
  detection_info += f"Columns: {len(cols)}\n"
169
+ detection_info += f"Density: {int(total_knots)} knots/sqcm"
170
 
171
  return padded_img, detection_info
172