转载请注明出处 https://blog.csdn.net/gloria_iris/article/details/91625656


本博文是优达城Finding Lane Lines项目的总结,主要实现车道线识别功能。课程连接:https://classroom.udacity.com/nanodegrees/nd013-cn-preview/parts/b2c3eb3d-8c52-4b8c-9d68-6af6d02a27b8/modules/91f01fb3-48a0-4c5a-a20d-3570261a18c3/lessons/44eca098-2fbb-45d8-81b6-d16b245b4af4/concepts/5ab569c2-d833-4dd4-9f85-b84afe3e0d38

1. 颜色选择

彩色图像通常是由RGB通道的三幅图像叠加而成的,RGB的变化范围都是[0, 255]。通过三通道颜色的阈值选择,可以得到一幅简单的二值化图像。

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np# Read in the image
image = mpimg.imread('test.jpg') # Grab the x and y size and make a copy of the image
ysize = image.shape[0]
xsize = image.shape[1]
color_select = np.copy(image)# Define color selection criteria
red_threshold = 200
green_threshold = 200
blue_threshold = 200rgb_threshold = [red_threshold, green_threshold, blue_threshold]# Do a boolean or with the "|" character to identify
# pixels below the thresholds
thresholds = (image[:,:,0] < rgb_threshold[0]) \| (image[:,:,1] < rgb_threshold[1]) \| (image[:,:,2] < rgb_threshold[2])
color_select[thresholds] = [0,0,0]# Display the image
plt.imshow(color_select)


                                     原图                                                                            颜色选择后的图像

2. ROI选择

二值化后还是会有很多其他干扰像素。此处只选择感兴趣区域ROI的掩码,即车道线所在的范围。

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np# Read in the image and print some stats
image = mpimg.imread('test.jpg')# Pull out the x and y sizes and make a copy of the image
ysize = image.shape[0]
xsize = image.shape[1]
region_select = np.copy(image)# Define a triangle region of interest
# Keep in mind the origin (x=0, y=0) is in the upper left in image processing
# Note: if you run this code, you'll find these are not sensible values!!
# But you'll get a chance to play with them soon in a quiz
left_bottom = [0, 539]
right_bottom = [900, 300]
apex = [400, 0]# Fit lines (y=Ax+B) to identify the  3 sided region of interest
# np.polyfit() returns the coefficients [A, B] of the fit
fit_left = np.polyfit((left_bottom[0], apex[0]), (left_bottom[1], apex[1]), 1)
fit_right = np.polyfit((right_bottom[0], apex[0]), (right_bottom[1], apex[1]), 1)
fit_bottom = np.polyfit((left_bottom[0], right_bottom[0]), (left_bottom[1], right_bottom[1]), 1)# Find the region inside the lines
XX, YY = np.meshgrid(np.arange(0, xsize), np.arange(0, ysize))
region_thresholds = (YY > (XX*fit_left[0] + fit_left[1])) & \(YY > (XX*fit_right[0] + fit_right[1])) & \(YY < (XX*fit_bottom[0] + fit_bottom[1]))# Color pixels red which are inside the region of interest
region_select[region_thresholds] = [255, 0, 0]# Display the image
plt.imshow(region_select)
plt.show()

3. 颜色选择和ROI结合

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np# Read in the image
image = mpimg.imread('test.jpg')# Grab the x and y sizes and make two copies of the image
ysize = image.shape[0]
xsize = image.shape[1]
color_select= np.copy(image)
line_image = np.copy(image)# Define our color criteria
red_threshold = 200
green_threshold = 200
blue_threshold = 200
rgb_threshold = [red_threshold, green_threshold, blue_threshold]# Define a triangle region of interest (Note: if you run this code,
# Keep in mind the origin (x=0, y=0) is in the upper left in image processing
# you'll find these are not sensible values!!
# But you'll get a chance to play with them soon in a quiz ;)
left_bottom = [0, 539]
right_bottom = [900, 539]
apex = [475, 320]# Perform a linear fit (y=Ax+B) to each of the three sides of the triangle
# np.polyfit returns the coefficients [A, B] of the fit
fit_left = np.polyfit((left_bottom[0], apex[0]), (left_bottom[1], apex[1]), 1)
fit_right = np.polyfit((right_bottom[0], apex[0]), (right_bottom[1], apex[1]), 1)
fit_bottom = np.polyfit((left_bottom[0], right_bottom[0]), (left_bottom[1], right_bottom[1]), 1)# Mask pixels below the threshold
color_thresholds = (image[:,:,0] < rgb_threshold[0]) | \(image[:,:,1] < rgb_threshold[1]) | \(image[:,:,2] < rgb_threshold[2])# Find the region inside the lines
XX, YY = np.meshgrid(np.arange(0, xsize), np.arange(0, ysize))
region_thresholds = (YY > (XX*fit_left[0] + fit_left[1])) & \(YY > (XX*fit_right[0] + fit_right[1])) & \(YY < (XX*fit_bottom[0] + fit_bottom[1]))
# Mask color selection
color_select[color_thresholds] = [0,0,0]
# Find where image is both colored right and in the region
line_image[~color_thresholds & region_thresholds] = [255,0,0]# Display the image and show region and color selections
plt.imshow(image)
x = [left_bottom[0], right_bottom[0], apex[0], left_bottom[0]]
y = [left_bottom[1], right_bottom[1], apex[1], left_bottom[1]]
plt.plot(x, y, 'b--', lw=4)
plt.imshow(color_select)
plt.imshow(line_image)


                                          原图像                                二值图像                         车道线识别结果

