def filter_and_bbox(imageIn):
    from gamera.toolkits.ocr.classes import Page
    my_filter(imageIn)
    #p = StepTwo(imageIn)
    p = Page(imageIn)
    p.segment()
    return show_lines(p)
예제 #2
0
        print "rotated with", rotation, "angle"

if (opt.auto_group):
    cknn = knn.kNNInteractive(
        [], ["aspect_ratio", "volume64regions", "moments", "nholes_extended"],
        0)
    cknn.from_xml_filename(opt.trainfile)
    if (opt.ccsfilter):
        the_ccs = ccs
    else:
        the_ccs = img.cc_analysis()
    median_cc = int(median([cc.nrows for cc in the_ccs]))
    autogroup = ClassifyCCs(cknn)
    autogroup.parts_to_group = 3
    autogroup.grouping_distance = max([2, median_cc / 8])
    p = Page(img, classify_ccs=autogroup)
    if opt.verbosity > 0:
        print "autogrouping glyphs activated."
        print "maximal autogroup distance:", autogroup.grouping_distance
else:
    p = Page(img)

if opt.verbosity > 0:
    print "start page segmentation..."
    t = time.time()

p.segment()

if opt.verbosity > 0:
    t = time.time() - t
    print "\t segmentation done [", t, "sec]"