当前位置: 首页>>代码示例>>Python>>正文


Python DataSet.add_obj方法代码示例

本文整理汇总了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
开发者ID:fireae,项目名称:visiongrader,代码行数:37,代码来源:inria_bool.py

示例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
开发者ID:fireae,项目名称:visiongrader,代码行数:15,代码来源:inria.py

示例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
开发者ID:fireae,项目名称:visiongrader,代码行数:23,代码来源:cmu.py

示例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
开发者ID:fireae,项目名称:visiongrader,代码行数:42,代码来源:eblearn.py


注:本文中的dataset.DataSet.add_obj方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。