Skip to content

Commit bcb13a7

Browse files
ui diff replay: remove unused frame_data list for individual frame display (#37117)
Remove unused base64 encoding and simplify frame data handling in diff video report
1 parent 0ce2880 commit bcb13a7

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

selfdrive/ui/tests/diff/diff.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import sys
44
import subprocess
55
import tempfile
6-
import base64
76
import webbrowser
87
import argparse
98
from pathlib import Path
@@ -25,12 +24,6 @@ def compare_frames(frame1_path, frame2_path):
2524
return result.returncode == 0
2625

2726

28-
def frame_to_data_url(frame_path):
29-
with open(frame_path, 'rb') as f:
30-
data = f.read()
31-
return f"data:image/png;base64,{base64.b64encode(data).decode()}"
32-
33-
3427
def create_diff_video(video1, video2, output_path):
3528
"""Create a diff video using ffmpeg blend filter with difference mode."""
3629
print("Creating diff video...")
@@ -60,20 +53,16 @@ def find_differences(video1, video2):
6053

6154
print(f"Comparing {len(frames1)} frames...")
6255
different_frames = []
63-
frame_data = []
6456

6557
for i, (f1, f2) in enumerate(zip(frames1, frames2, strict=False)):
6658
is_different = not compare_frames(f1, f2)
6759
if is_different:
6860
different_frames.append(i)
6961

70-
if i < 10 or i >= len(frames1) - 10 or is_different:
71-
frame_data.append({'index': i, 'different': is_different, 'frame1_url': frame_to_data_url(f1), 'frame2_url': frame_to_data_url(f2)})
72-
73-
return different_frames, frame_data, len(frames1)
62+
return different_frames, len(frames1)
7463

7564

76-
def generate_html_report(video1, video2, basedir, different_frames, frame_data, total_frames):
65+
def generate_html_report(video1, video2, basedir, different_frames, total_frames):
7766
chunks = []
7867
if different_frames:
7968
current_chunk = [different_frames[0]]
@@ -177,14 +166,14 @@ def main():
177166
diff_video_path = os.path.join(os.path.dirname(args.output), DIFF_OUT_DIR / "diff.mp4")
178167
create_diff_video(args.video1, args.video2, diff_video_path)
179168

180-
different_frames, frame_data, total_frames = find_differences(args.video1, args.video2)
169+
different_frames, total_frames = find_differences(args.video1, args.video2)
181170

182171
if different_frames is None:
183172
sys.exit(1)
184173

185174
print()
186175
print("Generating HTML report...")
187-
html = generate_html_report(args.video1, args.video2, args.basedir, different_frames, frame_data, total_frames)
176+
html = generate_html_report(args.video1, args.video2, args.basedir, different_frames, total_frames)
188177

189178
with open(DIFF_OUT_DIR / args.output, 'w') as f:
190179
f.write(html)

0 commit comments

Comments
 (0)