Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date. Images, audio, models and binaries go through Git LFS (.gitattributes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
Tools/Trailer/grid.py
Normal file
44
Tools/Trailer/grid.py
Normal file
@ -0,0 +1,44 @@
|
||||
"""Contact sheets of a rendered cut. py -I grid.py in.mp4 outdir step [from to]"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
src, out, step = sys.argv[1], sys.argv[2], float(sys.argv[3])
|
||||
start = float(sys.argv[4]) if len(sys.argv) > 4 else 0.0
|
||||
cap = cv2.VideoCapture(src)
|
||||
fps = cap.get(cv2.CAP_PROP_FPS)
|
||||
end = float(sys.argv[5]) if len(sys.argv) > 5 else cap.get(cv2.CAP_PROP_FRAME_COUNT) / fps
|
||||
os.makedirs(out, exist_ok=True)
|
||||
upright = cap.get(cv2.CAP_PROP_FRAME_HEIGHT) > cap.get(cv2.CAP_PROP_FRAME_WIDTH)
|
||||
cols, rows, w, h = (8, 3, 240, 427) if upright else (5, 6, 400, 225)
|
||||
cells, page, t = [], 0, start
|
||||
|
||||
|
||||
def flush():
|
||||
global cells, page
|
||||
if not cells:
|
||||
return
|
||||
while len(cells) % cols:
|
||||
cells.append(np.zeros((h, w, 3), np.uint8))
|
||||
sheet = np.vstack([np.hstack(cells[i:i + cols]) for i in range(0, len(cells), cols)])
|
||||
page += 1
|
||||
cv2.imwrite(os.path.join(out, f"page{page:02d}.jpg"), sheet, [cv2.IMWRITE_JPEG_QUALITY, 85])
|
||||
cells = []
|
||||
|
||||
|
||||
while t < end:
|
||||
cap.set(cv2.CAP_PROP_POS_MSEC, t * 1000)
|
||||
ok, f = cap.read()
|
||||
if not ok:
|
||||
break
|
||||
f = cv2.resize(f, (w, h), interpolation=cv2.INTER_AREA)
|
||||
cv2.putText(f, f"{t:.1f}", (6, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.55, (0, 0, 0), 3, cv2.LINE_AA)
|
||||
cv2.putText(f, f"{t:.1f}", (6, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.55, (255, 255, 255), 1, cv2.LINE_AA)
|
||||
cells.append(f)
|
||||
if len(cells) == cols * rows:
|
||||
flush()
|
||||
t += step
|
||||
flush()
|
||||
print(page)
|
||||
Reference in New Issue
Block a user