您的位置 首页 kreess

(十六)實踐出真知——無人駕駛數據集tusimple

每次要一些數據集都是臨時找,感覺有必要慢慢收集這些數據來源,方便用得到的時候。一、tusimple主要是車道線數據,含有以下幾種狀況:- 中等天氣條件- 白天不同的時間-

每次要一些數據集都是臨時找,感覺有必要慢慢收集這些數據來源,方便用得到的時候。

一、tusimple

主要是車道線數據,含有以下幾種狀況:

– 中等天氣條件

– 白天不同的時間

– 2車道/3車道/4車道/或更多

– 不同的交通狀況

數據集大小:

– ==訓練集==:

– 3626個視頻剪輯,每個視頻剪輯為1s拍攝的圖片,共計20張

– 對於每個剪輯:3626個註釋幀

– ==測試集==:

– 2944個視頻剪輯

– ==每張圖片==:1280 x 720

– 總計:3626張訓練圖像和2782張測試圖像;每張圖都提供瞭該圖前19幀圖像(不過這19幀是未標註的)

訓練集如下:

clips是圖片,json是車道線標註

標註json 文件中每一行包括三個字段 :

raw_file : 每一個數據段的第20幀圖像的的 path 路徑

lanes 和 h_samples 是數據具體的標註內容,為瞭壓縮,h_sample 是縱坐標(等分確定),lanes 是每個車道的橫坐標,是個二維數組。-2 表示這個點是無效的點。

標註的過程應該是,將圖片的下半部分如70%*height 等分成N份。然後取車道線(如論虛實)與該標註線交叉的點。

下載數據集:

LaneNet車道線檢測使用的是Tusimple數據集,下載它

https://github.com/TuSimple/tusimple-benchmark/issues/3

數據處理

為瞭獲得我們所需的分割樣式,需要進一步處理生成分割圖片

處理代碼如下,註意修改自己的路徑即可:

import cv2
import json
import numpy as np
import os,time

base_path = r"D:/DeepLearning/Dataset/tusimple_train_set"

file = open(base_path + '/label_data_0313.json', 'r')
image_num = 0

for line in file.readlines():
data = json.loads(line)
# print data['raw_file']
# 如果要單幀看效果,添加以下條件語句
# if image_num == 29:
image = cv2.imread(os.path.join(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 # 255白色,0是黑色
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()
now = time.time()
string1 = base_path + "/lane_seg_annotations" + "\" + str(int(round(now * 1000))) + ".png"
# string2 = base_path + "\" + str(int(round(now * 1000))) + ".png"
string3 = base_path + "/lane_images" + "\" + str(int(round(now * 1000))) + ".png"
cv2.imwrite(string1, binaryimage)
# cv2.imwrite(string2, instanceimage)
cv2.imwrite(string3, image)
# break
image_num = image_num + 1

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

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

返回顶部