首页
前端开发

分类

当前位置: 云海天教程网 > 技术新闻 > 前端开发 >正文

将tusimple转换为lanenet-lane-detection可以训练的方式

更新时间:2020-11-21  作者:佚名   来源:网络转载


	将tusimple转换为lanenet-lane-detection可以训练的方式
[web前端开发]

# -*- coding: utf-8 -*-
import cv2
import json
import numpy as np

base_path = "D:/Personal_Task/A3_ADASProject/Traffic_Line/dataset/train_set/"
targetpath = "D:/Personal_Task/A3_ADASProject/Traffic_Line/dataset/"
traintxt_path = "D:/Personal_Task/A3_ADASProject/Traffic_Line/dataset/train.txt"
file = open(base_path + ‘label_data_0313.json‘, ‘r‘)

# image_name = "gt_image/" + str(name) + ".png"
# binary_name = "gt_binary_image/" + str(name) + ".png"
# instance_name = "gt_instance_image/" + str(name) + ".png"
image_num = 0

for line in file.readlines():
with open("D:/Personal_Task/A1_manka_tusimple_make/new_train.txt", ‘w+‘) as file:
image_name = "gt_image/" + str(image_num).zfill(4) + ".png"
binary_name = "gt_binary_image/" + str(image_num).zfill(4) + ".png"
instance_name = "gt_instance_image/" + str(image_num).zfill(4) + ".png"
train_rows = image_name + " " + binary_name + " " + instance_name + " "
file.write(train_rows)

data = json.loads(line)
# print data[‘raw_file‘]
# 取第 29 帧 看一下处理的效果

image = cv2.imread(base_path + data[‘raw_file‘])
# 二进制图像数组初始化
binaryimage = np.zeros((image.shape[0], image.shape[1], 1), np.uint8)
# 实例图像数组初始化
instanceimage = binaryimage.copy()
arr_width = data[‘lanes‘]
arr_height = data[‘h_samples‘]
width_num = len(arr_width)
height_num = len(arr_height)
# print width_num
# print height_num
# 遍历纵坐标
for i in range(height_num):
lane_hist = 40
# 遍历各个车道的横坐标
for j in range(width_num):
# 端点坐标赋值
if arr_width[j][i - 1] > 0 and arr_width[j][i] > 0:
binaryimage[int(arr_height[i]), int(arr_width[j][i])] = 255
instanceimage[int(arr_height[i]), int(arr_width[j][i])] = lane_hist
if i > 0:
# 画线,线宽10像素
cv2.line(binaryimage, (int(arr_width[j][i - 1]), int(arr_height[i - 1])),
(int(arr_width[j][i]), int(arr_height[i])), 255, 10)
cv2.line(instanceimage, (int(arr_width[j][i - 1]), int(arr_height[i - 1])),
(int(arr_width[j][i]), int(arr_height[i])), lane_hist, 10)
lane_hist += 50
# cv2.imshow(‘image.jpg‘, image)
# cv2.waitKey()
# cv2.imshow(‘binaryimage.jpg‘, binaryimage)
# cv2.waitKey()
# cv2.imshow(‘instanceimage.jpg‘, instanceimage)
# cv2.waitKey()
cv2.imwrite(targetpath + "/" + image_name, image)
cv2.imwrite(targetpath + "/" + binary_name, binaryimage)
cv2.imwrite(targetpath + "/" + instance_name, instanceimage)
# break
# string1=base_path+"gt_image_binary/"+str(image_num)+".png"
# string2=base_path+"gt_image_instance/"+str(image_num)+".png"
# string3=base_path+"raw_image/"+str(image_num)+".png"
# cv2.imwrite(string1,binaryimage)
# cv2.imwrite(string2,instanceimage)
# cv2.imwrite(string3,image)
print(str(image_num) + " over")
image_num = image_num + 1

file.close()
print("total image_num:" + str(image_num))

将tusimple转换为lanenet-lane-detection可以训练的方式

原文地址:https://www.cnblogs.com/ymec/p/13985599.html

上一篇: Effective C++的50条建议 [编程语言教程] 下一篇: mysql性能问题 [数据库教程]
小编推荐
快速导航更多>>
JavaScript 教程 HTML5 教程 CSS3 教程 jQuery 教程 Vue.js 教程 Node.js 教程 SQL 教程 C 教程 PHP 教程 Linux 教程 Docker 教程 Nginx 教程 Python 教程 Java 教程

云海天教程网 版权所有

陕ICP备14013131号-3