I'll record my first python3 visualization script here.
This script is able to visualize the formatted datas in txt file dynamically and record the process by generating a mp4 file for recalling. It may not adaptable for your own data format while only for reference. Or you can modify the code construction to adapt your data format.
If there is any problem please message me.
我将在这里录制我的第一个python3可视化脚本。
该脚本能够动态地可视化txt文件中的格式化数据,并通过生成用于调用的mp4文件来记录过程。它可能不适合您自己的数据格式,而仅用于参考。也可以修改代码结构以适应数据格式。
如果有任何问题,请给我留言。
注:如果有兴趣可以在这里下载测试用的txt数据:下载地址
(该脚本提供三个对外参数:
必要参数:<测试数据>.txt
非必要参数:<预测数据>.txt
<对应帧图片folder>
由于一些项目内数据不便展示,因此这里只给出测试数据的txt,敬请谅解!
在终端下运行测试:
$ python3 visualization.py -l test1.txt
visualization.py
# _*_ coding: utf-8 _*_
# @Author : Mingquan
# @File: line_visualization.py
# @Information: *Using this file to visualize the lanes line fitting
# *INPUT: <lane_data.txt>/<pred_data.txt>/<image_source/>
# *OUTPUT: <lane_fitting.mp4>
from os import write
import sys
import importlib
importlib.reload(sys)
# import time
import math
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import json
import argparse
import matplotlib.image as mpimg
from matplotlib.animation import FFMpegWriter
matplotlib.use('TkAgg')
class VisualizationTool:
lane_data = None
pred_data = None
img_folder = None
lane_type = None
pred_type = None
data_l