@@ -795,20 +795,19 @@ def format_shape(s):
795
795
# Can add differrent annotation formats here
796
796
try :
797
797
if self .usingPascalVocFormat is True :
798
- if ustr ( annotationFilePath [- 4 :]) != ".xml" :
798
+ if annotationFilePath [- 4 :]. lower ( ) != ".xml" :
799
799
annotationFilePath += XML_EXT
800
- print ('Img: ' + self .filePath + ' -> Its xml: ' + annotationFilePath )
801
800
self .labelFile .savePascalVocFormat (annotationFilePath , shapes , self .filePath , self .imageData ,
802
801
self .lineColor .getRgb (), self .fillColor .getRgb ())
803
802
elif self .usingYoloFormat is True :
804
- if annotationFilePath [- 4 :] != ".txt" :
803
+ if annotationFilePath [- 4 :]. lower () != ".txt" :
805
804
annotationFilePath += TXT_EXT
806
- print ('Img: ' + self .filePath + ' -> Its txt: ' + annotationFilePath )
807
805
self .labelFile .saveYoloFormat (annotationFilePath , shapes , self .filePath , self .imageData , self .labelHist ,
808
806
self .lineColor .getRgb (), self .fillColor .getRgb ())
809
807
else :
810
808
self .labelFile .save (annotationFilePath , shapes , self .filePath , self .imageData ,
811
809
self .lineColor .getRgb (), self .fillColor .getRgb ())
810
+ print ('Image:{0} -> Annotation:{1}' .format (self .filePath , annotationFilePath ))
812
811
return True
813
812
except LabelFileError as e :
814
813
self .errorMessage (u'Error saving label data' , u'<b>%s</b>' % e )
@@ -1293,13 +1292,13 @@ def saveFile(self, _value=False):
1293
1292
savedFileName = os .path .splitext (imgFileName )[0 ]
1294
1293
savedPath = os .path .join (imgFileDir , savedFileName )
1295
1294
self ._saveFile (savedPath if self .labelFile
1296
- else self .saveFileDialog ())
1295
+ else self .saveFileDialog (removeExt = False ))
1297
1296
1298
1297
def saveFileAs (self , _value = False ):
1299
1298
assert not self .image .isNull (), "cannot save empty image"
1300
1299
self ._saveFile (self .saveFileDialog ())
1301
1300
1302
- def saveFileDialog (self ):
1301
+ def saveFileDialog (self , removeExt = True ):
1303
1302
caption = '%s - Choose File' % __appname__
1304
1303
filters = 'File (*%s)' % LabelFile .suffix
1305
1304
openDialogPath = self .currentPath ()
@@ -1311,7 +1310,10 @@ def saveFileDialog(self):
1311
1310
dlg .setOption (QFileDialog .DontUseNativeDialog , False )
1312
1311
if dlg .exec_ ():
1313
1312
fullFilePath = ustr (dlg .selectedFiles ()[0 ])
1314
- return os .path .splitext (fullFilePath )[0 ] # Return file path without the extension.
1313
+ if removeExt :
1314
+ return os .path .splitext (fullFilePath )[0 ] # Return file path without the extension.
1315
+ else :
1316
+ return fullFilePath
1315
1317
return ''
1316
1318
1317
1319
def _saveFile (self , annotationFilePath ):
0 commit comments