in scripts/render/resize.py [0:0]
def main(argv):
"""Validates flags and resizes the frame pointed at by them if determined to be valid.
Args:
argv (list[str]): List of arguments (used interally by abseil).
"""
with open(FLAGS.rig, "r") as f:
rig = json.load(f)
cameras_rig = sorted([camera["id"] for camera in rig["cameras"]])
cameras_dir = sorted(
os.path.basename(d)
for d in glob.iglob(os.path.join(FLAGS.src_dir, "*"))
if os.path.isdir(d)
)
if len(cameras_dir) == 0:
print(f"No cameras found in {FLAGS.src_dir}")
sys.exit()
if cameras_rig != cameras_dir:
print(
f"Cameras from rig differ from cameras in source directory: {cameras_rig} vs {cameras_dir}"
)
sys.exit()
# Get list of frames from the first camera
frames = []
dirCamRef = os.path.join(FLAGS.src_dir, cameras_dir[0])
img_ext = ""
for f in glob.iglob(os.path.join(dirCamRef, "*")):
if os.path.isfile(f):
frame, img_ext = os.path.splitext(os.path.basename(f))
frames.append(frame)
frames.sort()
if len(frames) == 0:
print(f"No frames found in {dirCamRef}")
sys.exit()
if img_ext == "":
print(f"Could not find image extension from frames in {dirCamRef}")
sys.exit()
if not FLAGS.first:
FLAGS.first = frames[0]
if not FLAGS.last:
FLAGS.last = frames[-1]
if FLAGS.first not in frames:
print(f"Could not find frame {FLAGS.first} in {dirCamRef}")
sys.exit()
if FLAGS.last not in frames:
print(f"Could not find frame {FLAGS.last} in {dirCamRef}")
sys.exit()
resize_frames(
FLAGS.src_dir,
FLAGS.dst_dir,
rig,
frames.index(FLAGS.first),
frames.index(FLAGS.last),
)