Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -432,7 +432,7 @@ class WatermelonProcessor:
|
|
| 432 |
|
| 433 |
pt_top, pt_bot, height_px = get_intersections(phi + np.pi/2, rind_mask)
|
| 434 |
pt_right, pt_left, width_px = get_intersections(phi, rind_mask)
|
| 435 |
-
_, _, f_height_px = get_intersections(phi + np.pi/2, flesh_mask)
|
| 436 |
_, _, f_width_px = get_intersections(phi, flesh_mask)
|
| 437 |
|
| 438 |
rind_thick_px = None
|
|
@@ -607,8 +607,13 @@ class WatermelonProcessor:
|
|
| 607 |
flesh_closed = cv2.warpAffine(flesh_closed_rot, M_inv, (w, h))
|
| 608 |
_, flesh_closed = cv2.threshold(flesh_closed, 127, 255, cv2.THRESH_BINARY)
|
| 609 |
|
| 610 |
-
# Now extract the unified flesh data
|
| 611 |
flesh_data = self.get_polar_data(flesh_closed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
# -----------------------------------------------------------
|
| 613 |
if rind_data is None:
|
| 614 |
return fail("No stable perimeter.", measurement_unit="cm" if cm_per_px else "px", scale_source="color_checker" if cm_per_px else "original_pixels", color_checker_found=checker_corners is not None, rind_source=rind_source, rind_overlap_ratio=rind_overlap_ratio)
|
|
|
|
| 432 |
|
| 433 |
pt_top, pt_bot, height_px = get_intersections(phi + np.pi/2, rind_mask)
|
| 434 |
pt_right, pt_left, width_px = get_intersections(phi, rind_mask)
|
| 435 |
+
_, _, f_height_px = get_intersections(phi + np.pi/2, flesh_mask)
|
| 436 |
_, _, f_width_px = get_intersections(phi, flesh_mask)
|
| 437 |
|
| 438 |
rind_thick_px = None
|
|
|
|
| 607 |
flesh_closed = cv2.warpAffine(flesh_closed_rot, M_inv, (w, h))
|
| 608 |
_, flesh_closed = cv2.threshold(flesh_closed, 127, 255, cv2.THRESH_BINARY)
|
| 609 |
|
|
|
|
| 610 |
flesh_data = self.get_polar_data(flesh_closed)
|
| 611 |
+
|
| 612 |
+
raw_flesh_perim = None
|
| 613 |
+
if flesh_data:
|
| 614 |
+
_, _, _, raw_flesh_cnt = flesh_data
|
| 615 |
+
raw_flesh_perim = float(cv2.arcLength(raw_flesh_cnt, True))
|
| 616 |
+
|
| 617 |
# -----------------------------------------------------------
|
| 618 |
if rind_data is None:
|
| 619 |
return fail("No stable perimeter.", measurement_unit="cm" if cm_per_px else "px", scale_source="color_checker" if cm_per_px else "original_pixels", color_checker_found=checker_corners is not None, rind_source=rind_source, rind_overlap_ratio=rind_overlap_ratio)
|