Created
February 24, 2023 23:11
-
-
Save PeterJCLaw/69b81b16efb0f5d6a7d2b79a9a7972e6 to your computer and use it in GitHub Desktop.
Generate white-balanced & cropped final images from SR2023 Virtual Competition recordings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -euo pipefail | |
# Requirements: | |
# - ImageMagick and FFMPEG (cli tools on PATH) | |
# - The script from http://www.fmwconcepts.com/imagemagick/whitebalance/index.php, +x and on PATH | |
# | |
# Usage: | |
# - cd into the directory containing the recordings | |
# - run this script | |
# We only have 20 matches | |
for matchno in $(seq 0 19) | |
do | |
# Extract the last frame from the video | |
ffmpeg -sseof -3 -i match-${matchno}.mp4 -update 1 -q:v 1 -y last-${matchno}.raw.jpg | |
# Balance the image using a pixel known to be in the background | |
whitebalance 1,1 last-${matchno}.raw.jpg last-${matchno}.balanced.jpg | |
# Crop to the arena; size and offset manually determined by experimentation | |
convert last-${matchno}.balanced.jpg -crop 1152x882+380+95 last-${matchno}.cropped.jpg | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment