GPS Within 10 Feet checking...

main
Robert 8 months ago
parent ace574eac9
commit 1df14ded24
  1. 38
      coordinates.py
  2. 48
      dedup.py

@ -1,6 +1,7 @@
from PIL import Image from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS from PIL.ExifTags import TAGS, GPSTAGS
import os import os
import math
""" """
Copyright (c) 2025 by Robert Strutts Copyright (c) 2025 by Robert Strutts
@ -78,33 +79,34 @@ def get_lat_lon(gps_info):
import math import math
def haversine(lat1, lon1, lat2, lon2): def haversine_distance_feet(coord1, coord2):
""" """
Calculate the great circle distance between two points Calculate the Haversine distance between two coordinates in feet.
on the earth (specified in decimal degrees) Returns:
Returns distance in miles float: distance in feet
""" """
# Convert decimal degrees to radians # Earth radius in meters
lat1, lon1, lat2, lon2 = map(math.radians, [lat1, lon1, lat2, lon2]) R = 6371000
lat1, lon1 = math.radians(coord1[0]), math.radians(coord1[1])
lat2, lon2 = math.radians(coord2[0]), math.radians(coord2[1])
# Haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1 dlat = lat2 - lat1
a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2 dlon = lon2 - lon1
c = 2 * math.asin(math.sqrt(a))
a = (math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
# Radius of earth in miles (3956 for miles, 6371 for kilometers) # Distance in meters
r = 3956 distance_meters = R * c
return c * r
def are_within_one_mile(lat1, lon1, lat2, lon2): # Convert to feet
distance = haversine(lat1, lon1, lat2, lon2) return distance_meters * 3.28084
return distance <= 1
""" """
Example points: Example points:
point1 = (40.7128, -74.0060) # New York City point1 = (40.7484, -73.9857) # Empire State Building coordinates (approximately)
point2 = (40.7200, -74.0100) # About 0.5 miles from NYC point2 = (40.748405, -73.985685) # about 10 feet northeast of point1
""" """
def get_coordinates_from_image(image_path): def get_coordinates_from_image(image_path):

@ -28,40 +28,52 @@ Processing time scales with area, so 4x downscale = ~16x faster initial alignmen
Memory usage significantly reduced Memory usage significantly reduced
""" """
within_one_mile_check = False within_feet_check = True
withinFeet = 10 # < 10 feet
# Photo File Size Limits:
too_small = 1024 # 1KB too_small = 1024 # 1KB
too_large = 10 * 1024 * 1024 # 10MB too_large = 10 * 1024 * 1024 # 10MB
def handle_GPS(location1, location2): def camera_check(camera_info1, camera_info2, diff_location = False):
camera_info1, latitude1, longitude1 = location1
make1 = camera_info1['Make'] make1 = camera_info1['Make']
model1 = camera_info1['Model'] model1 = camera_info1['Model']
camera_info2, latitude2, longitude2 = location2
make2 = camera_info2['Make'] make2 = camera_info2['Make']
model2 = camera_info2['Model'] model2 = camera_info2['Model']
if diff_location == True:
point1 = (latitude1, longitude1) print("Images are from different Locations")
point2 = (latitude2, longitude2)
if point1 == point2:
print("Images are both from same exact Location")
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: if make1 == make2 and model1 == model2:
print("Images are within one mile")
print("Cameras are the same.") print("Cameras are the same.")
delibs.exit_timer(6) delibs.exit_timer(6)
else:
print("Different Cameras detected.")
print("👌Not a Duplicate")
delibs.exit_timer(0)
else: else:
print("Images are from different Locations")
if make1 != make2 or model1 != model2: if make1 != make2 or model1 != model2:
print("Different Cameras detected.") print("Different Cameras detected.")
print("👌Not a Duplicate") print("👌Not a Duplicate")
delibs.exit_timer(0) delibs.exit_timer(0)
def handle_GPS(location1, location2):
camera_info1, latitude1, longitude1 = location1
camera_info2, latitude2, longitude2 = location2
point1 = (latitude1, longitude1)
point2 = (latitude2, longitude2)
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)
def is_module_imported(module_name): def is_module_imported(module_name):
return module_name in sys.modules return module_name in sys.modules

Loading…
Cancel
Save