diff --git a/dedup.py b/dedup.py index 56a26cb..e8a8d07 100644 --- a/dedup.py +++ b/dedup.py @@ -34,46 +34,60 @@ withinFeet = 10 # < 10 feet too_small = 1024 # 1KB too_large = 10 * 1024 * 1024 # 10MB -def camera_check(camera_info1, camera_info2, diff_location = False): - make1 = camera_info1['Make'] - model1 = camera_info1['Model'] - make2 = camera_info2['Make'] - model2 = camera_info2['Model'] - if diff_location == True: - print("Images are from different Locations") - if make1 == make2 and model1 == model2: - print("Cameras are the same.") - delibs.exit_timer(6) - else: - print("Different Cameras detected.") - print("👌Not a Duplicate") - delibs.exit_timer(0) +def not_a_dup(): + print("👌Not a Duplicate") + delibs.exit_timer(0) + +def is_same_location(point1, point2): + if point1 == point2: + return True + elif within_feet_check == True: + return coordinates.haversine_distance_feet(point1, point2) else: - if make1 != make2 or model1 != model2: - print("Different Cameras detected.") - print("👌Not a Duplicate") - delibs.exit_timer(0) + return False + +def is_same_camera(cam1, cam2): + return cam1 == cam2 def handle_GPS(location1, location2): camera_info1, latitude1, longitude1 = location1 camera_info2, latitude2, longitude2 = location2 point1 = (latitude1, longitude1) point2 = (latitude2, longitude2) + camera1 = (camera_info1['Make'], camera_info1['Model']) + camera2 = (camera_info2['Make'], camera_info2['Model']) - if point1 == point2: - print("Images are both from same exact Location") - camera_check(camera_info1, camera_info2) - elif within_feet_check == True: - feet = coordinates.haversine_distance_feet(point1, point2) - print(f"Images distance in feet: {feet:.2f}") - if feet < withinFeet: - print(f"With in requirements of {withinFeet}") - camera_check(camera_info1, camera_info2) - else: - camera_check(camera_info1, camera_info2, True) - else: - camera_check(camera_info1, camera_info2, True) - + the_location = is_same_location(point1, point2) + match the_location: + case True: + print("Images are both from same exact Location") + if is_same_camera(camera1, camera2): + print("Cameras are the same.") + delibs.exit_timer(5) + else: + print("Different Cameras detected.") + not_a_dup() + + case False: + print("Images are from different Locations") + if is_same_camera(camera1, camera2) == False: + print("Different Cameras detected.") + not_a_dup() + + case float() if isinstance(the_location, float): # Checks if it's a float + print(f"Images distance in feet: {the_location:.2f}") + if the_location < withinFeet: + print(f"With in requirements of {withinFeet}") + if is_same_camera(camera1, camera2): + print("Cameras are the same.") + delibs.exit_timer(6) + else: + print("Different Cameras detected.") + not_a_dup() + elif is_same_camera(camera1, camera2) == False: + print("Different Cameras detected.") + not_a_dup() + def is_module_imported(module_name): return module_name in sys.modules @@ -135,8 +149,7 @@ def main(): if w != w2 and w != h2 and h != h2 and h != w2: print("Diffent Resolutions") - print("👌Not a Duplicate") - delibs.exit_timer(0) + not_a_dup() print("Done loading images...") with delibs.Timer("Module - Aligning with downscaling 1/4 size - Total Time"):