Code for the PyCon US 2020 presentation Decoding bias and narrative in competitive video games broadcasts with video analysis
.
✨ Slides: https://aka.ms/pycon2020-overwatch
🗓 PyCon US schedule description: https://us.pycon.org/2020/schedule/presentation/107/
What you will need:
- VS Code + Python extension
- Python 3.X
- An Azure subcription with a Computer Vision resource (documentation)
> git clone [email protected]:kimadeline/overwatch-ocr.git
> cd overwatch-ocr
> python -m venv .venv
> source .venv/bin/activate
> python -m pip install -r requirements.txt
-
A list of video files for the games you want to parse, preferably without the breaks between maps. It's easier now that the OWL is on YT Gaming, otherwise here's the full USA vs China OWWC match, now go have fun trimming it;
-
A JSON reference file mapping player names, team names and shorthand names, look at
static/owwc_teams.json
for an example. -
Create the following folders at the workspace root (siblings of
src
):input
: Where you'll put your video filesoutput
: Where the algorithm will split the frames and crop themdata
: Where we will store JSON files containing player names extracted from each frame, and also the reference teams file
To visualize graphs for the OWL matches I used to compute the stats in my PyCon talk:
- Pull the
owl_2020
branch of this repo - Copy the
owl_results/*_pov.json
files to thedata
folder - Update the arguments of the
display_dashboard
function inmain.py
- ✨
python main.py
✨
- Copy your video files to the
input
folder - Update the
GAMES_LIST
variable insrc/__init__.py
to be the list of the videos you want to parse (don't include the extension, but if it's not an mp4 file update L.12 offilename.py
) - Save your Azure subscription key and endpoint somewhere:
- Option 1: Add your subscription key and your endpoint to a
.env
file at the root of the repo - Option 1: Write them directly in
ocr.py
- Option 1: Add your subscription key and your endpoint to a
- Run everything (this might take a while because I make unoptimized, throttled Azure OCR calls)
- If you followed option 1 from above, launch the
Python: Main script
configuration (you can't use the run button because of this issue) - Otherwise, use the run button in the top-right corner, or call
python main.py
directly
- If you followed option 1 from above, launch the
⚠️ Make sure your computer doesn't go to sleep- Profit 🥳
You should end up with something like this: