Add camera properties

merge-requests/30/head
Bob Mottram 2021-05-11 13:36:35 +01:00
parent 81df7cf699
commit 6929fb8c96
3 changed files with 65 additions and 5 deletions

58
city.py
View File

@ -21,6 +21,50 @@ PERSON_EVENING = 4
PERSON_PARTY = 5 PERSON_PARTY = 5
def _getDecoyCamera(decoySeed: int) -> (str, str, int):
"""Returns a decoy camera make and model which took the photo
"""
cameras = [
["Apple", "iPhone SE"],
["Apple", "iPhone XR"],
["Apple", "iPhone 6"],
["Apple", "iPhone 7"],
["Apple", "iPhone 8"],
["Apple", "iPhone 11"],
["Apple", "iPhone 11 Pro"],
["Apple", "iPhone 12"],
["Apple", "iPhone 12 Mini"],
["Apple", "iPhone 12 Pro Max"],
["Samsung", "Galaxy Note 20 Ultra"],
["Samsung", "Galaxy S20 Plus"],
["Samsung", "Galaxy S20 FE 5G"],
["Samsung", "Galaxy Z FOLD 2"],
["Samsung", "Galaxy S10 Plus"],
["Samsung", "Galaxy S10e"],
["Samsung", "Galaxy Z Flip"],
["Samsung", "Galaxy A51"],
["Samsung", "Galaxy S10"],
["Samsung", "Galaxy S10 Plus"],
["Samsung", "Galaxy S10e"],
["Samsung", "Galaxy S10 5G"],
["Samsung", "Galaxy A60"],
["Samsung", "Note 10"],
["Samsung", "Note 10 Plus"],
["Samsung", "Galaxy S21 Ultra"],
["Samsung", "Galaxy Note 20 Ultra"],
["Samsung", "Galaxy S21"],
["Samsung", "Galaxy S21 Plus"],
["Samsung", "Galaxy S20 FE"],
["Samsung", "Galaxy Z Fold 2"],
["Samsung", "Galaxy A52 5G"],
["Samsung", "Galaxy A71 5G"]
]
randgen = random.Random(decoySeed)
index = randgen.randint(0, len(cameras) - 1)
serialNumber = randgen.randint(100000000000, 999999999999999999999999)
return cameras[index][0], cameras[index][1], serialNumber
def _getCityPulse(currTimeOfDay, decoySeed: int) -> (float, float): def _getCityPulse(currTimeOfDay, decoySeed: int) -> (float, float):
"""This simulates expected average patterns of movement in a city. """This simulates expected average patterns of movement in a city.
Jane or Joe average lives and works in the city, commuting in Jane or Joe average lives and works in the city, commuting in
@ -76,10 +120,12 @@ def _getCityPulse(currTimeOfDay, decoySeed: int) -> (float, float):
def spoofGeolocation(baseDir: str, def spoofGeolocation(baseDir: str,
city: str, currTime, decoySeed: int, city: str, currTime, decoySeed: int,
citiesList: []) -> (float, float, str, str): citiesList: []) -> (float, float, str, str,
str, str, int):
"""Given a city and the current time spoofs the location """Given a city and the current time spoofs the location
for an image for an image
returns latitude, longitude, N/S, E/W returns latitude, longitude, N/S, E/W,
camera make, camera model, camera serial number
""" """
locationsFilename = baseDir + '/custom_locations.txt' locationsFilename = baseDir + '/custom_locations.txt'
if not os.path.isfile(locationsFilename): if not os.path.isfile(locationsFilename):
@ -122,6 +168,8 @@ def spoofGeolocation(baseDir: str,
approxTimeZone = -approxTimeZone approxTimeZone = -approxTimeZone
currTimeAdjusted = currTime - \ currTimeAdjusted = currTime - \
datetime.timedelta(hours=approxTimeZone) datetime.timedelta(hours=approxTimeZone)
camMake, camModel, camSerialNumber = \
_getDecoyCamera(decoySeed)
# patterns of activity change in the city over time # patterns of activity change in the city over time
(distanceFromCityCenter, angleRadians) = \ (distanceFromCityCenter, angleRadians) = \
_getCityPulse(currTimeAdjusted, decoySeed) _getCityPulse(currTimeAdjusted, decoySeed)
@ -142,7 +190,9 @@ def spoofGeolocation(baseDir: str,
# number of decimal places # number of decimal places
latitude = int(latitude * 100000) / 100000.0 latitude = int(latitude * 100000) / 100000.0
longitude = int(longitude * 100000) / 100000.0 longitude = int(longitude * 100000) / 100000.0
return latitude, longitude, latdirection, longdirection return (latitude, longitude, latdirection, longdirection,
camMake, camModel, camSerialNumber)
return (default_latitude, default_longitude, return (default_latitude, default_longitude,
default_latdirection, default_longdirection) default_latdirection, default_longdirection,
"", "", 0)

View File

@ -84,10 +84,14 @@ def _spoofMetaData(baseDir: str, nickname: str, domain: str,
datetime.datetime.utcnow() - \ datetime.datetime.utcnow() - \
datetime.timedelta(minutes=randint(2, 120)) datetime.timedelta(minutes=randint(2, 120))
published = currTimeAdjusted.strftime("%Y:%m:%d %H:%M:%S+00:00") published = currTimeAdjusted.strftime("%Y:%m:%d %H:%M:%S+00:00")
(latitude, longitude, latitudeRef, longitudeRef) = \ (latitude, longitude, latitudeRef, longitudeRef,
camMake, camModel, camSerialNumber) = \
spoofGeolocation(baseDir, spoofCity, currTimeAdjusted, spoofGeolocation(baseDir, spoofCity, currTimeAdjusted,
decoySeed, None) decoySeed, None)
os.system('exiftool -artist="' + nickname + '" ' + os.system('exiftool -artist="' + nickname + '" ' +
'-Make="' + camMake + '" ' +
'-Model="' + camModel + '" ' +
'-Comment="' + str(camSerialNumber) + '" ' +
'-DateTimeOriginal="' + published + '" ' + '-DateTimeOriginal="' + published + '" ' +
'-FileModifyDate="' + published + '" ' + '-FileModifyDate="' + published + '" ' +
'-CreateDate="' + published + '" ' + '-CreateDate="' + published + '" ' +

View File

@ -3688,6 +3688,9 @@ def testSpoofGeolocation() -> None:
assert coords[1] <= 118.408 + cityRadius assert coords[1] <= 118.408 + cityRadius
assert coords[2] == 'N' assert coords[2] == 'N'
assert coords[3] == 'W' assert coords[3] == 'W'
assert len(coords[4]) > 4
assert len(coords[5]) > 4
assert coords[6] > 0
coords = spoofGeolocation('', 'unknown', currTime, coords = spoofGeolocation('', 'unknown', currTime,
decoySeed, citiesList) decoySeed, citiesList)
assert coords[0] >= 51.8744 - cityRadius assert coords[0] >= 51.8744 - cityRadius
@ -3696,6 +3699,9 @@ def testSpoofGeolocation() -> None:
assert coords[1] <= 0.368333 + cityRadius assert coords[1] <= 0.368333 + cityRadius
assert coords[2] == 'N' assert coords[2] == 'N'
assert coords[3] == 'W' assert coords[3] == 'W'
assert len(coords[4]) == 0
assert len(coords[5]) == 0
assert coords[6] == 0
kmlStr = '<?xml version="1.0" encoding="UTF-8"?>\n' kmlStr = '<?xml version="1.0" encoding="UTF-8"?>\n'
kmlStr += '<kml xmlns="http://www.opengis.net/kml/2.2">\n' kmlStr += '<kml xmlns="http://www.opengis.net/kml/2.2">\n'
kmlStr += '<Document>\n' kmlStr += '<Document>\n'