Camera Make/Model Detection.

main
Robert 8 months ago
parent 424cab7aa4
commit 698f927468
  1. 50
      coordinates.py
  2. 23
      dedup.py
  3. 5
      get_dups.bat
  4. 5
      get_dups.sh

@ -18,6 +18,21 @@ def get_exif_data(image_path):
print(f"Error reading EXIF data: {e}")
return None
def get_camera_info(exif):
if not exif:
return None
camera_info = {
'Make': exif.get('Make', 'Unknown'),
'Model': exif.get('Model', 'Unknown')
}
# Some cameras store model in 'Camera Model Name' instead
if camera_info['Model'] == 'Unknown':
camera_info['Model'] = exif.get('Camera Model Name', 'Unknown')
return camera_info
def get_gps_info(exif_data):
"""Extract GPS information from EXIF data"""
if not exif_data or 'GPSInfo' not in exif_data:
@ -61,6 +76,37 @@ def get_lat_lon(gps_info):
return None, None
import math
def haversine(lat1, lon1, lat2, lon2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal degrees)
Returns distance in miles
"""
# Convert decimal degrees to radians
lat1, lon1, lat2, lon2 = map(math.radians, [lat1, lon1, lat2, lon2])
# Haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2
c = 2 * math.asin(math.sqrt(a))
# Radius of earth in miles (3956 for miles, 6371 for kilometers)
r = 3956
return c * r
def are_within_one_mile(lat1, lon1, lat2, lon2):
distance = haversine(lat1, lon1, lat2, lon2)
return distance <= 1
"""
Example points:
point1 = (40.7128, -74.0060) # New York City
point2 = (40.7200, -74.0100) # About 0.5 miles from NYC
"""
def get_coordinates_from_image(image_path):
"""Main function to get coordinates from image file"""
exif_data = get_exif_data(image_path)
@ -73,9 +119,11 @@ def get_coordinates_from_image(image_path):
print("No GPS information found in EXIF data.")
return None
camera_info = get_camera_info(exif_data)
latitude, longitude = get_lat_lon(gps_info)
if latitude is not None and longitude is not None:
return (latitude, longitude)
return (camera_info, latitude, longitude)
else:
print("Could not extract valid coordinates.")
return None

@ -29,13 +29,33 @@ Memory usage significantly reduced
"""
def handle_GPS(location1, location2):
if location1 == location2:
camera_info1, latitude1, longitude1 = location1
make1 = camera_info1['Make']
model1 = camera_info1['Model']
camera_info2, latitude2, longitude2 = location2
make2 = camera_info2['Make']
model2 = camera_info2['Model']
point1 = (latitude1, longitude1)
point2 = (latitude2, longitude2)
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.")
delibs.exit_timer(5)
# elif coordinates.are_within_one_mile(*point1, *point2):
# if make1 == make2 and model1 == model2:
# print("Images are within one mile")
# print("Cameras are the same.")
# delibs.exit_timer(6)
else:
print("Images are from different Locations")
print("👌Not a Duplicate")
if make1 != make2 and model1 != model2:
print("Different Cameras detected.")
delibs.exit_timer(0)
def is_module_imported(module_name):
@ -67,6 +87,7 @@ def main():
coordinates1 = coordinates.get_coordinates_from_image(file1)
if coordinates1 != None:
coordinates2 = coordinates.get_coordinates_from_image(file2)
if coordinates2 != None:
handle_GPS(coordinates1, coordinates2)
else:

@ -50,6 +50,11 @@ for /l %%i in (1,1,%count%) do (
echo %~1\!outer_image!>> sameGPS.txt
goto :break_inner
)
if !errorlevel! equ 5 (
echo %~1\!outer_image!>> sameGPSmile.txt
goto :break_inner
)
if !errorlevel! equ 8 (
echo %~1\!outer_image!>> invalid.txt
goto :break_inner

@ -44,6 +44,11 @@ for ((i = 0; i < ${#images[@]}; i++)); do
echo "$1/$outer_image # $inner_image" >> sameGPS.txt
break # No need to check more once found matching GPS image
fi
if [ $exit_code -eq 6 ]; then
echo "$1/$outer_image # $inner_image" >> sameGPSmile.txt
break # No need to check more once found matching GPS image
fi
if [ $exit_code -eq 8 ]; then
echo "$1/$outer_image # $inner_image" >> invalid.txt
break # No need to check more once found bad image

Loading…
Cancel
Save