Ejemplo n.º 1
0
def make_sliding_strips_from_box(boxfilename):
    basename = get_basename(boxfilename)

    # create the output directory for all the files I'm about to create
    output_dir = make_output_dir(basename)
    #    return

    box_list = zonebox.load_boxes(boxfilename)

    # load the image associated with this box list
    # assume all the boxes have the same image name (they should)
    imgfilename = "IMAGEBIN/{0}BIN.png".format(box_list[0].document_id)

    # get the image as a numpy array
    data = mkslices.load_image(imgfilename)

    strip_list = make_all_strips_images(data, basename, output_dir)

    #
    # Now make the ground truth files for each strip
    #

    # convert the box list into a list of strips
    box_strip_list = [rects.Strip(box=box) for box in box_list]

    # slice up the ground truth into individual XML files
    make_all_gtruth_xml(box_strip_list, data, output_dir, basename)
Ejemplo n.º 2
0
def make_sliding_strips_from_box( boxfilename ) :
    basename = get_basename( boxfilename )

    # create the output directory for all the files I'm about to create
    output_dir = make_output_dir(basename)
#    return
    
    box_list = zonebox.load_boxes( boxfilename ) 

    # load the image associated with this box list
    # assume all the boxes have the same image name (they should)
    imgfilename = "IMAGEBIN/{0}BIN.png".format( box_list[0].document_id )

    # get the image as a numpy array
    data = mkslices.load_image( imgfilename )

    strip_list = make_all_strips_images( data, basename, output_dir )

    # 
    # Now make the ground truth files for each strip
    #
    
    # convert the box list into a list of strips
    box_strip_list = [ rects.Strip(box=box) for box in box_list ]

    # slice up the ground truth into individual XML files 
    make_all_gtruth_xml( box_strip_list, data, output_dir, basename ) 
Ejemplo n.º 3
0
def awinder():
    # slice up Amy Winder's images
    output_dir_base = "{0}_winder/".format(num_rows_in_strip)
    #    output_dir_base = "300_winder/"

    for imgfilename in sys.argv[1:]:
        basename = get_basename(imgfilename)

        input_path = os.path.dirname(imgfilename)
        # get rid of the trailing "/png" component (it's annoying)
        input_path = input_path.replace("/png", "/")

        output_dir = output_dir_base + input_path + basename
        print output_dir

        if os.path.exists(output_dir):
            print "{0} exists so assume files are OK".format(output_dir)
            continue
        else:
            os.makedirs(output_dir)

        make_sliding_strips_from_image(imgfilename, output_dir)

        xmlfilename = imgfilename.replace(".png", ".xml")
        xmlfilename = xmlfilename.replace("png", "gTruth")
        print xmlfilename

        try:
            zone_list = gtruthxml.parse_xml(xmlfilename)
        except IOError, e:
            if e.errno == 2:
                # some of the files are living in a ./xml subdir
                xmlfilename = imgfilename.replace(".png", ".xml")
                xmlfilename = xmlfilename.replace("png", "gTruth/xml")
                zone_list = gtruthxml.parse_xml(xmlfilename)
            else:
                raise

        print zone_list

        # get the image as a numpy array
        data = mkslices.load_image(imgfilename)

        # slice up the ground truth into individual XML files
        make_all_gtruth_xml(zone_list, data, output_dir, basename)
Ejemplo n.º 4
0
def awinder( ) : 
    # slice up Amy Winder's images 
    output_dir_base = "{0}_winder/".format(num_rows_in_strip)
#    output_dir_base = "300_winder/"

    for imgfilename in sys.argv[1:] :
        basename = get_basename(imgfilename)

        input_path = os.path.dirname(imgfilename)
        # get rid of the trailing "/png" component (it's annoying)
        input_path = input_path.replace( "/png", "/" )

        output_dir = output_dir_base + input_path + basename
        print output_dir

        if os.path.exists(output_dir) : 
            print "{0} exists so assume files are OK".format(output_dir)
            continue
        else:
            os.makedirs(output_dir)

        make_sliding_strips_from_image( imgfilename, output_dir )

        xmlfilename = imgfilename.replace(".png",".xml")
        xmlfilename = xmlfilename.replace("png","gTruth")
        print xmlfilename

        try : 
            zone_list = gtruthxml.parse_xml( xmlfilename )
        except IOError,e:
            if e.errno==2 :
                # some of the files are living in a ./xml subdir
                xmlfilename = imgfilename.replace(".png",".xml")
                xmlfilename = xmlfilename.replace("png","gTruth/xml")
                zone_list = gtruthxml.parse_xml( xmlfilename )
            else :
                raise

        print zone_list

        # get the image as a numpy array
        data = mkslices.load_image( imgfilename )

        # slice up the ground truth into individual XML files 
        make_all_gtruth_xml( zone_list, data, output_dir, basename ) 
Ejemplo n.º 5
0
def make_sliding_strips_from_image(imgfilename, output_dir):
    basename = get_basename(imgfilename)

    # get the image as a numpy array
    data = mkslices.load_image(imgfilename)
    strip_list = make_all_strips_images(data, basename, output_dir)
Ejemplo n.º 6
0
def make_sliding_strips_from_image( imgfilename, output_dir ) : 
    basename = get_basename( imgfilename ) 

    # get the image as a numpy array
    data = mkslices.load_image( imgfilename )
    strip_list = make_all_strips_images( data, basename, output_dir )