Merge pull request #1123 from pierotofy/exiffix

Handles malformed XMP XML
pull/1131/head
Piero Toffanin 2020-06-19 11:47:18 -04:00 zatwierdzone przez GitHub
commit aacdcec1da
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 16 dodań i 7 usunięć

Wyświetl plik

@ -9,7 +9,7 @@ ExternalProject_Add(${_proj_name}
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
GIT_REPOSITORY https://github.com/OpenDroneMap/OpenSfM/
GIT_TAG 099
GIT_TAG 100
#--Update/Patch step----------
UPDATE_COMMAND git submodule update --init --recursive
#--Configure step-------------

Wyświetl plik

@ -12,7 +12,7 @@ import log
import system
import xmltodict as x2d
from opendm import get_image_size
from xml.parsers.expat import ExpatError
class ODM_Photo:
""" ODMPhoto - a class for ODMPhotos
@ -205,10 +205,12 @@ class ODM_Photo:
self.gps_z_stddev = float(self.get_xmp_tag(tags, '@drone-dji:RtkStdHgt'))
else:
self.set_attr_from_xmp_tag('gps_xy_stddev', tags, [
'@Camera:GPSXYAccuracy'
'@Camera:GPSXYAccuracy',
'GPSXYAccuracy'
], float)
self.set_attr_from_xmp_tag('gps_z_stddev', tags, [
'@Camera:GPSZAccuracy'
'@Camera:GPSZAccuracy',
'GPSZAccuracy'
], float)
if 'DLS:Yaw' in tags:
@ -227,7 +229,6 @@ class ODM_Photo:
# ], float)
self.width, self.height = get_image_size.get_image_size(_path_file)
# Sanitize band name since we use it in folder paths
self.band_name = re.sub('[^A-Za-z0-9]+', '', self.band_name)
@ -267,7 +268,13 @@ class ODM_Photo:
if xmp_start < xmp_end:
xmp_str = img_str[xmp_start:xmp_end + 12]
xdict = x2d.parse(xmp_str)
try:
xdict = x2d.parse(xmp_str)
except ExpatError:
from bs4 import BeautifulSoup
xmp_str = str(BeautifulSoup(xmp_str, 'xml'))
xdict = x2d.parse(xmp_str)
log.ODM_WARNING("%s has malformed XMP XML (but we fixed it)" % self.filename)
xdict = xdict.get('x:xmpmeta', {})
xdict = xdict.get('rdf:RDF', {})
xdict = xdict.get('rdf:Description', {})
@ -400,4 +407,4 @@ class ODM_Photo:
if val > 0:
return val
return None
return None

Wyświetl plik

@ -23,3 +23,5 @@ cryptography==2.8
pyOpenSSL==19.1.0
scikit-learn==0.20
laspy==1.6.0
beautifulsoup4==4.9.1
lxml==4.5.1