怎么使用opencv实现车道线检测
发表于:2025-11-21 作者:千家信息网编辑
千家信息网最后更新 2025年11月21日,这篇"怎么使用opencv实现车道线检测"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇
千家信息网最后更新 2025年11月21日怎么使用opencv实现车道线检测
这篇"怎么使用opencv实现车道线检测"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇"怎么使用opencv实现车道线检测"文章吧。
效果
void lane_detection(cv::Mat &src, cv::Mat &dst) { dst = cv::Mat::zeros(src.size(),src.type()); cv::Mat grid =cv::Mat::zeros(src.size(),src.type()); int iStep = 25; int iNUmsX = src.cols / iStep; int inUmsY = src.rows / iStep; for(int i = 1; i <= inUmsY; i++) { int yPos = i * iStep + src.cols / 5; cv::Point2d pt1,pt2; int iOffset = 10; pt1.x = 0 + iOffset; pt1.y = yPos; pt2.x = src.cols - iOffset; pt2.y = yPos; cv::line(grid,pt1,pt2,cv::Scalar(255), 1, cv::LINE_4); } for(int i = 1; i <= iNUmsX; i++) int xPos = i * iStep; pt1.x = xPos; pt1.y = 0 + iOffset + src.rows / 5; pt2.x = xPos; pt2.y = src.rows - iOffset; cv::imshow("grid", grid); cv::Mat bitNot; cv::bitwise_and(src, grid, bitNot); cv::Mat add = cv::Mat::zeros(bitNot.rows, bitNot.cols,bitNot.type()); int iDiffTh = 200; QTime timer; timer.start(); //#pragma omp parallel for num_threads(10) for (int i = 1; i < bitNot.rows - 1; i++) { for (int j = 1; j < bitNot.cols - 1; j++) { int iValueX = (int)bitNot.at(i, j); int iValueXPre = (int)bitNot.at(i-1, j); int iValueXNext = (int)bitNot.at(i+1, j); int iValueY = (int)bitNot.at(i, j); int iValueYPre = (int)bitNot.at(i, j-1); int iValueYNext = (int)bitNot.at(i, j+1); if((iValueX - iValueXPre > iDiffTh && iValueX - iValueXNext > iDiffTh) || (iValueY - iValueYPre > iDiffTh && iValueY - iValueYNext > iDiffTh)) { add.at(i, j) = 255; } } } qDebug()<<"process time: "<> contours; //cv::findContours(matThresh,contours,) std::vector > contoursDefect; std::vector hierarchyDefect; cv::Mat canves; cv::cvtColor(src, canves,cv::COLOR_RGBA2RGB); cv::findContours(matThresh, contoursDefect, hierarchyDefect, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_NONE); for (size_t i = 0; i < contoursDefect.size(); i++) { cv::Mat contour(contoursDefect.at(i));//第i个轮廓 double area = contourArea(contour); if (area >= 50) cv::Moments moment;//矩 moment = moments(contour, false); cv::Point2d pt1; double m00 = moment.m00 + 0.01; pt1.x = moment.m10 / m00;//计算重心横坐标 pt1.y = moment.m01 / m00;//计算重心纵坐标 cv::drawContours(canves, contoursDefect, i, cv::Scalar(255, 255, 0), -1); } cv::imshow("canves", canves); cv::waitKey(0); } void test_lane_detection() int i = 0; while(1) cv::Mat src; QString dir("D:\\QtProject\\Opencv_Example\\gen_grid_region\\scene_"); QString path; if(i>9) path = QString("%1%2%3").arg(dir).arg(i++).arg(".png"); else path = QString("%1%2%3%4").arg(dir).arg("0").arg(i++).arg(".png"); cout<以上就是关于"怎么使用opencv实现车道线检测"这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注行业资讯频道。
内容
车道
检测
文章
知识
篇文章
重心
价值
大部分
就是
形态
形态学
效果
更多
横坐标
步骤
知识点
纵坐标
行业
资讯
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
钢铁行业网络安全工作原理
河北九善互联网科技有限公司
redis如何和数据库同步
南通软件开发管理
电脑服务器禁止登录
服务器关闭ie安全
东城区正规软件开发推广
临沂市甲设网络技术有限公司
sql查询数据库所有记录
贵州ftp服务器云主机
中汇通网络技术
文成新能源刀片服务器质量推荐
红运软件开发
数据库如何储存视频
软件开发人情况说明
朝阳区运营网络技术诚信服务
麒麟软件开发投资部
南山网络安全哪家好
银行数据库设计代码
随着5g网络技术的发展市场
网络安全法出台的定位是
tcl软件开发工程师薪酬
浙江安卓软件开发哪家好
软件开发企业申请专利
数据库dbf文件损坏
在创建数据库表结果时
芯片工业软件开发
金山区音频led大屏服务器
中石油会议服务器地址
服务器管理器查看错误日志