Python 轨道区域检测(基于霍夫变换)

该博客介绍了一种图像处理方法,包括从图片中裁剪ROI区域、灰度转换、高斯模糊、Canny边缘检测和霍夫变换。通过过滤直线并根据斜率找到主要线条,绘制轨道区域。涉及的技术包括边缘检测、直线检测和图像分割。

效果演示:(顺时针方向 - Ori-image(裁剪过)/After canny/Final area/Hough lines)

在这里插入图片描述

在这里插入图片描述

Main

def getline(imgpath):

    save_Edges = True
    save_Lines = True

    # Default - rate = 0.25
    img, general_point = img_Preprocess(imgpath)  
    gray, edges, orgb, orgb_lines, lines = mask_Preprocess(img, general_point)
	filted_lines, slopes = line_filter(lines)
    try:
        orgb, orgb_lines = draw_rail(orgb, orgb_lines, filted_lines, slopes)
    except:
        pass

    return orgb_lines,edges, orgb

1.传入图片路径或者图片 对应ROI区域坐标(默认为原图中间1/2大小区域)

def img_Preprocess(imgpath, rate = 0.25):

    if str(imgpath):
        img = cv2.imread(imgpath)
    else :
        img = imgpath

    h, w = img.shape[:2]
    left_top, right_top, right_buttom, left_buttom = (int(w * rate), int(h * rate)), \
                                                     (int(w 
评论 21
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值