当前位置:   article > 正文

Tusimple 数据集可视化_tusimple 数据可视化

tusimple 数据可视化
  1. import os
  2. import cv2
  3. import numpy as np
  4. import json
  5. from time import sleep
  6. # tusimple 数据集地址
  7. basedir = r'F:\data\tusimple'
  8. def get_laneData(filepath, y_samples, gt_lanes):
  9. img = None
  10. imgLable = None
  11. if os.path.exists(filepath) and gt_lanes:
  12. img = cv2.imread(filepath) # 读取图片
  13. # 获取点
  14. labelPos = [[(x, y) for (x, y) in zip(lane, y_samples) if x >= 0]
  15. for lane in gt_lanes]
  16. labelPos = [lane for lane in labelPos if len(lane) > 0]
  17. # 绘制点
  18. imgLable = img.copy()
  19. for lpos in labelPos:
  20. for point in lpos:
  21. cv2.circle(imgLable, point, 2, (0, 0, 255), 2)
  22. # 对没有车道线的图片仅读取图片
  23. elif os.path.exists(filepath):
  24. img = cv2.imread(filepath)
  25. imgLable = None
  26. else:
  27. print("no image")
  28. return img, imgLable
  29. text_path = r'test_label.json'
  30. for line in open(os.path.join(basedir, text_path)):
  31. # 读取数据
  32. data = json.loads(line)
  33. y_samples = data['h_samples']
  34. gt_lanes = data['lanes']
  35. path = data['raw_file']
  36. # 获取img以及绘制的imglabel
  37. img, imglabel = get_laneData(os.path.join(
  38. basedir, path.strip('\n')), y_samples, gt_lanes)
  39. # 均存在
  40. if img.any() and imglabel is not None:
  41. imglabel = cv2.resize(imglabel, (1024, 512))
  42. cv2.imshow('dsh', imglabel)
  43. sleep(0.1)
  44. # 无线
  45. elif img.any() is not None:
  46. cv2.imshow('dsh', img)
  47. sleep(0.1)
  48. # 退出判断
  49. if cv2.waitKey(1) & 0xFF == ord('q'): # 按q退出
  50. cv2.waitKey(0)
  51. cv2.destroyAllWindows()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/345242
推荐阅读
相关标签
  

闽ICP备14008679号