def hough_vertical(edges, fn=None, hough_line_len=30, line_gap=5, save=False, show=False, raw=None, xdiff=0, ydiff=0): height = edges.shape[0] width = edges.shape[1] div = 9 hough_end = 0 + math.pi/div hough_start = 0 - math.pi/div hough_gap = 0.001 hough_angle = np.arange(hough_start,hough_end, hough_gap) lines_ret = probabilistic_hough_line(edges, threshold=30, line_gap=line_gap,line_length=hough_line_len, theta=hough_angle) from src.utils.util import tuple2list lines = tuple2list(lines_ret) from src.utils.util import changecoord if xdiff != 0 and ydiff !=0: lines= changecoord(lines, xdiff, ydiff) if lines is not None: if save is True or show is True: if raw is None: logging.error('background image is not provided') sys.exit(1) from src.utils.io import add_lines raw = add_lines(lines, raw) if show is True: raw.show() if save is True: raw.save(fn + '.jpg') return lines, raw
def my_hough_2(edges, hough_start, hough_end, hough_line_len=30, line_gap=50, fn = None, show=False, raw=None, xdiff=0, ydiff=0): height = edges.shape[0] width = edges.shape[1] hough_gap = 0.001 hough_angle = np.arange(hough_start,hough_end, hough_gap) lines_ret = probabilistic_hough_line(edges, threshold=30, line_gap=line_gap,line_length=hough_line_len, theta=hough_angle) from src.utils.util import tuple2list lines_temp1 = tuple2list(lines_ret) from src.utils.util import sortlines_len lines = sortlines_len(lines_temp1) from src.utils.util import changecoord if xdiff != 0 and ydiff != 0: lines = changecoord(lines, xdiff=xdiff, ydiff=ydiff) if lines is not None: if show is True: if raw is None: logging.error('background image is not provided') sys.exit(1) from src.utils.io import add_lines raw = add_lines(lines, raw) return lines, raw