本文整理汇总了Python中dataset.DataSet.add_obj方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.add_obj方法的具体用法?Python DataSet.add_obj怎么用?Python DataSet.add_obj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.add_obj方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import add_obj [as 别名]
def parse(path, crawl = False):
if crawl == True:
raise StandardError()
pos_filename = os.path.join(path, "pos.lst")
neg_filename = os.path.join(path, "neg.lst")
pos_dir = os.path.join(path, "pos")
neg_dir = os.path.join(path, "neg")
if not os.path.isfile(pos_filename):
print "%s is not a file."%(pos_filename,)
return None
if not os.path.isfile(neg_filename):
print "%s is not a file."%(neg_filename,)
return None
if not os.path.isdir(pos_dir):
print "%s is not a directory."%(pos_dir,)
return None
if not os.path.isdir(neg_dir):
print "%s is not a directory."%(neg_dir,)
return None
ret = DataSet()
pos = open(pos_filename, "r")
pos_names = [line[line.rfind("/")+1:] for line in pos.read().split()]
pos.close()
for name in pos_names:
filename = os.path.join(pos_dir, name)
ret.add_obj(name, WholeImage(name))
neg = open(neg_filename, "r")
neg_names = [line[line.rfind("/")+1:] for line in neg.read().split()]
neg.close()
for name in neg_names:
ret.add_empty_image(name)
return ret
示例2: parse
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import add_obj [as 别名]
def parse(path, crawl = False):
if crawl == True:
raise StandardError()
ret = DataSet()
filenames = os.listdir(path)
for filename in filenames:
#TODO : check validity
(fname, width, height, chans, bboxes) \
= parse_file(os.path.join(path, filename))
fname = os.path.basename(fname)
for bbox in bboxes:
ret.add_obj(fname, bbox, height, width)
return ret
示例3: parse
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import add_obj [as 别名]
def parse(filen, crawl = False):
if crawl == True:
raise StandardError()
file = open(filen, "r")
ret = DataSet()
for line in file:
line = line.strip().rstrip()
splited = line.split()
filename = splited[0]
(left_eye_x, left_eye_y, right_eye_x, right_eye_y,
nose_x, nose_y, left_corner_mouth_x, left_corner_mouth_y,
center_mouth_x, center_mouth_y, right_corner_mouth_x,
right_corner_mouth_y) = tuple([float(a) for a in splited[1:]])
ret.add_obj(filename, EyesNoseMouth(Point(left_eye_x, left_eye_y),
Point(right_eye_x, right_eye_y),
Point(nose_x, nose_y),
Point(left_corner_mouth_x, left_corner_mouth_y),
Point(center_mouth_x, center_mouth_y),
Point(right_corner_mouth_x, right_corner_mouth_y)))
file.close()
return ret
示例4: parse
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import add_obj [as 别名]
def parse(filen, crawl = False):
file = open(filen, "r")
ret = DataSet()
for line in file:
line = line.strip().rstrip()
splited = line.split()
filename = splited[0]
# filename = filename[filename.rfind("/")+1:]
# filename = filename[:filename.rfind(".")]
height = int(splited[1])
width = int(splited[2])
class_id = int(splited[3])
(confidence, x, y, x2, y2) = tuple([float(a) for a in splited[4:]])
#if confidence > parse_confidence_min: #TODO
if hratio != None:
height = y2 - y
height2 = height * hratio
y += (height - height2) / 2.0
y2 = y + height2
if wratio != None:
width = x2 - x
width2 = width * wratio
x += (width - width2) / 2.0
x2 = x + width2
if whratio != None:
height = y2 - y
width = x2 - x
width2 = height * whratio
x += (width - width2) / 2.0
x2 = x + width2
bb = BoundingBox(x, y, x2, y2)
area = bb.area()
if (min_area == None or area >= min_area) and \
(max_area == None or area <= max_area):
ret.add_obj(filename, bb)
file.close()
# print summary
print 'Dataset ' + str(filen) + ' has ' + str(len(ret)) + ' images and ' \
+ str(ret.get_nobjs()) + ' positive objects.'
return ret