📚 Course contents
AI & Computer Vision, lesson 46 of 52
Formation & Tactical Analysis
Introduction
A team is like a flock of birds: nobody draws its shape, yet you can see it stretch when it attacks and squeeze when it defends. Today you'll measure that shape from your tracked positions: the lines (defence, midfield, attack), how wide and deep the team is, how compact, and how it changes with the ball.
By the end of this lesson you'll be able to:
- Convert positions into depth for a team that attacks left or right
- Find the lines of a formation by cutting at the biggest gaps
- Measure width, depth and convex hull area
- Estimate possession from the ball and the nearest player
- Compare team shape with and without the ball
- Make measured claims without telling the coach what to do
Working principle
Team shape is a statement about positions
A formation such as 4-4-2 means: four defenders, four midfielders, two forwards, plus the keeper. It is a label for a shape. From positions in metres (lesson 33) we can look at the shape directly instead of trusting a label.
Average position
Players move around. Their average position over a period is a good first summary: where they spend their time. It is the centre of the heatmap (lesson 41). Use the average over a minute or a phase of play, not the whole match, or you blur everything.
Finding the lines
To find "four, three, three":
- Take the outfield players (leave out the keeper).
- Measure how far up the pitch each one is. This depends on which way the team attacks, so we convert x into depth: distance from their own goal line.
- Sort by depth. Cut the sorted list at the biggest gaps. Two cuts make three lines.
- Count the players in each line, from back to front.
It is simple, and it works when lines are clear. It forces the number of lines you ask for, so it can't discover that a team has changed shape; and it cannot tell a flat midfield from a midfield with a "number 10".
Width, depth and compactness
| Measure | Meaning | How we compute |
|---|---|---|
| Width | How wide the team spreads | Largest minus smallest y of outfield players |
| Depth | How stretched from back to front | Largest minus smallest depth |
| Area | How much ground is covered | Area of the convex hull |
Small area = compact: hard to play through, but leaves space behind. Large area = stretched: more room for passes, more room for the opponent too. Neither is "right".
Who has the ball?
Tactics depend on the phase: with the ball, without it, or loose. Our proxy: the team of the nearest player, if within 6 metres. In our pretend match it matched the truth in 100% of frames; in a real match it will make mistakes (players close together, the ball in the air, a ball tracker that loses the ball). Treat the phases as estimates (lesson 36, lesson 40).
Directions and halves
Teams swap ends at half time, and our depth calculation needs the direction. Give each half its own direction, or the numbers will be mirrored. This is the kind of bug that makes a formation look "reversed" and a coach distrust the whole system.
Describe, don't prescribe
Computers can say: "this team had a width of 49 m with the ball and 35 m without". They cannot say "that was the right way to play". Tactics depend on the opponent, the score, the weather, the players' ages and the coach's plan. When you present results, say what you measured, how sure you are, and leave the judging to the people.
Be careful with claims about children's teams
Young players change position often and learn the game in different roles. Fixed labels ("a defender") can limit them. Use the data for the coach to discuss with the players, never to fix roles, rank players or select teams without human judgement (lesson 43).
What a camera can't see
A formation analysis needs all the players in view and a good calibration (lesson 33). A camera that sees only half the pitch cannot analyse a team's depth. If players are missing from the tracks, the shape is wrong. Report how many players you could see in each frame.

