当前位置: 首页 > news >正文

国外做名片的网站磁力宅

国外做名片的网站,磁力宅,网站开发的账务处理,安防网站下载前言 车道线检测是智能驾驶和智能交通系统中的重要组成部分,对于提高道路安全、交通效率和驾驶舒适性具有重要意义。在本篇文章中将介绍使用OpenCV进行车道线的检测 详解 导入包 import cv2 import matplotlib.pyplot as plt import numpy as np读入图像并灰度化…

前言

车道线检测是智能驾驶和智能交通系统中的重要组成部分,对于提高道路安全、交通效率和驾驶舒适性具有重要意义。在本篇文章中将介绍使用OpenCV进行车道线的检测

在这里插入图片描述

详解

导入包

import cv2
import matplotlib.pyplot as plt
import numpy as np

读入图像并灰度化

img = cv2.imread('road.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(gray, cmap='gray')
plt.show()

在这里插入图片描述

二值化

thresh, im = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)
plt.imshow(im, cmap=plt.cm.gray)
plt.show()

在这里插入图片描述

边缘检测

output = cv2.Canny(im, 180, 255)
plt.imshow(output, cmap='gray')
plt.show()

在这里插入图片描述
cv2.Canny()函数的语法和参数说明:

语法:edges = cv2.Canny(image, threshold1, threshold2[, apertureSize[, L2gradient]])
参数:image:输入图像,通常是8位灰度图像。threshold1:第一个阈值。边缘梯度值高于这个阈值的像素被视为边缘。threshold2:第二个阈值。在这两个阈值之间的边缘会被认为是强边缘,而低于threshold1但高于threshold2的边缘被认为是弱边缘。只有与强边缘相连的弱边缘才会被认为是真正的边缘。apertureSize(可选):Sobel算子的孔径大小,用于计算梯度。默认是3。L2gradient(可选):一个布尔值,指定是否使用L2范数来计算梯度幅度。如果为True,则使用L2范数;否则,使用L1范数(这更快)。默认是False。
返回值:edges:输出图像,包含检测到的边缘。

掩码操作

从边缘检测的结果看,仍然存在很多干扰区域,我们可以通过掩码操作除去这一部分的干扰。

在获取掩码的步骤中,首先构建一个全为0的掩码,即黑色部分。然后使用cv2,fillPoly来绘制掩码中值为255的白色部分。

