예제 #1
0
def detect_line_hough(img):
    img_edge = edge_detect.full_detect(img, is_binary=False)
    lines = cv2.HoughLinesP(img_edge, 1, np.pi/2, 2, minLineLength=200, maxLineGap=10)

    if lines is not None:
        for x1, y1, x2, y2 in lines[0]:
            # print (x1, y1), (x2, y2)
            cv2.line(img, (x1, y1), (x2, y2), (255, 255, 255), 1)

    return img
예제 #2
0
def compute_skew(img, is_binary=True, canny=True):
    img = edge_detect.full_detect(img, is_binary, canny)

    angle = line_detect.process(img, binary_image=True)[1]
    # angle = line_detect.houghlines(img, binary_image=True)

    angle = -angle if angle < 90 else (180 - angle)
    angle = -(90 - angle) if angle > 45 else angle
    angle = -(90 + angle) if angle < -45 else angle

    return angle
예제 #3
0
def compute_skew(img, is_binary=True, canny=True):
    img = edge_detect.full_detect(img, is_binary, canny)

    angle = line_detect.process(img, binary_image=True)[1]
    # angle = line_detect.houghlines(img, binary_image=True)

    angle = -angle if angle < 90 else (180 - angle)
    angle = -(90 - angle) if angle > 45 else angle
    angle = -(90 + angle) if angle < -45 else angle

    return angle
예제 #4
0
def detect_line_hough(img):
    img_edge = edge_detect.full_detect(img, is_binary=False)
    lines = cv2.HoughLinesP(img_edge,
                            1,
                            np.pi / 2,
                            2,
                            minLineLength=200,
                            maxLineGap=10)

    if lines is not None:
        for x1, y1, x2, y2 in lines[0]:
            # print (x1, y1), (x2, y2)
            cv2.line(img, (x1, y1), (x2, y2), (255, 255, 255), 1)

    return img
예제 #5
0
def detect_line(img):
    img_edge = edge_detect.full_detect(img, is_binary=False)

    sum_x = np.sum(img_edge, axis=0)
    # max_xs = bn.argpartsort(-sum_x, 10)[:10]
    max_xs = sum_x.argsort()[-10:]

    sum_y = np.sum(img_edge, axis=1)
    max_ys = bn.argpartsort(-sum_y, 10)[:10]

    height, width = img_edge.shape[:2]

    for x in max_xs:
        # print (x, 0), (x, height)
        cv2.line(img, (x, 0), (x, height), (255, 255, 255), 1)

    for y in max_ys:
        # print (0, y), (width, y)
        cv2.line(img, (0, y), (width, y), (255, 255, 255), 1)

    return img
예제 #6
0
def detect_line(img):
    img_edge = edge_detect.full_detect(img, is_binary=False)

    sum_x = np.sum(img_edge, axis=0)
    # max_xs = bn.argpartsort(-sum_x, 10)[:10]
    max_xs = sum_x.argsort()[-10:]

    sum_y = np.sum(img_edge, axis=1)
    max_ys = bn.argpartsort(-sum_y, 10)[:10]

    height, width = img_edge.shape[:2]

    for x in max_xs:
        # print (x, 0), (x, height)
        cv2.line(img, (x, 0), (x, height), (255, 255, 255), 1)

    for y in max_ys:
        # print (0, y), (width, y)
        cv2.line(img, (0, y), (width, y), (255, 255, 255), 1)

    return img