车道线识别(一) 简单识别相关推荐

  1. PreScan快速入门到精通第三十九讲基于车道线识别传感器的车道保持辅助算法Demo讲解

    车道保持辅助系统介绍: 什么是车道保持辅助系统? 疲劳和分心是无意中偏离车辆行驶车道线的最常见原因.车道保持辅助系统主动帮助驾驶者将其车辆保持在车道内,避免或者降低事故的发生. 车道保持辅助系统使用一 ...

  2. MATLAB 数字图像处理---车牌简单识别【亲测有效】

    文章内容:利用 MATLAB 对图像进行简单处理,包括图像的模糊.锐化.和直方图均衡化:对图像进行边缘检测:并对利用 MATLAB 对图像中的数字提取识别. 目录 1 MATLAB 对图像进行简单处理 ...

  3. ECCV2020 | Gen-LaneNet:百度Apollo提出两阶段的3D车道线检测算法,已开源

    点击上方"3D视觉工坊",选择"星标 干货第一时间送达 这篇文章收录于ECCV2020,是百度Apollo团队发表的关于3D车道线检测的文章,针对3D-LaneNet做了 ...

  4. LIDAR系列之2:用激光雷达检测车道线

    转自:https://www.sohu.com/a/207740445_391994 基于视觉系统的车道线检测有诸多缺陷 首先是视觉系统对背景光线很敏感,诸如阳光强烈的林荫道,车道线被光线分割成碎片, ...

  5. 基于边缘检测与Hough变换的车道线检测

    基于边缘检测与Hough变换的车道线检测 第一章:绪论 1.1 研究意义及背景 高速公路的通行里程是一个国家发展水平的重要标志之一.高速公路具有车辆通行能力大.交通事故少.经济效益高的特点,它的不断发 ...

  6. 无人驾驶汽车系统入门(六)——基于传统计算机视觉的车道线检测(1)

    无人驾驶汽车系统入门(六)--基于传统计算机视觉的车道线检测(1) 感知,作为无人驾驶汽车系统中的"眼睛",是目前无人驾驶汽车量产和商用化的最大障碍之一(技术角度), 目前,高等级 ...

  7. 学习笔记之车道线相关记录

    一. 车道线相关的知识 &&1.标线的分类 以下分类来自于百科: 按照道路交通标线的功能划分为:指示标线.警告标线和禁止标线. 按标划方法可分为:白色虚线.白色实线.黄色虚线.黄色实线 ...

  8. 空间中的语义直线检测_基于语义分割的车道线检测算法研究

    龙源期刊网 http://www.qikan.com.cn 基于语义分割的车道线检测算法研究 作者:张道芳 张儒良 来源:<科技创新与应用> 2019 年第 06 期 摘 ; 要:随着半自 ...

  9. 怎么样利用激光雷达检测车道线?这上面提供了4个方法---凯利讯半导体

    通过理论分析和实验验证可知一二两层返回的信息主要包括路面.车道线.少量障碍物和边界数据;三四两层主要返回道路边界.障碍物和少量路表信息,所以在特征种子点提取阶段需要重点分析一二两层的雷达数据,这部分数 ...

  10. 通用汽车研发中心最新提出:3D车道线检测新方法

    点上方蓝字计算机视觉联盟获取更多干货 在右上方 ··· 设为星标 ★,与你不见不散 仅作分享,不代表本公众号立场,侵权联系删除 转载于:知乎黄浴博士,已获授权 https://zhuanlan.zhi ...

最新文章

  1. ASP.NET MVC 1.0 NVelocityViewEngine
  2. 测试和恢复性的争论:面向对象vs.函数式编程
  3. AngularJS基于MVC的复杂操作案例
  4. 执行虚拟机mysql脚本_mysql一键执行脚本 超方便!!!
  5. 【图片识别】java 图片文字识别 ocr (转)
  6. Hdoj 1847.Good Luck in CET-4 Everybody! 题解
  7. 获取网站服务器数据库,利用XmlHttp获取服务器数据库数据以表格的方式返回客户的代码示例...
  8. 如何在Angular.JS中打开JSON / XML文件
  9. 周年直播倒计时2天,攒足惊喜等你开场! | MindSpore 开源一周年
  10. K-摇臂赌博机算法与实现
  11. 鸟哥的Linux私房菜第零章
  12. Java 视频资源分享(干货)
  13. http状态码大全(最全整理)
  14. 安装SHARP MX-3618NC PCL6打印机驱动程序
  15. leapftp怎么下载文件,用leapftp怎么下载文件
  16. C#WPF内存回收与释放LierdaCracker
  17. 16年,平凡而又收获的一年,android底层开发实战
  18. 用计算机计算根号2^2-1÷,2根号2(万能计算器在线使用)
  19. linux 下 安装Gdrive来实现谷歌云盘同步文件ps 可能出现 Error 404: File not found
  20. PHP使用声网的页面录制、合流录制、单流录制

热门文章

  1. 那些在一个公司死磕了5-10年的人,最后都怎么样了?那些在一个公司死磕了5-10年的人,最后都怎么样了?...
  2. golang 调度之wakep和M创建
  3. 二十、JVM命令行监控工具
  4. Python图像处理(13):brisk特征检测
  5. 在Java中计算一元线性回归
  6. MySQL索引的数据结构及算法原理
  7. 使用php实现自动获取一个获取文章标题生成主题关键词功能源码
  8. 保送清华计算机,高二学霸保送清华,怎么做到的?
  9. Element-ui 一些容易忽略的知识点
  10. PopupWindow