Esempio n. 1
0
def cut_(origin):
    img = common.bgr2gray_(origin)
    img = common.binary_(img, thresh=config.binary_threshold)

    cut, mask = common.grabCut_(origin, newmask=img)

    return cut
Esempio n. 2
0
def roi_(origin):
    img = common.binary_(origin, thresh=config.binary_threshold)
    img = common.erode_(img)
    img = common.morph_(img)

    img = common.canny_(img)
    contours = common.findContours_(img, origin)

    # FFT 矫正
    roi = common.minAreaRect_(origin, contours)

    return roi
Esempio n. 3
0
def chosen(origin):
    # randon hough
    img = common.binary_(origin, thresh=config.binary_threshold)
    img = common.erode_(img)
    img = common.morph_(img)

    img = common.canny_(img)
    origin = common.hough_lines_p_(img, origin)

    contours = common.findContours_(img, origin)
    roi = common.boundingRect_(origin, contours)

    return roi
Esempio n. 4
0
        plt.subplot(1, 2, 1)
        plt.imshow(img)
        ax = plt.gca()  # 获取到当前坐标轴信息
        ax.xaxis.set_ticks_position('top')  # 将X坐标轴移到上面

        plt.subplot(1, 2, 2)
        plt.imshow(cut)
        ax = plt.gca()  # 获取到当前坐标轴信息
        ax.xaxis.set_ticks_position('top')  # 将X坐标轴移到上面
        plt.show()

    #     ret, cut = cv2.threshold(cut, 100, 255, cv2.THRESH_BINARY)

    return img, cut


if __name__ == '__main__':
    # 0黑色,255白色
    # 11,12,13
    file_name = "../data/img/2.jpg"
    img = cv2.imread(file_name)
    img = common.bgr2gray_(img)
    img = common.binary_(img)

    img, cut = rotate_(img, (1430, 895), (280, 30),
                       30,
                       draw=False,
                       display=True)

    print(cut)