Commit b6f900bc authored by Jorge S. Mendes de Jesus's avatar Jorge S. Mendes de Jesus
Browse files

update and documentation

parent 3bea79f1
...@@ -35,5 +35,15 @@ And then run the startup script: ...@@ -35,5 +35,15 @@ And then run the startup script:
Finally, detach orderly from the running container with the escape sequence: Finally, detach orderly from the running container with the escape sequence:
`Ctrl+P Ctrl+Q` `Ctrl+P Ctrl+Q`
Image processing
================
Pleae consult the specific folder ** (README)[imageProcessing/README.md] **
\ No newline at end of file
#Script to read and write the tags on image using new lib
#DOCS:
#https://wiki.gnome.org/Projects/gexiv2/PythonSupport
#http://www.exiv2.org/tags.html
#!/bin/env python
from gi.repository import GExiv2
from collections import namedtuple
import glob, re, csv,os,time
#testFile1="./testImages/AU-001-def.1per.jpg"
#testFile2="/home/mende012/monoliths/Photos-original/AU-001-def.tif"
#print dir(GExiv2)['LogLevel', 'MAJOR_VERSION', 'MICRO_VERSION', 'MINOR_VERSION', 'Metadata', 'MetadataClass', 'MetadataPrivate', 'Orientation', 'PreviewImage', 'PreviewImageClass', 'PreviewImagePrivate', 'PreviewProperties', 'PreviewPropertiesClass', 'PreviewPropertiesPrivate'
import geocoder
#Elevation should be comming from Google Maps API
#g = geocoder.elevation([51.9667,5.6667]) #'<address or [lat,lng]>' 51.9667 N, 5.6667 E (y,x)
#print (g.meters)
import shapely.wkb
#PASS OP POINT (-37 -7.266666666666667) this is reverse from geocoder.elevation
#print tag,":", metadata[tag]
#metadata.set_gps_info(-79.3969702721, 43.6295057244, 76)
#exif.save_file()
#print('Photo taken at:', metadata.get_gps_info())
#print('Altitude:', metadata.get_exif_tag_rational('Exif.GPSInfo.GPSAltitude'))
def profileCorrector(profile_code):
# convernts from AU012 --> AU-012
returnString=profile_code[0:2]+"-"+profile_code[2:]
return returnString
fileList=glob.glob("/home/mende012/monoliths/Photos-original_work/original/jpg/*.jpg")
with open('./profilesCodeGeom.csv', mode="r") as csvfile:
reader= csv.DictReader(csvfile)
Data = namedtuple("Data",reader.fieldnames)
for row in reader:
tupleProfiles = [Data(**row) for row in reader ] #a if c else b for item in list]
for profile in tupleProfiles:
profileCode = profileCorrector(profile.profile_code)
res=[x for x in fileList if re.search(profileCode, x)]
if res:
#loop file list add coordinates
for fileImage in res: # we have multiple images
Point=shapely.wkb.loads(profile.geom,hex=True)
#g = geocoder.elevation([Point.y,Point.x]) #'<address or [lat,lng]>' 51.9667 N, 5.6667 E (y,x)
print Point, os.path.basename(fileImage),float(profile.elev)
#time.sleep(0.1) #lets no overload the web service otherwise we dont get the elevation
metadata = GExiv2.Metadata(fileImage)
#metadata.set_gps_info(Point.x, Point.y, g.meters) # (longitude, latitude, altitude) (x,y)
metadata.set_gps_info(Point.x, Point.y,float(profile.elev))
metadata.save_file()
print "All done"
...@@ -12,28 +12,19 @@ import glob, re, csv,os,time ...@@ -12,28 +12,19 @@ import glob, re, csv,os,time
#testFile2="/home/mende012/monoliths/Photos-original/AU-001-def.tif" #testFile2="/home/mende012/monoliths/Photos-original/AU-001-def.tif"
#print dir(GExiv2)['LogLevel', 'MAJOR_VERSION', 'MICRO_VERSION', 'MINOR_VERSION', 'Metadata', 'MetadataClass', 'MetadataPrivate', 'Orientation', 'PreviewImage', 'PreviewImageClass', 'PreviewImagePrivate', 'PreviewProperties', 'PreviewPropertiesClass', 'PreviewPropertiesPrivate' #print dir(GExiv2)['LogLevel', 'MAJOR_VERSION', 'MICRO_VERSION', 'MINOR_VERSION', 'Metadata', 'MetadataClass', 'MetadataPrivate', 'Orientation', 'PreviewImage', 'PreviewImageClass', 'PreviewImagePrivate', 'PreviewProperties', 'PreviewPropertiesClass', 'PreviewPropertiesPrivate'
import geocoder
#Elevation should be comming from Google Maps API
#g = geocoder.elevation([51.9667,5.6667]) #'<address or [lat,lng]>' 51.9667 N, 5.6667 E (y,x)
#print (g.meters)
import shapely.wkb import shapely.wkb
#PASS OP POINT (-37 -7.266666666666667) this is reverse from geocoder.elevation
#print tag,":", metadata[tag]
#metadata.set_gps_info(-79.3969702721, 43.6295057244, 76)
#exif.save_file()
#print('Photo taken at:', metadata.get_gps_info())
#print('Altitude:', metadata.get_exif_tag_rational('Exif.GPSInfo.GPSAltitude'))
def profileCorrector(profile_code): def profileCorrector(profile_code):
# convernts from AU012 --> AU-012 # convernts from AU012 --> AU-012
returnString=profile_code[0:2]+"-"+profile_code[2:] returnString=profile_code[0:2]+"-"+profile_code[2:]
return returnString return returnString
fileList=glob.glob("/home/mende012/monoliths/Photos-original_work/original/png/*.png") fileListJPG = glob.glob("/home/mende012/monoliths/Photos-original_work/original/jpg/*.jpg")
fileListPNG = glob.glob("/home/jesus/git/wsm.rest/imageProcessing/tmp3/original/png/*.png")
fileListTIFF = glob.glob("/home/jesus/git/wsm.rest/imageProcessing/tmp3/original/tif/*.tif")
with open('./profilesCodeGeom.csv', mode="r") as csvfile: with open('./profilesCodeGeom2.csv', mode="r") as csvfile:
reader= csv.DictReader(csvfile) reader= csv.DictReader(csvfile)
Data = namedtuple("Data",reader.fieldnames) Data = namedtuple("Data",reader.fieldnames)
...@@ -47,11 +38,12 @@ for profile in tupleProfiles: ...@@ -47,11 +38,12 @@ for profile in tupleProfiles:
if res: if res:
#loop file list add coordinates #loop file list add coordinates
for fileImage in res: # we have multiple images for fileImage in res: # we have multiple images
print os.path.basename(fileImage) print("Doing:{}".format(fileImage))
metadata = GExiv2.Metadata(fileImage) Point=shapely.wkb.loads(profile.geom,hex=True)
#metadata.set_gps_info(Point.x, Point.y, g.meters) # (longitude, latitude, altitude) (x,y) try:
metadata = GExiv2.Metadata(fileImage)
metadata.set_comment("WOSIS:"+profile.profile_id+","+"ISIS:"+profile.profile_code) metadata.set_gps_info(Point.x, Point.y,0) # (longitude, latitude, altitude) (x,y)
#metadata.set_gps_info(Point.x, Point.y,float(profile.elev)) metadata.save_file()
metadata.save_file() except:
print "All done" print("failed picture: {}".format(fileImage))
print("All done")
\ No newline at end of file
#Generic script that add all metadata ti what ever pic #Generic script that add all metadata ti what ever pic this only on JPG images, PNG supported GLib.Error: GExiv2: unsupported format (501)
from gi.repository import GExiv2 from gi.repository import GExiv2
import glob import glob
fileImageList=glob.glob("/home/mende012/monoliths/Photos-original_work/original/jpg/*.jpg")
fileImageListTIF=glob.glob("/home/jesus/git/wsm.rest/imageProcessing/tmp3/original/tif/*.tif")
fileImageListJPG=glob.glob("/home/jesus/git/wsm.rest/imageProcessing/tmp3/original/jpg/*.jpg")
fileImageList = fileImageListTIF + fileImageListJPG
for image in fileImageList: for image in fileImageList:
print "Doing:%s" % image print("Doing:%s" % image)
metadata = GExiv2.Metadata(image) metadata = GExiv2.Metadata(image)
#print metadata.get_exif_tags() #print metadata.get_exif_tags()
#for tag in metadata.get_exif_tags(): #for tag in metadata.get_exif_tags():
...@@ -16,4 +21,4 @@ for image in fileImageList: ...@@ -16,4 +21,4 @@ for image in fileImageList:
#metadata.set_comment("WOSIS:63670,ISIS:AU002,WRB2004:Solonetzs") #metadata.set_comment("WOSIS:63670,ISIS:AU002,WRB2004:Solonetzs")
#metadata.set_tag_string("Iptc.Application2.Keywords","Test,Foo") # Doesnt work #metadata.set_tag_string("Iptc.Application2.Keywords","Test,Foo") # Doesnt work
metadata.save_file() metadata.save_file()
print "Done" print("Done")
\ No newline at end of file \ No newline at end of file
...@@ -4,7 +4,7 @@ from collections import namedtuple ...@@ -4,7 +4,7 @@ from collections import namedtuple
import glob import glob
fileList=glob.glob("/home/mende012/monoliths/Photos-original_work/orginal/tif/*.tif") fileList=glob.glob("/home/mende012/monoliths/Photos-original_work/orginal/tif/*.tif")
print fileList print(fileList)
def profileCorrector(profile_code): def profileCorrector(profile_code):
# convernts from AU012 --> AU-012 # convernts from AU012 --> AU-012
returnString=profile_code[0:2]+"-"+profile_code[2:] returnString=profile_code[0:2]+"-"+profile_code[2:]
......
#compiles a list of images without coordinates form ISIS #compiles a list of images without coordinates form ISIS
import csv,re,os import csv, re, os
from collections import namedtuple from collections import namedtuple
import glob import glob
fileList=glob.glob("/home/mende012/monoliths/Photos-original_work/original/tif/*.tif") fileList = glob.glob("/home/jesus/git/wsm.rest/imageProcessing/tmp2/original/tif/*.tif")
#fileList = glob.glob("/home/mende012/monoliths/Photos-original_work/original/tif/*.tif")
#print fileList #print fileList
fileList.sort() fileList.sort()
...@@ -16,7 +17,6 @@ with open('./profilesCodeGeom.csv', mode="r") as csvfile: ...@@ -16,7 +17,6 @@ with open('./profilesCodeGeom.csv', mode="r") as csvfile:
reader= csv.DictReader(csvfile) reader= csv.DictReader(csvfile)
Data = namedtuple("Data",reader.fieldnames) Data = namedtuple("Data",reader.fieldnames)
for row in reader: for row in reader:
...@@ -24,7 +24,7 @@ with open('./profilesCodeGeom.csv', mode="r") as csvfile: ...@@ -24,7 +24,7 @@ with open('./profilesCodeGeom.csv', mode="r") as csvfile:
#print tupleProfiles[0] #print tupleProfiles[0]
f1=open("profilesCodeGeomPicture.csv","w") f1=open("profilesCodeGeomPicture2.csv","w")
f1.write("country_id,geom,elev,profile_id,profile_code,profile_code,image\n") f1.write("country_id,geom,elev,profile_id,profile_code,profile_code,image\n")
for file in fileList: for file in fileList:
...@@ -36,4 +36,4 @@ for file in fileList: ...@@ -36,4 +36,4 @@ for file in fileList:
else: else:
#just jump the data tumple #just jump the data tumple
pass pass
print "Done" print("Done")
\ No newline at end of file \ No newline at end of file
#aniso8601==1.3.0 aniso8601==1.3.0
click==6.7 click==6.7
Flask==0.12.2 Flask==0.12.2
Flask-Cors==3.0.6 Flask-Cors==3.0.6
......
...@@ -43,7 +43,7 @@ class MonolithRoot(Resource): ...@@ -43,7 +43,7 @@ class MonolithRoot(Resource):
listDir=[o for o in os.listdir(monolithsPath) if os.path.isdir(os.path.join(monolithsPath,o))] listDir=[o for o in os.listdir(monolithsPath) if os.path.isdir(os.path.join(monolithsPath,o))]
response = json.dumps(listDir) response = json.dumps(listDir)
return make_response(response,200,headers) return make_response(response,200,headers)
class CloseBy(Resource): class CloseBy(Resource):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment