本文整理汇总了Python中annotation.Annotation方法的典型用法代码示例。如果您正苦于以下问题:Python annotation.Annotation方法的具体用法?Python annotation.Annotation怎么用?Python annotation.Annotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类annotation
的用法示例。
在下文中一共展示了annotation.Annotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_annotations
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def _load_annotations(self):
f = open(self.file_name,'r')
for line in f:
line = line.strip()
if line != "":
annotations_list = [Annotation(int(begin_index) + 1, int(end_index), time_expression, timex3) for begin_index, end_index, time_expression, timex3 in map(None, *([iter(line.split("\t"))] * 4))]
else:
annotations_list = []
self.annotations.append(annotations_list)
f.close()
# wrapper for java API
示例2: loadLabels
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def loadLabels(self):
filename = self.getLabelFilename()
if not filename or not os.path.isfile(filename):
self.clearAnnotation()
return
# If we have everything and the filename did not change, then we are good
if self.annotation and filename == self.currentLabelFile:
return
# Clear the current labels first
self.clearAnnotation()
try:
self.annotation = Annotation()
self.annotation.fromJsonFile(filename)
except IOError as e:
# This is the error if the file does not exist
message = "Error parsing labels in {0}. Message: {1}".format( filename, e.strerror )
self.statusBar().showMessage(message)
# Remember the filename loaded
self.currentLabelFile = filename
# Remeber the status bar message to restore it later
restoreMessage = self.statusBar().currentMessage()
# Restore the message
self.statusBar().showMessage( restoreMessage )
# Load the labels from file
# Only loads if they exist
# Otherwise the filename is stored and that's it
示例3: json2instanceImg
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def json2instanceImg(inJson,outImg,encoding="ids"):
annotation = Annotation()
annotation.fromJsonFile(inJson)
instanceImg = createInstanceImage( annotation , encoding )
instanceImg.save( outImg )
# The main method, if you execute this script directly
# Reads the command line arguments and calls the method 'json2instanceImg'
示例4: json2labelImg
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def json2labelImg(inJson,outImg,encoding="ids"):
annotation = Annotation()
annotation.fromJsonFile(inJson)
labelImg = createLabelImage( annotation , encoding )
labelImg.save( outImg )
# The main method, if you execute this script directly
# Reads the command line arguments and calls the method 'json2labelImg'
示例5: loadLabels
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def loadLabels(self):
filename = self.getLabelFilename()
if not filename:
self.clearAnnotation()
return
# If we have everything and the filename did not change, then we are good
if self.annotation and filename == self.currentLabelFile:
return
# Clear the current labels first
self.clearAnnotation()
try:
self.annotation = Annotation()
self.annotation.fromJsonFile(filename)
except IOError as e:
# This is the error if the file does not exist
message = "Error parsing labels in {0}. Message: {1}".format( filename, e.strerror )
self.statusBar().showMessage(message)
# Remember the filename loaded
self.currentLabelFile = filename
# Remeber the status bar message to restore it later
restoreMessage = self.statusBar().currentMessage()
# Restore the message
self.statusBar().showMessage( restoreMessage )
# Load the disparity map from file
# Only loads if they exist
示例6: loadLabels
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def loadLabels(self):
filename = self.getLabelFilename()
if not filename:
self.clearAnnotation()
return
# If we have everything and the filename did not change, then we are good
if self.annotation and filename == self.currentLabelFile:
return
# Clear the current labels first
self.clearAnnotation()
try:
self.annotation = Annotation()
self.annotation.fromJsonFile(filename)
except IOError as e:
# This is the error if the file does not exist
message = "Error parsing labels in {0}. Message: {1}".format(filename, e.strerror)
self.statusBar().showMessage(message)
# Remember the filename loaded
self.currentLabelFile = filename
# Remeber the status bar message to restore it later
restoreMessage = self.statusBar().currentMessage()
# Restore the message
self.statusBar().showMessage(restoreMessage)
# Load the disparity map from file
# Only loads if they exist
示例7: appendObject
# 需要导入模块: import annotation [as 别名]
# 或者: from annotation import Annotation [as 别名]
def appendObject(self, label, polygon):
# Create empty annotation object
# if first object
if not self.annotation:
self.annotation = Annotation()
# Search the highest ID
newID = 0
for obj in self.annotation.objects:
if obj.id >= newID:
newID = obj.id + 1
# New object
# Insert the object in the labels list
obj = CsObject()
obj.label = label
obj.polygon = [ Point(p.x(),p.y()) for p in polygon ]
obj.id = newID
obj.deleted = 0
obj.verified = 0
obj.user = getpass.getuser()
obj.updateDate()
self.annotation.objects.append(obj)
# Append to changes
self.addChange( "Created object {0} with label {1}".format( newID, label ) )
# Clear the drawn polygon
self.deselectAllObjects()
self.clearPolygon()
# select the new object
self.mouseObj = 0
self.selectObject()
# Helper for leaving an image
# Returns true if the image can be left, false if not
# Checks for possible changes and asks the user if they should be saved
# If the user says yes, then they are saved and true is returned