コード例 #1
0
def segment(image, addr, extras):
    log = cap.logger(extras, image)
    components = findComponents(image, log)
    log.log(cap.drawComponents(image, components))
    angles = map(lambda comp: findAngle(comp, log), components)
    angles = filter(lambda angle: angle != 0.0 and abs(angle) <= 27.0, angles)
    if len(angles) != 0:
        angle = fsum(angles) / len(angles)
        image = cap.doRotate(image,
                             -angle,
                             fillval=255,
                             interpolation=cv.CV_INTER_NN)
        log.log(image)
        components = findComponents(image)
    assert (len(components) <= nSegs)
    log.log(cap.drawComponents(image, components))
    #components = cap.spltCCs(components, cap.partsFromnSegs5(components), projRadius=5, thresh=2)
    #components = filtCCs(components, (15, 15), 200, 0.2)
    components = map(lambda comp: addBackground(comp, image, bgcolor=96),
                     components)
    segments = map(lambda comp: comp[3], components)
    segments = map(removeBadBackground, segments)
    log.log(cap.joinImagesH(segments))
    segments = map(lambda seg: cap.smoothNoise1(seg, bgcolor=0), segments)
    log.log(cap.joinImagesH(segments))
    cap.processExtras(log.steps, addr, extras, cap.CAP_STAGE_SEGMENT)
    return segments
コード例 #2
0
def preprocess(image, addr, extras):
    log = cap.logger(extras, image)
    alpha, dark = rotAngle(image)
    log.log(dark, False)
    clear = clearNoise(image)
    log.log(clear, False)
    straight = cap.doRotate(clear, -alpha, fillval=0, resize=False, interpolation=cv.CV_INTER_NN)
    #cv.Threshold(straight, straight, 128, 255, cv.CV_THRESH_BINARY)
    log.log(straight)
    cv.Dilate(straight, straight)
    cv.Erode(straight, straight)
    log.log(straight)
    cap.processExtras(log.steps, addr, extras, cap.CAP_STAGE_PREPROCESS)
    return straight
コード例 #3
0
def preprocess(image, addr, extras):
    log = cap.logger(extras, image)
    alpha, dark = rotAngle(image)
    log.log(dark, False)
    clear = clearNoise(image)
    log.log(clear, False)
    straight = cap.doRotate(clear,
                            -alpha,
                            fillval=0,
                            resize=False,
                            interpolation=cv.CV_INTER_NN)
    #cv.Threshold(straight, straight, 128, 255, cv.CV_THRESH_BINARY)
    log.log(straight)
    cv.Dilate(straight, straight)
    cv.Erode(straight, straight)
    log.log(straight)
    cap.processExtras(log.steps, addr, extras, cap.CAP_STAGE_PREPROCESS)
    return straight
コード例 #4
0
ファイル: segment.py プロジェクト: woto/EPC
def segment(image, addr, extras):
    log = cap.logger(extras, image)
    components = findComponents(image, log)
    log.log(cap.drawComponents(image, components))
    angles = map(lambda comp: findAngle(comp, log), components)
    angles = filter(lambda angle: angle != 0.0 and abs(angle) <= 27.0, angles)
    if len(angles) != 0:
        angle = fsum(angles) / len(angles)
        image = cap.doRotate(image, -angle, fillval=255, interpolation=cv.CV_INTER_NN)
        log.log(image)
        components = findComponents(image)
    assert(len(components) <= nSegs)
    log.log(cap.drawComponents(image, components))
    #components = cap.spltCCs(components, cap.partsFromnSegs5(components), projRadius=5, thresh=2)
    #components = filtCCs(components, (15, 15), 200, 0.2)
    components = map(lambda comp: addBackground(comp, image, bgcolor=96), components)
    segments = map(lambda comp: comp[3], components)
    segments = map(removeBadBackground, segments)
    log.log(cap.joinImagesH(segments))
    segments = map(lambda seg: cap.smoothNoise1(seg, bgcolor=0), segments)
    log.log(cap.joinImagesH(segments))
    cap.processExtras(log.steps, addr, extras, cap.CAP_STAGE_SEGMENT)
    return segments
コード例 #5
0
ファイル: train.py プロジェクト: valentyn-yakovlev/captchure
def addRotation(image):
    angle = uniform(-15.0, 15.00000001)
    image = cap.doRotate(image, angle)
    return image
コード例 #6
0
ファイル: train.py プロジェクト: woto/EPC
def addRotation(image):
    angle = uniform(-15.0, 15.00000001)
    image = cap.doRotate(image, angle)
    return image