-
Notifications
You must be signed in to change notification settings - Fork 2
/
fplot.py
21 lines (19 loc) · 915 Bytes
/
fplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PIL import Image
import numpy as np
import os
path = os.getcwd()
res = 8192
for f in os.listdir(path):
if f.endswith(".txt"):
map = np.zeros((res, res))
posX = 0
posY = 0
with open(os.path.join(path, f)) as data:
for line in data.readlines():
if "Yaw(Float):" in line and -res/2 < posX < res/2 and -res/2 < posY < res/2:
map[round(posX + res/2), round(posY + res/2)] = 1
if "PositionX(Float):" in line:
posX = float(line.replace("PositionX(Float):","").replace("\n","").replace(" ","").replace(",","."))
if "PositionY(Float):" in line:
posY = float(line.replace("PositionY(Float):","").replace("\n","").replace(" ","").replace(",","."))
Image.fromarray(np.rot90(map).astype(bool)).save(os.path.join(path, f[:-4] + ".png"))