Compare commits
No commits in common. "5290f605005bf8be12e2c7092125b4aa157f11e2" and "eaf7294d06f9b3dd48619a25b3f1e243953b64e7" have entirely different histories.
5290f60500
...
eaf7294d06
12
decode.py
12
decode.py
|
@ -6,7 +6,9 @@ from tqdm import tqdm
|
|||
import pandas as pd
|
||||
import pcapng
|
||||
from struct import unpack
|
||||
import matplotlib.pyplot as plt
|
||||
from PIL import Image
|
||||
from PIL import Image, ImageDraw
|
||||
import cv2
|
||||
|
||||
|
||||
|
@ -38,7 +40,6 @@ def parse(data):
|
|||
ret['data'] = data[hdr:]
|
||||
return ret
|
||||
|
||||
|
||||
df = pd.DataFrame([parse(d) for d in raw])
|
||||
df2 = df[[c for c in df.columns if c != 'data']]
|
||||
|
||||
|
@ -59,10 +60,7 @@ def getframes(df):
|
|||
|
||||
|
||||
def image16(frame, width, height, pixelformat='>H'):
|
||||
return [
|
||||
Image.fromarray(np.frombuffer(frame, dtype=pixelformat).reshape(width, height)) for frame in frames
|
||||
if len(frame) == 2 * width * height
|
||||
]
|
||||
return [Image.fromarray(np.frombuffer(frame, dtype=pixelformat).reshape(width, height)) for frame in frames if len(frame) == 2 * width * height]
|
||||
|
||||
|
||||
def showvideo(images):
|
||||
|
@ -89,8 +87,8 @@ for i, img in enumerate(tqdm(images)):
|
|||
#frame = b''.join(df.iloc[:32]['data'])
|
||||
#Image.frombytes('RGB', (288, 256), frame).show()
|
||||
start_len = len(b'T=(-1.665884e-08)*X^4+(1.347094e-05)*X^3+(-4.396264e-03)*X^2+(9.506939e-01)*X+(-6.353247e+01)\r\n ')
|
||||
|
||||
# 250 bytes at start of frame
|
||||
|
||||
equations = {x[:250].decode().strip() for x in df[df.part == 0]['data']}
|
||||
# seen only a single equation on all packets
|
||||
assert len(equations) == 1
|
||||
|
@ -101,5 +99,5 @@ assert list(equations)[0] == 'T=(-1.665884e-08)*X^4+(1.347094e-05)*X^3+(-4.39626
|
|||
assert df.shape[0] == 6372
|
||||
|
||||
# produce a video
|
||||
system('ffmpeg -f image2 -framerate 25 -i %04d.png -vf "transpose=1" -s 384x288 -vcodec libx264 -pix_fmt yuv420p thermal.mp4')
|
||||
system('ffmpeg -f image2 -framerate 25 -i %04d.png -s 288x384 thermal.mp4')
|
||||
print('to play: ffplay thermal.mp4')
|
||||
|
|
BIN
thermal.avi
Normal file
BIN
thermal.avi
Normal file
Binary file not shown.
BIN
thermal.mp4
BIN
thermal.mp4
Binary file not shown.
Loading…
Reference in New Issue
Block a user