Added tagging and workflow powerpoint
parent
a227b77ad3
commit
d048ea6d43
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,138 @@
|
|||||||
|
import numpy as np
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import sys
|
||||||
|
from time import strptime
|
||||||
|
from PIL import Image, ImageFont
|
||||||
|
|
||||||
|
def divide_chunks(l, n):
|
||||||
|
"""
|
||||||
|
Splits a list into chunks of length n. Used to process the images in chunks.
|
||||||
|
"""
|
||||||
|
for i in range(0, len(l), n):
|
||||||
|
yield l[i : i + n]
|
||||||
|
|
||||||
|
# Sourced from https://gist.github.com/victorkristof/b9d794fe1ed12e708b9d
|
||||||
|
def datenum_to_datetime(datenum):
|
||||||
|
"""
|
||||||
|
Convert Matlab datenum into Python datetime.
|
||||||
|
:param datenum: Date in datenum format
|
||||||
|
:return: Datetime object corresponding to datenum.
|
||||||
|
"""
|
||||||
|
days = datenum % 1
|
||||||
|
hours = days % 1 * 24
|
||||||
|
minutes = hours % 1 * 60
|
||||||
|
seconds = np.round(minutes % 1 * 60)
|
||||||
|
return datetime.fromordinal(int(datenum)) \
|
||||||
|
+ timedelta(days=int(days)) \
|
||||||
|
+ timedelta(hours=int(hours)) \
|
||||||
|
+ timedelta(minutes=int(minutes)) \
|
||||||
|
+ timedelta(seconds=int(seconds)) \
|
||||||
|
- timedelta(days=366)
|
||||||
|
|
||||||
|
|
||||||
|
# Sourced from https://stackoverflow.com/questions/32237862/find-the-closest-date-to-a-given-date
|
||||||
|
def nearest(items, pivot):
|
||||||
|
"""
|
||||||
|
This function will return the datetime in items
|
||||||
|
which is the closest to the date pivot
|
||||||
|
"""
|
||||||
|
return min(items, key=lambda x: abs(x - pivot))
|
||||||
|
|
||||||
|
|
||||||
|
def progressbar(it, prefix="", size=60, out=sys.stdout): # Python3.3+
|
||||||
|
count = len(it)
|
||||||
|
def show(j):
|
||||||
|
x = int(size*j/count)
|
||||||
|
print("{}[{}{}] {}/{}".format(prefix, u"#"*x, "."*(size-x), j, count),
|
||||||
|
end='\r', file=out, flush=True)
|
||||||
|
show(0)
|
||||||
|
for i, item in enumerate(it):
|
||||||
|
yield item
|
||||||
|
show(i+1)
|
||||||
|
print("\n", flush=True, file=out)
|
||||||
|
|
||||||
|
|
||||||
|
class RegisteredImage():
|
||||||
|
|
||||||
|
def __init__(self, pathname, filename):
|
||||||
|
self.pathname = pathname
|
||||||
|
self.filename = filename
|
||||||
|
filename_list = filename.split(".")
|
||||||
|
date = filename_list[3].split("_")
|
||||||
|
if 'snap' in filename_list:
|
||||||
|
self.contributor = filename_list[8] # Mitch filename format
|
||||||
|
else:
|
||||||
|
self.contributor = filename_list[6] # Leaman filename format
|
||||||
|
self.site = filename_list[6]
|
||||||
|
self.posix_time = filename_list[0]
|
||||||
|
self.timezone = filename_list[4]
|
||||||
|
self.year = filename_list[5]
|
||||||
|
self.month = '{:02d}'.format(strptime(filename_list[2],'%b').tm_mon) # Ensure 2-digit format
|
||||||
|
self.day = date[0]
|
||||||
|
self.hour = date[1]
|
||||||
|
self.minute = date[2]
|
||||||
|
self.second = date[3]
|
||||||
|
|
||||||
|
self.tide = None
|
||||||
|
self.tag = None
|
||||||
|
self.width = None
|
||||||
|
self.height = None
|
||||||
|
self.font = None
|
||||||
|
|
||||||
|
def get_tide(self, site_tide_data, ts):
|
||||||
|
|
||||||
|
# Account for daylight savings
|
||||||
|
# ASSUMPTION: All .mat tide files are either AEST or AEDT
|
||||||
|
if self.timezone == 'AEDT':
|
||||||
|
self.hour = str(int(self.hour) - 1)
|
||||||
|
date_string = self.year + '-' + self.month + '-' + self.day + ' ' + self.hour + ':' + self.minute + ':' + self.second
|
||||||
|
img_datetime = datetime.strptime(date_string, "%Y-%m-%d %H:%M:%S") # Image date/time as a datetime object
|
||||||
|
|
||||||
|
tide_date = nearest(site_tide_data, img_datetime)
|
||||||
|
mat_index = site_tide_data.index(tide_date) # Retrieve the index of the .mat tide/time
|
||||||
|
mat_tide = round(ts[1][mat_index][0], 2) # Associated tide
|
||||||
|
|
||||||
|
#print('Image date/time: ' + date_string)
|
||||||
|
#print('Tide record: ' + str(tide_date))
|
||||||
|
self.tide = "{:.2f}".format(mat_tide)
|
||||||
|
|
||||||
|
def create_tag(self):
|
||||||
|
# Create image tag
|
||||||
|
hour = self.hour.zfill(2)
|
||||||
|
minute = self.minute.zfill(2)
|
||||||
|
|
||||||
|
if self.tide:
|
||||||
|
tide = self.tide
|
||||||
|
if float(self.tide) >= 0:
|
||||||
|
tide = '+' + self.tide
|
||||||
|
self.tag = ('Date:' + self.year + '/' + self.month + '/' + self.day +
|
||||||
|
' Time:' + hour + ':' + minute +
|
||||||
|
' Tide:' + tide + 'm AHD' +
|
||||||
|
' Contributor:' + self.contributor)
|
||||||
|
else:
|
||||||
|
self.tag = ('Date:' + self.year + '/' + self.month + '/' + self.day +
|
||||||
|
' Time:' + hour + ':' + minute +
|
||||||
|
' Contributor:' + self.contributor)
|
||||||
|
|
||||||
|
def get_dimensions(self):
|
||||||
|
image = Image.open(self.pathname)
|
||||||
|
# White Text Box
|
||||||
|
self.width, self.height = image.size
|
||||||
|
|
||||||
|
|
||||||
|
def get_font(self):
|
||||||
|
|
||||||
|
image = Image.open(self.pathname)
|
||||||
|
fontsize = 1
|
||||||
|
if self.tide:
|
||||||
|
img_fraction = 0.95
|
||||||
|
else:
|
||||||
|
img_fraction = 0.85
|
||||||
|
font = ImageFont.truetype("fonts/Courier New Bold.ttf", fontsize)
|
||||||
|
generic_large_tag = "1641775682.Mon.Jan.10_11_48_02.AEDT.2022.byron.snap.KateThornborough123"
|
||||||
|
|
||||||
|
while font.getsize(generic_large_tag)[0] < img_fraction*image.size[0]:
|
||||||
|
# iterate until the text size is just larger than the criteria
|
||||||
|
fontsize += 1
|
||||||
|
font = ImageFont.truetype("fonts/Courier New Bold.ttf", fontsize)
|
||||||
|
self.font = ImageFont.truetype("fonts/Courier New Bold.ttf", fontsize)
|
@ -0,0 +1,38 @@
|
|||||||
|
site_name,root_id,limit,type,Registration Capacity,Comment,parent_directory
|
||||||
|
alex,487451,300,CoastSnap Station,Good,Hand rail in foreground,C:\Users\z5079346\OneDrive - UNSW\My files\CoastSnap\Images
|
||||||
|
birubi,548070,300,CoastSnap Station,Good,Structures in foreground,
|
||||||
|
blacksmiths,269988,300,CoastSnap Station,Good,,
|
||||||
|
broulee,269990,300,CoastSnap Station,Good,Bad images small and tagged,
|
||||||
|
buddina,487447,300,CoastSnap Station,Ok,,
|
||||||
|
burleigh,303934,300,CoastSnap Station,Good,Distant view. Building.,
|
||||||
|
byron,269991,300,CoastSnap Station,Ok,Distant view. Zoomed images turn small,
|
||||||
|
cathieillaroo,393016,300,CoastSnap Station,,,
|
||||||
|
cathielagoon,392988,300,CoastSnap Station,,,
|
||||||
|
coogee,286418,300,DIY,,,
|
||||||
|
coolum,487449,300,CoastSnap Station,,,
|
||||||
|
cooya,275690,300,CoastSnap Station,Very Bad,,Bad Seed Images
|
||||||
|
cowbay,275692,300,CoastSnap Station,,,
|
||||||
|
era,297634,300,CoastSnap Station,,,
|
||||||
|
fourmile,275689,300,CoastSnap Station,,,
|
||||||
|
frankston,425039,300,CoastSnap Station,,,
|
||||||
|
garie,296239,300,CoastSnap Station,,,
|
||||||
|
hungry,296903,300,CoastSnap Station,,,
|
||||||
|
kirra,270011,300,CoastSnap Station,,,
|
||||||
|
macsnth,257393,300,DIY,,,
|
||||||
|
macssth,404754,300,DIY,,,
|
||||||
|
manly,242186,300,CoastSnap Station,,,
|
||||||
|
moffat,487448,300,CoastSnap Station,,,
|
||||||
|
newell,275691,300,CoastSnap Station,,,
|
||||||
|
nthnarra,243537,300,CoastSnap Station,,,
|
||||||
|
queenscliff,269334,300,CoastSnap Station,,,
|
||||||
|
rainbow,451612,300,CoastSnap Station,,,
|
||||||
|
seaford,421320,300,CoastSnap Station,,,
|
||||||
|
shortpoint,269992,300,CoastSnap Station,,,
|
||||||
|
stockton1,269985,300,CoastSnap Station,,,
|
||||||
|
stockton2,269986,300,CoastSnap Station,,,
|
||||||
|
stockton3,269987,300,CoastSnap Station,,,
|
||||||
|
tomakin,269989,300,CoastSnap Station,,,
|
||||||
|
tugun,269993,300,CoastSnap Station,,,
|
||||||
|
wamberal,299431,300,CoastSnap Station,,,
|
||||||
|
wonga,268307,300,CoastSnap Station,,,
|
||||||
|
woolgooga,435190,300,CoastSnap Station,,,
|
|
Binary file not shown.
Loading…
Reference in New Issue