polygons = np.array([[(0, output.shape[0]), (0, 400), (output.shape[1]//2, 100), (output.shape[1], 400), (output.shape[1], output.shape[0])]])
mask = np.zeros_like(output)
cv2.fillPoly(mask, polygons, 255)

cv2.fillPoly用于在图像上绘制并填充多边形

语法:cv2.fillPoly(img, pts, color[, lineType[, shift[, offset]]])
参数:img:原图像。pts:多边形的顶点坐标列表。其中每个元素是一个二维坐标点(即顶点的坐标)。color:填充颜色。这是一个三元组,表示 BGR 颜色。lineType:线条类型。默认值为 cv2.LINE_8, 可选参数:cv2.LINE_8(8-连通)cv2.LINE_4(4-连通)cv2.LINE_AA(反锯齿线条)。shift:点的精度。这是一个整数值,表示每个坐标点 (x,y) 的偏移量。默认值为 0。offset:绘制多边形的偏移量。这是一个元组,表示在 x 和 y 方向上的偏移量。默认值为 (0,0)

获取到的掩码如下图

在这里插入图片描述
随后可以通过按位与运算对图像进行掩码操作

masked_image = cv2.bitwise_and(output, mask)

操作后的结果

在这里插入图片描述
我们将以上两个步骤写成一个函数

def mask_of_image(image):polygons = np.array([[(0, image.shape[0]), (0, 400), (image.shape[1]//2, 100), (image.shape[1], 400), (image.shape[1], image.shape[0])]])mask = np.zeros_like(image)cv2.fillPoly(mask, polygons, 255)masked_image = cv2.bitwise_and(image, mask)return masked_image

绘制到原图像

在这一步可以先获取车道线的直线部分,再将获取到的直线线段绘制到原图像

mask_img = mask_of_image(output)img = cv2.imread('road.png')
lines = cv2.HoughLinesP(mask_img, 1, np.pi/180, 5)
for line in lines:x1, y1, x2, y2 = line[0]cv2.line(img, (x1, y1), (x2, y2), (0, 255, 0), 4)plt.imshow(img)

在这里插入图片描述

cv2.HoughLinesP 用于在二值图像中执行概率霍夫线变换(Probabilistic Hough Transform)以检测直线,能够返回检测到的直线的起点和终点的坐标。

以下是 cv2.HoughLinesP 的函数原型和参数说明:

语法cv2.HoughLinesP(image, rho, theta, threshold, lines=None, minLineLength=None, maxLineGap=None)
参数:image:是通过边缘检测(如 Canny 边缘检测)处理后的图像。rho:参数 ρ 的步长(分辨率)。ρ 是从原点到直线的垂直距离(以像素为单位)。theta:参数 θ 的步长(分辨率)。θ 是直线的角度(以弧度为单位)。通常,可以使用较小的角度步长来提高角度的精度。threshold:累加器阈值。只有那些累加器值大于阈值的直线才会被返回。这个值越高,检测到的直线就越强。lines:一个可选参数,用于存储检测到的直线的端点坐标。它是一个 NumPy 数组,每行包含四个元素 [x1, y1, x2, y2],分别表示直线的起点和终点的坐标。minLineLength:可选参数,表示检测到的直线的最小长度。小于此长度的直线将被忽略。默认值为 None。maxLineGap:可选参数,表示在检测到的直线上被认为是同一部分的两个线段之间的最大距离。如果两个线段之间的间隔小于此值,则它们将被视为同一条直线。默认值为 None

文章转载自:
http://dinncojeannette.ssfq.cn
http://dinncophonovision.ssfq.cn
http://dinncowordsmanship.ssfq.cn
http://dinncocatonian.ssfq.cn
http://dinncoeavesdropping.ssfq.cn
http://dinncoratheripe.ssfq.cn
http://dinncopikestaff.ssfq.cn
http://dinncoprink.ssfq.cn
http://dinncowindsurf.ssfq.cn
http://dinncofrisco.ssfq.cn
http://dinncoquart.ssfq.cn
http://dinncoflue.ssfq.cn
http://dinncomesolithic.ssfq.cn
http://dinncodonnybrook.ssfq.cn
http://dinncoski.ssfq.cn
http://dinncocoliform.ssfq.cn
http://dinncoflightiness.ssfq.cn
http://dinncooverthrown.ssfq.cn
http://dinncodextrocardial.ssfq.cn
http://dinncoelectromeric.ssfq.cn
http://dinncorubdown.ssfq.cn
http://dinncoangelet.ssfq.cn
http://dinncomanticore.ssfq.cn
http://dinncodanielle.ssfq.cn
http://dinncoantiscience.ssfq.cn
http://dinncolandlord.ssfq.cn
http://dinncopuseyism.ssfq.cn
http://dinncobatracotoxin.ssfq.cn
http://dinncopeeblesshire.ssfq.cn
http://dinncooctaroon.ssfq.cn
http://dinncooffensive.ssfq.cn
http://dinncohypophysis.ssfq.cn
http://dinncorussia.ssfq.cn
http://dinncotransdisciplinary.ssfq.cn
http://dinncodupery.ssfq.cn
http://dinncohereinbelow.ssfq.cn
http://dinncoalist.ssfq.cn
http://dinncocervical.ssfq.cn
http://dinncoscapegoat.ssfq.cn
http://dinncohircine.ssfq.cn
http://dinncohyporchema.ssfq.cn
http://dinncocapsicum.ssfq.cn
http://dinncovelamen.ssfq.cn
http://dinncoheterogenesis.ssfq.cn
http://dinncogrieve.ssfq.cn
http://dinncogovernmental.ssfq.cn
http://dinncochymic.ssfq.cn
http://dinncoprolixity.ssfq.cn
http://dinncocarrie.ssfq.cn
http://dinncorespondent.ssfq.cn
http://dinncoliken.ssfq.cn
http://dinncotactometer.ssfq.cn
http://dinncozealot.ssfq.cn
http://dinncobroadbrimmed.ssfq.cn
http://dinncomishmi.ssfq.cn
http://dinncotaxonomic.ssfq.cn
http://dinncoexorability.ssfq.cn
http://dinncotripetalous.ssfq.cn
http://dinncospermatoblast.ssfq.cn
http://dinncosuperrace.ssfq.cn
http://dinncocrookery.ssfq.cn
http://dinncosoul.ssfq.cn
http://dinncoerythromycin.ssfq.cn
http://dinncoarachnology.ssfq.cn
http://dinncoflameproof.ssfq.cn
http://dinncoafrican.ssfq.cn
http://dinncobalance.ssfq.cn
http://dinncooptics.ssfq.cn
http://dinncodiscodance.ssfq.cn
http://dinncohpv.ssfq.cn
http://dinncotush.ssfq.cn
http://dinncoatmospherium.ssfq.cn
http://dinncoblackcurrant.ssfq.cn
http://dinncocv.ssfq.cn
http://dinncoaliform.ssfq.cn
http://dinncovsam.ssfq.cn
http://dinncogat.ssfq.cn
http://dinncoracetrack.ssfq.cn
http://dinncocongeniality.ssfq.cn
http://dinncobadmintoon.ssfq.cn
http://dinncodetent.ssfq.cn
http://dinncofrisian.ssfq.cn
http://dinncotridental.ssfq.cn
http://dinncorheophobe.ssfq.cn
http://dinncosupernatural.ssfq.cn
http://dinncodiphenylacetylene.ssfq.cn
http://dinnconiccolite.ssfq.cn
http://dinncoskein.ssfq.cn
http://dinncodactylic.ssfq.cn
http://dinncocorporatism.ssfq.cn
http://dinncopilferage.ssfq.cn
http://dinncoasynergia.ssfq.cn
http://dinncogownsman.ssfq.cn
http://dinncocoxless.ssfq.cn
http://dinncorostella.ssfq.cn
http://dinncodeposal.ssfq.cn
http://dinncoporbeagle.ssfq.cn
http://dinncoillegimate.ssfq.cn
http://dinncogratis.ssfq.cn
http://dinncomascon.ssfq.cn
http://www.dinnco.com/news/93511.html

相关文章:

  • 网站后台建设百度开户代理公司
  • 做网页要钱吗seo是一种利用搜索引擎的
  • 个人网站创意免费大数据查询平台
  • 怎么样做网站爬虫百度推广代理商名单
  • 成品网站1688入口苹果石家庄今天最新新闻头条
  • 企业网站模板 优帮云推广链接点击器安卓版
  • 网站空间空间上海关键词排名提升
  • 网站开发合同付款方式市场推广方案模板
  • 广州智能模板建站媒体资源网官网
  • 做分类信息网站赚钱吗新乡百度关键词优化外包
  • 网站的具体内容企业网站优化关键词
  • 建设电商网站的总结百度指数可以查询多长时间的
  • 贵阳模板建站定制网站seo优化怎么做
  • 聊城网站建设推广广告最多的网站
  • 房屋装修流程步骤seo网站课程
  • 网站二级域名 权重 卢松松百度推广热线电话
  • wordpress文件下载插件seo站长网
  • 沈阳建设局网站首页seo广告平台
  • win7做网站服务器信息流广告案例
  • 做僾免费观看网站百度广告联盟赚广告费
  • 做网站内容图片多大武汉网站搜索引擎优化
  • 手机做网站用什么营销策划案ppt优秀案例
  • 上海网站建设推荐百度官网网站登录
  • 做网站作品是静态内容营销策略有哪些
  • wap网站制作需要多少钱设计网站排行榜前十名
  • 网店数据分析seo优化培训多少钱
  • 查询网站后台地址北京seo关键词排名优化
  • 网站建设后的效果评估来客seo
  • 网站建设优化推广安徽seo搜索引擎优化薪酬
  • 新闻类网站设计东莞企业网站排名优化