Exemplo n.º 1
0
def get_image(filename,label_num_dic = None):
    tVocParseReader = PascalVocReader(filename)
    raw_shapes = tVocParseReader.getShapes()
    print raw_shapes
    def format_shape(s):
        label,points,aa,bb,c = s
        return dict(label=unicode(label),
                    points=[(int(p[0]), int(p[1])) for p in points])

    shapes = [format_shape(shape) for shape in raw_shapes]
    image_size = tVocParseReader.get_img_size()
    result_path = '/mask'+filename.split('/')[1].split('.')[0]+'.png'
    mask_writer = save_mask_image.label_mask_writer(label_num_dic, result_path, image_size[0],
                                                    image_size[1])
    mask_writer.save_mask_image(shapes)
Exemplo n.º 2
0
def generate_mask_png(label_num_dic, xml_file_name, output_path):
    if os.path.exists(output_path) is False:
        os.makedirs(output_path)
    tVocParseReader = PascalVocReader(xml_file_name)
    shapes = tVocParseReader.getShapes()
    image_size = tVocParseReader.get_img_size()

    num = 1
    no_ext_name = os.path.splitext(xml_file_name)

    for shape in shapes:
        final_path = no_ext_name + u'_' + unicode(num) + '.png'
        mask_writer = label_mask_writer(label_num_dic, final_path,
                                        image_size[0], image_size[1])
        mask_writer.save_mask_image(shapes)
        num = num + 1
Exemplo n.º 3
0
def get_image(filename, label_num_dic=None):
    tVocParseReader = PascalVocReader(filename)
    raw_shapes = tVocParseReader.getShapes()
    print raw_shapes

    def format_shape(s):
        label, points, aa, bb, c = s
        return dict(label=unicode(label),
                    points=[(int(p[0]), int(p[1])) for p in points])

    shapes = [format_shape(shape) for shape in raw_shapes]
    image_size = tVocParseReader.get_img_size()
    result_path = '/mask' + filename.split('/')[1].split('.')[0] + '.png'
    mask_writer = save_mask_image.label_mask_writer(label_num_dic, result_path,
                                                    image_size[0],
                                                    image_size[1])
    mask_writer.save_mask_image(shapes)