Lanenet车道线检测 --运行别人代码(1)

本文介绍了作者在运行Lanenet车道线检测模型时的步骤和遇到的问题,包括处理程序路径、添加__init__.py文件以及解决依赖库如cv2的安装。在Python3.5环境下,模型成功复现并展示了在GPU上的运行效果,测试了单张及多张图像的预测速度。
摘要由CSDN通过智能技术生成

2018.2发表出来的,文章下载地址https://arxiv.org/abs/1802.05591

github上代码https://github.com/MaybeShewill-CV/lanenet-lane-detection

【本文用的还是18年的,没有用最新的】


运行代码时可能出错:

处理:

程序里添加路径

import sys 
sys.path.append('/home/zengjun/下载/lanenet-lane-detection-master')
sys.path.append('/home/zengjun/下载/lanenet-lane-detection-master/config')
sys.path.append('/home/zengjun/下载/lanenet-lane-detection-masterdata_provider')
sys.path.append('/home/zengjun/下载/lanenet-lane-detection-master/lanenet_model')
sys.path.append('/home/zengjun/下载/lanenet-lane-detection-master/encoder_decoder_model')
sys.path.append('/home/zengjun/下载/lanenet-lane-detection-master/tools')

对应文件夹里加入一个空的 __init__.py文件

遇到库文件比如cv2等问题,在pycharm里使用更为方便。本文用的python3.5

测试结果:

2019-05-30 20:47:00.556062: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4861 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
INFO:tensorflow:Restoring parameters from model/tusimple_lanenet/tusimple_lanenet_vgg_2018-10-19-13-33-56.ckpt-200000
I0530 20:47:00.557337 7261 tf_logging.py:115] Restoring parameters from model/tusimple_lanenet/tusimple_lanenet_vgg_2018-10-19-13-33-56.ckpt-200000
I0530 20:47:01.835264 7261 test_lanenet.py:127] 单张图像车道线预测耗时: 1.20088s

预测多张,FPS应该会提高,因为预处理时间。

python tools/test_lanenet.py --is_batch True --batch_size 2 --save_dir data/tusimple_test_image/ret  --weights_path model/tusimple_lanenet/tusimple_lanenet_vgg_2018-10-19-13-33-56.ckpt-200000  --image_path data/tusimple_test_image/

I0530 21:02:25.781537 9119 test_lanenet.py:208] [Epoch:2] 预处理2张图像, 共耗时: 0.01650s, 平均每张耗时: 0.00825
I0530 21:02:25.835193 9119 test_lanenet.py:215] [Epoch:2] 预测2张图像车道线, 共耗时: 0.05352s, 平均每张耗时: 0.02676s
I0530 21:02:25.957873 9119 test_lanenet.py:245] [Epoch:2] 进行2张图像车道线聚类, 共耗时: 0.10769s, 平均每张耗时: 0.05384
I0530 21:02:25.957981 9119 test_lanenet.py:198] [Epoch:3] 开始图像读取和预处理...
I0530 21:02:25.975388 9119 test_lanenet.py:208] [Epoch:3] 预处理2张图像, 共耗时: 0.01733s, 平均每张耗时: 0.00866
I0530 21:02:26.029834 9119 test_lanenet.py:215] [Epoch:3] 预测2张图像车道线, 共耗时: 0.05430s, 平均每张耗时: 0.02715s
I0530 21:02:26.092286 9119 test_lanenet.py:245] [Epoch:3] 进行2张图像车道线聚类, 共耗时: 0.04747s, 平均每张耗时: 0.02374
I0530 21:02:26.092393 9119 test_lanenet.py:198] [Epoch:4] 开始图像读取和预处理...
I0530 21:02:26.105244 9119 test_lanenet.py:208] [Epoch:4] 预处理2张图像, 共耗时: 0.01278s, 平均每张耗时: 0.00639
I0530 21:02:26.158836 9119 test_lanenet.py:215] [Epoch:4] 预测2张图像车道线, 共耗时: 0.05346s, 平均每张耗时: 0.02673s
I0530 21:02:26.210763 9119 test_lanenet.py:245] [Epoch:4] 进行2张图像车道线聚类, 共耗时: 0.04204s, 平均每张耗时: 0.02102
I0530 21:02:26.210871 9119 test_lanenet.py:198] [Epoch:5] 开始图像读取和预处理...
I0530 21:02:26.227664 9119 test_lanenet.py:208] [Epoch:5] 预处理2张图像, 共耗时: 0.01670s, 平均每张耗时: 0.00835
I0530 21:02:26.280578 9119 test_lanenet.py:215] [Epoch:5] 预测2张图像车道线, 共耗时: 0.05277s, 平均每张耗时: 0.02638s
I0530 21:02:26.344519 9119 test_lanenet.py:245] [Epoch:5] 进行2张图像车道线聚类, 共耗时: 0.04929s, 平均每张耗时: 0.02465


这下面部分运行除了问题,不要看:

自己加了个视频处理显示的py

#video_test.py   可以读取视频与处理后显示
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 18-5-23 上午11:33
# @Author  : Luo Yao
# @Site    : https://github.com/MaybeShewill-CV/lane
  • 9
    点赞
  • 71
    收藏
    觉得还不错? 一键收藏
  • 18
    评论
以下是基于OpenCV传统数字图像处理实现车道线检测的Python代码示例: ```python import cv2 import numpy as np def lane_detection(image): # 将图像转换为灰度图 gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 对图像进行高斯平滑去噪 blurred = cv2.GaussianBlur(gray, (5, 5), 0) # 使用Canny算法进行边缘提取 edges = cv2.Canny(blurred, 50, 150) # 定义ROI(感兴趣区域)的顶点坐标 height, width = edges.shape roi_vertices = [(0, height), (width/2, height/2), (width, height)] # 创建一个掩膜,将ROI以外的区域屏蔽掉 mask = np.zeros_like(edges) cv2.fillPoly(mask, np.array([roi_vertices], np.int32), 255) masked_edges = cv2.bitwise_and(edges, mask) # 使用霍夫变换检测直线 lines = cv2.HoughLinesP(masked_edges, 1, np.pi/180, threshold=50, minLineLength=100, maxLineGap=50) # 在原始图像上绘制检测到的车道线 line_image = np.zeros_like(image) if lines is not None: for line in lines: x1, y1, x2, y2 = line[0] cv2.line(line_image, (x1, y1), (x2, y2), (0, 0, 255), 3) # 将车道线图像与原始图像进行叠加 result = cv2.addWeighted(image, 0.8, line_image, 1, 0) return result # 读取图像 image = cv2.imread('road.jpg') # 进行车道线检测 result = lane_detection(image) # 显示结果图像 cv2.imshow('Lane Detection', result) cv2.waitKey(0) cv2.destroyAllWindows() ``` 这段代码实现了基于OpenCV的传统数字图像处理方法进行车道线检测。首先,将图像转换为灰度图,然后使用高斯平滑对图像进行去噪,接着使用Canny算法进行边缘提取。然后,定义感兴趣区域(ROI)并创建一个掩膜,将ROI以外的区域屏蔽掉。最后,使用霍夫变换检测直线,并在原始图像上绘制检测到的车道线。
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值