Load Pascal xml for each image if setting saved annotation folder
This commit is contained in:
parent
38c9cabb01
commit
3b01871851
24
labelImg.py
24
labelImg.py
@ -705,8 +705,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
|
|
||||||
## Label xml file and show bound box according to its filename
|
## Label xml file and show bound box according to its filename
|
||||||
if self.usingPascalVocFormat is True and \
|
if self.usingPascalVocFormat is True and \
|
||||||
self.changeSavedir is not None:
|
self.defaultSaveDir is not None:
|
||||||
print 'Try to load xml file to the image'
|
basename = os.path.basename(self.filename).split('.')[:-1][0]
|
||||||
|
xmlPath = os.path.join(self.defaultSaveDir, basename + '.xml')
|
||||||
|
self.loadPascalXMLByFilename(xmlPath)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -813,18 +815,14 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
|
|
||||||
path = os.path.dirname(unicode(self.filename))\
|
path = os.path.dirname(unicode(self.filename))\
|
||||||
if self.filename else '.'
|
if self.filename else '.'
|
||||||
|
if self.usingPascalVocFormat:
|
||||||
formats = ['*.%s' % unicode(fmt).lower()\
|
formats = ['*.%s' % unicode(fmt).lower()\
|
||||||
for fmt in QImageReader.supportedImageFormats()]
|
for fmt in QImageReader.supportedImageFormats()]
|
||||||
filters = "Open Annotation XML file (%s)" % \
|
filters = "Open Annotation XML file (%s)" % \
|
||||||
' '.join(formats + ['*.xml'])
|
' '.join(formats + ['*.xml'])
|
||||||
filename = unicode(QFileDialog.getOpenFileName(self,
|
filename = unicode(QFileDialog.getOpenFileName(self,
|
||||||
'%s - Choose a xml file' % __appname__, path, filters))
|
'%s - Choose a xml file' % __appname__, path, filters))
|
||||||
|
self.loadPascalXMLByFilename(filename)
|
||||||
tVocParseReader = PascalVocReader(filename)
|
|
||||||
shapes = tVocParseReader.getShapes()
|
|
||||||
self.loadLabels(shapes)
|
|
||||||
return
|
|
||||||
|
|
||||||
def openDir(self, _value=False):
|
def openDir(self, _value=False):
|
||||||
if not self.mayContinue():
|
if not self.mayContinue():
|
||||||
@ -1037,6 +1035,16 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
else:
|
else:
|
||||||
self.labelHist.append(line)
|
self.labelHist.append(line)
|
||||||
|
|
||||||
|
def loadPascalXMLByFilename(self, filename):
|
||||||
|
if self.filename is None:
|
||||||
|
return
|
||||||
|
if os.path.exists(filename) is False:
|
||||||
|
return
|
||||||
|
|
||||||
|
tVocParseReader = PascalVocReader(filename)
|
||||||
|
shapes = tVocParseReader.getShapes()
|
||||||
|
self.loadLabels(shapes)
|
||||||
|
|
||||||
class Settings(object):
|
class Settings(object):
|
||||||
"""Convenience dict-like wrapper around QSettings."""
|
"""Convenience dict-like wrapper around QSettings."""
|
||||||
def __init__(self, types=None):
|
def __init__(self, types=None):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user