|
|
|
|
@ -42,7 +42,7 @@ signal.signal(signal.SIGINT, exit_handler) |
|
|
|
|
|
|
|
|
|
def exit_timer(level): |
|
|
|
|
end = time.perf_counter() |
|
|
|
|
print(f"Execution took {end - start:.4f} seconds") |
|
|
|
|
print(f"⏱ Execution took {end - start:.4f} seconds") |
|
|
|
|
exit(level) |
|
|
|
|
|
|
|
|
|
class Timer: |
|
|
|
|
@ -74,7 +74,7 @@ class Timer: |
|
|
|
|
|
|
|
|
|
def print_result(self): |
|
|
|
|
elapsed = self.elapsed() |
|
|
|
|
print(f"{self.name}: {elapsed:.6f} seconds") |
|
|
|
|
print(f"{self.name}: ⏱ {elapsed:.6f} seconds") |
|
|
|
|
|
|
|
|
|
def align_with_downscaling(img1, img2, downscale_factor=4, try_common_rotations=True): |
|
|
|
|
""" |
|
|
|
|
@ -442,7 +442,7 @@ if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
if (hash1 == hash2): |
|
|
|
|
print("xxHash found duplicates") |
|
|
|
|
print("✅ Perfect match - images are identical") |
|
|
|
|
print("❌ Perfect match - images are identical - Duplicate Found!") |
|
|
|
|
print("No transformation needed") |
|
|
|
|
exit_timer(1) |
|
|
|
|
else: |
|
|
|
|
@ -456,14 +456,16 @@ if __name__ == "__main__": |
|
|
|
|
w, h = get_image_dimensions_cv(large_img1) |
|
|
|
|
w2, h2 = get_image_dimensions_cv(large_img2) |
|
|
|
|
if w == None or w2 == None or h == None or h2 == None: |
|
|
|
|
print("Aborting...Invalid Image!") |
|
|
|
|
print("❌Aborting❌...Invalid Image!") |
|
|
|
|
exit_timer(8) |
|
|
|
|
if w != w2 and w != h2: |
|
|
|
|
print("Diffent Resolutions") |
|
|
|
|
print("👌Not a Duplicate") |
|
|
|
|
exit_timer(0) |
|
|
|
|
|
|
|
|
|
if h != h2 and h != w2: |
|
|
|
|
print("Diffent Resolutions") |
|
|
|
|
print("👌Not a Duplicate") |
|
|
|
|
exit_timer(0) |
|
|
|
|
|
|
|
|
|
print("Done loading images...") |
|
|
|
|
@ -491,10 +493,10 @@ if __name__ == "__main__": |
|
|
|
|
is_score = "" |
|
|
|
|
|
|
|
|
|
if matrix_score == 1.0 and is_score != "scores": |
|
|
|
|
print("✅ Perfect Matrix score, should be identical") |
|
|
|
|
print("❌ Perfect match score, images should be identical - Duplicate Found!") |
|
|
|
|
exit_timer(1) |
|
|
|
|
if matrix_score < 0.3 and is_score != "scores": |
|
|
|
|
print("❌ Significant transformation required") |
|
|
|
|
print("👌Not a Duplicate, best guess!") |
|
|
|
|
exit_timer(0) |
|
|
|
|
if is_score == "scores": |
|
|
|
|
score = find_duplicate_with_rotation(large_img1, aligned) |
|
|
|
|
@ -505,14 +507,14 @@ if __name__ == "__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") |
|
|
|
|
print("❌ Perfect match - images are identical - Duplicate Found!") |
|
|
|
|
print("No transformation needed") |
|
|
|
|
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") |
|
|
|
|
print("✅ Near-perfect alignment - minor differences detected") |
|
|
|
|
exit_code = 2 |
|
|
|
|
else: |
|
|
|
|
print("❌ Significant transformation required") |
|
|
|
|
print("👌Not a Duplicate") |
|
|
|
|
exit_code = 0 |
|
|
|
|
|
|
|
|
|
print(f"Matrix deviation score: {matrix_score:.4f}") |
|
|
|
|
|