From 566c11af0e344ee9337e5bacbc6c2e0fd4d08f42 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 28 Apr 2025 16:43:27 -0400 Subject: [PATCH] ANSI White on Timer --- dedup.py | 9 ++++----- delibs.py | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/dedup.py b/dedup.py index 762a173..f6aa3d0 100644 --- a/dedup.py +++ b/dedup.py @@ -28,7 +28,7 @@ Processing time scales with area, so 4x downscale = ~16x faster initial alignmen Memory usage significantly reduced """ -within_one_mile_check = True +within_one_mile_check = False too_small = 1024 # 1KB too_large = 10 * 1024 * 1024 # 10MB @@ -46,9 +46,9 @@ def handle_GPS(location1, location2): if point1 == point2: print("Images are both from same exact Location") - print("✅Possible duplicate") if make1 == make2 and model1 == model2: print("Cameras are the same.") + print("✅Possible duplicate") delibs.exit_timer(5) elif coordinates.are_within_one_mile(*point1, *point2) and within_one_mile_check == True: if make1 == make2 and model1 == model2: @@ -57,9 +57,9 @@ def handle_GPS(location1, location2): delibs.exit_timer(6) else: print("Images are from different Locations") - print("👌Not a Duplicate") if make1 != make2 or model1 != model2: print("Different Cameras detected.") + print("👌Not a Duplicate") delibs.exit_timer(0) def is_module_imported(module_name): @@ -92,7 +92,6 @@ def main(): if (hash1 == hash2): print("xxHash found duplicates") print("❌ Perfect match - images are identical - Duplicate Found!") - print("No transformation needed") delibs.exit_timer(1) else: print("Done hashing...") @@ -166,8 +165,8 @@ def main(): # Check for perfect alignment if matrix_score == 1.0 and decomposed_score == 1.0 and combined_score == 1.0: - print("❌ Perfect match - images are identical - Duplicate Found!") print("No transformation needed") + print("❌ Perfect match - images are identical - Duplicate Found!") exit_code = 1 elif matrix_score > 0.9 and decomposed_score > 0.9 and combined_score > 0.7: print("✅ Near-perfect alignment - minor differences detected") diff --git a/delibs.py b/delibs.py index e923207..ba9427f 100644 --- a/delibs.py +++ b/delibs.py @@ -12,6 +12,12 @@ Copyright (c) 2025 by Robert Strutts License: MIT """ +use_ANSI_Colors = True + +# ANSI escape codes for colors +WHITE = "\033[97m" +RESET = "\033[0m" + start = time.perf_counter() def kill_all(): @@ -24,9 +30,13 @@ def exit_handler(signum, frame): signal.signal(signal.SIGINT, exit_handler) def exit_timer(level): - end = time.perf_counter() - print(f"⏱ Execution took {end - start:.4f} seconds") - exit(level) + end = time.perf_counter() + if use_ANSI_Colors == True: + print(f"{WHITE}⏱ Execution took {end - start:.4f} seconds{RESET}") + else: + print(f"⏱ Execution took {end - start:.4f} seconds") + + exit(level) class Timer: def __init__(self, name=None): @@ -57,7 +67,10 @@ class Timer: def print_result(self): elapsed = self.elapsed() - print(f"{self.name}: ⏱ {elapsed:.6f} seconds") + if use_ANSI_Colors == True: + print(f"{self.name}: {WHITE}⏱ {elapsed:.6f} seconds{RESET}") + else: + print(f"{self.name}: ⏱ {elapsed:.6f} seconds") def align_with_downscaling(img1, img2, downscale_factor=4, try_common_rotations=True): """