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

update and documentation

parent 3bea79f1
......@@ -37,3 +37,13 @@ Finally, detach orderly from the running container with the escape sequence:
`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
#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/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)
Data = namedtuple("Data",reader.fieldnames)
......@@ -47,11 +38,12 @@ for profile in tupleProfiles:
if res:
#loop file list add coordinates
for fileImage in res: # we have multiple images
print os.path.basename(fileImage)
print("Doing:{}".format(fileImage))
Point=shapely.wkb.loads(profile.geom,hex=True)
try:
metadata = GExiv2.Metadata(fileImage)
#metadata.set_gps_info(Point.x, Point.y, g.meters) # (longitude, latitude, altitude) (x,y)
metadata.set_comment("WOSIS:"+profile.profile_id+","+"ISIS:"+profile.profile_code)
#metadata.set_gps_info(Point.x, Point.y,float(profile.elev))
metadata.set_gps_info(Point.x, Point.y,0) # (longitude, latitude, altitude) (x,y)
metadata.save_file()
print "All done"
except:
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
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:
print "Doing:%s" % image
print("Doing:%s" % image)
metadata = GExiv2.Metadata(image)
#print metadata.get_exif_tags()
#for tag in metadata.get_exif_tags():
......@@ -16,4 +21,4 @@ for image in fileImageList:
#metadata.set_comment("WOSIS:63670,ISIS:AU002,WRB2004:Solonetzs")
#metadata.set_tag_string("Iptc.Application2.Keywords","Test,Foo") # Doesnt work
metadata.save_file()
print "Done"
\ No newline at end of file
print("Done")
\ No newline at end of file
......@@ -4,7 +4,7 @@ from collections import namedtuple
import glob
fileList=glob.glob("/home/mende012/monoliths/Photos-original_work/orginal/tif/*.tif")
print fileList
print(fileList)
def profileCorrector(profile_code):
# convernts from AU012 --> AU-012
returnString=profile_code[0:2]+"-"+profile_code[2:]
......
#compiles a list of images without coordinates form ISIS
import csv,re,os
import csv, re, os
from collections import namedtuple
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
fileList.sort()
......@@ -18,13 +19,12 @@ with open('./profilesCodeGeom.csv', mode="r") as 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]
#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")
for file in fileList:
......@@ -36,4 +36,4 @@ for file in fileList:
else:
#just jump the data tumple
pass
print "Done"
\ No newline at end of file
print("Done")
\ No newline at end of file
#aniso8601==1.3.0
aniso8601==1.3.0
click==6.7
Flask==0.12.2
Flask-Cors==3.0.6
......
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