Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -384,8 +384,14 @@ def detect_paper_bounds(image: np.ndarray, paper_size: str, output_unit: str = "
|
|
| 384 |
paper_contour = expanded_contour
|
| 385 |
|
| 386 |
# Calculate scaling factor based on paper size with proper units
|
| 387 |
-
scaling_factor = calculate_paper_scaling_factor(paper_contour, paper_size, output_unit)
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
return paper_contour, scaling_factor
|
| 390 |
|
| 391 |
except Exception as e:
|
|
|
|
| 384 |
paper_contour = expanded_contour
|
| 385 |
|
| 386 |
# Calculate scaling factor based on paper size with proper units
|
| 387 |
+
# scaling_factor = calculate_paper_scaling_factor(paper_contour, paper_size, output_unit)
|
| 388 |
+
scaling_factor = calculate_paper_scaling_factor_corrected(
|
| 389 |
+
paper_contour,
|
| 390 |
+
paper_size,
|
| 391 |
+
output_unit="mm",
|
| 392 |
+
correction_factor=0.82, # Adjust this value
|
| 393 |
+
method="average" # Try different methods
|
| 394 |
+
)
|
| 395 |
return paper_contour, scaling_factor
|
| 396 |
|
| 397 |
except Exception as e:
|