Sports Field Localization - Department of Computer Science ... · Motivation Sports Field...

61
Sports Field Localization Namdar Homayounfar February 5, 2017 1/1

Transcript of Sports Field Localization - Department of Computer Science ... · Motivation Sports Field...

Page 1: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Sports Field Localization

Namdar Homayounfar

February 5, 2017

1 / 1

Page 2: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

MotivationSports Field Localization: Have to figure out where the field andplayers are in 3d space in order to make measurements andgenerate statistics.

http://stats.nba.com/

2 / 1

Page 3: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Motivation

a.espncdn.com3 / 1

Page 4: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How is this done in practice?• There are various tracking and analytics companies• Their solutions for field localization is based mostly on

hardware

http://www.stats.com/sportvu/sportvu-basketball-media/

4 / 1

Page 5: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How is this done in practice?

http://www.google.com/patents/US20080192116

5 / 1

Page 6: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How is this done in practice?

http://www.google.com/patents/US20080192116

6 / 1

Page 7: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How is this done in practice?

http://www.google.com/patents/US20080192116

7 / 1

Page 8: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How is this done in practice?

• There are various tracking and analytics companies

• Their solutions for field localization is based mostly onhardware

http://pixellot.tv/

8 / 1

Page 9: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How is this done in practice?

• There are various tracking and analytics companies

• Their solutions for field localization is based mostly onhardware

http://www.catapultsports.com/

9 / 1

Page 10: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Drawbacks

• Very expensive: e.g. Sportvue costs > $100000 per season fora team

• Only rich teams can afford them

• Have to maintain all the hardware

• Still not bulletproof. Require workers to fix mistakes

10 / 1

Page 11: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Simpler Solution?

Can we get rid of all these cameras/gps systems and just figure outwhere the players are by looking at a broadcast image of the field?

11 / 1

Page 12: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Simpler Solution? YES!

Goal: Given a single broadcast image of a sport game, such assoccer, can we localize it?

• H is a 3× 3 invertible matrix with 8 d.f. Called a projectivetransformation/homography

12 / 1

Page 13: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Homography MatrixThe matrix H captures all the following transformations:

Multiple View Geometry by Hartley and Zisserman

13 / 1

Page 14: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

How to find H?

• Require 4 point correspondences

• Difficulty arises in finding the 4 corresponding points

14 / 1

Page 15: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Related Work: Academia

• Hess et al., Improved Video Registration using Non-DistinctiveLocal Image Features, 2007

• Gupta et al. Using Line and Ellipse Features for Rectificationof Broadcast Hockey Video, 2011

Gupta et al. 2011

15 / 1

Page 16: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Related Work: Academia

• Based on Keyframes and old school computer visiontransforms (eg. SIFT)

Gupta et al. 2011

• Limitation: Depends on fixed features and also requiresmanual annotation of keyframes for each game and

16 / 1

Page 17: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Can we do better?

• Can we automatically localize the field from a broadcastimage?

• Lets come up with a learning approach

• Based on joint work with Sanja Fidler and Raquel Urtasunsubmitted to CVPR

17 / 1

Page 18: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

In case of Soccer

• Large dimensions and exposed to the elements

• Different grass textures and patterns

18 / 1

Page 19: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

This Work

• Introduce a parametrization of the field

• Incorporate prior knowledge about the soccer field aspotentials in an CRF

• Find the mapping H implicitly by doing inference in the CRF

• Single Camera, No key-frame, Fast Inference

19 / 1

Page 20: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology

• Let x ∈ X be random variable corresponding to a broadcastimage of a soccer field.

• A soccer field is restricted by two long sides referred to astouchlines and two shorter sides referred to as goallines

• We aim to infer the position of the touchlines and thegoallines in the image x . (Not all visible at the same time)

20 / 1

Page 21: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology

21 / 1

Page 22: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization

• It’s very important how we parametrize this problem

• What are we trying to find?

• Vanishing Points: Where parallel lines meet in the image

• Manhattan World Assumption: Existence of threedominant orthogonal vanishing points in human-made scenes.

• In a soccer field we usually have clues for the two orthogonalvanishing point

22 / 1

Page 23: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization

23 / 1

Page 24: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization

• Create a grid by emanating rays from the vanishing points

24 / 1

Page 25: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization

25 / 1

Page 26: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization

26 / 1

Page 27: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization• We parametrize the soccer field by four raysy = (y1, y2, y3, y4) on the grid

• State space: Y =∏4

i=1

{[y initi ,min, y

initi ,max ]

}⊂ N4

27 / 1

Page 28: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Methodology: Parametrization

28 / 1

Page 29: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Inference Task

Given an image x of the field, obtain the best prediction of thetouchlines and the goallines by solving the following inference task:

y = arg maxy∈Y

wTφ(x , y)

• φ(x , y): feature vector

• w : weights to be learned from training data

• Note: |Y| ∝ (#rays from vpH)2(#rays from vpV )2

We find an exact solution by using branch and bound for inference.More on that later

29 / 1

Page 30: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features

A soccer field is made up of grass and there are white markingcorresponding to lines and circles with fixed dimensions

We incorporate these as features.

30 / 1

Page 31: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features

• We need good features in the presence of noise

• Different weather and lighting conditions and shadows

• Methods based on heuristics are very fragile

31 / 1

Page 32: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features - Semantic Segmentaition

Train a semantic segmentation network to classify image pixels toeither belonging to:

1. Vertical Lines

2. Horizontal Lines

3. Middle Circle

4. Side Circles

5. Grass

6. Outside

32 / 1

Page 33: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features - Some Examples

33 / 1

Page 34: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features - Some Examples

34 / 1

Page 35: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features - Some Examples

35 / 1

Page 36: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Grass

36 / 1

Page 37: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Lines

7 vertical line segments corresponding to vpV and 10 horizontalline segments corresponding to vpH

37 / 1

Page 38: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Lines

• Given y , need to construct a potential function that is largewhen the projection of each line segment in the image x isclose to its ground truth.

• But given y , where does each line segment fall in the image x?

• Use Cross Ratios: Given 4 points A,B,C ,D on a line, theircross ratio is given by:

CR(A,B,C ,D) =|A− C | · |B − D||B − C | · |A− D|

• Cross ratios invariant under any projective transformation.

38 / 1

Page 39: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Lines

• Use cross ratios to find the position of each line on the grid

39 / 1

Page 40: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Lines

• For example for line `3:

40 / 1

Page 41: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Circles

A cemicircle on each side of the field C2,C3 and a circle in themiddle:

41 / 1

Page 42: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Circles

Transformed to ellipses C ′k in x

42 / 1

Page 43: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Circles

• Similar to line potentials, want potential functions that countthe fraction of supporting pixels in the image x for eachcircular shape Ci given a hypothesis field y

• Unlike lines, the ellipses don’t fall on the grid.

• Ellipse detection: slow and unreliable

43 / 1

Page 44: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Circles

• For each circle there are unique inscribing andcircumscribing rectangles aligned with the vanishing points.

• Similar to lines, we can find the quadrilaterals associated withthese rectangles on the grid Y.

44 / 1

Page 45: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Model: Features — Efficient Computation

• We have positive features.

• Can use 3d accumulators to compute the potentials efficiently.

Schwing et al. 2012

45 / 1

Page 46: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference

• Inference task

y = arg maxy∈Y

wTφ(x , y)

• Aim to do it efficiently and exactly

• Exactness comes from using branch and bound

• Efficiency comes from using integral images and tight upperbounds in branch and bound

46 / 1

Page 47: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — 3 Ingredients

Suppose Y ⊂ Y =∏4

i=1

{[y initi ,min, y

initi ,max ]

}is a subset of

parametrized fields. Branch and bound needs

• A branching mechanism that divides the set Y into twodisjoint subsets Y1 and Y2 of parametrized fields.

• A set function f such that f (Y ) ≥ maxy∈Y w tφ(x , y).

• A priority queue PQ which orders sets of parametrized fieldsY according to f .

47 / 1

Page 48: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — OptimalityIn order to guarantee the optimality of the converged solution:

1. f (Y ) ≥ maxy∈Y w tφ(x , y) for any arbitrary Y ∈ Y

2. f (Y ) = w tφ(x , y) when Y = {y}

Schwing et al. 201248 / 1

Page 49: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Branching• How to branch a set Y =

∏4i=1 {[yi ,min, yi ,max ]} ⊂ Y into two

disjoint sets Y1 and Y2

49 / 1

Page 50: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Branching

50 / 1

Page 51: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Branching

51 / 1

Page 52: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding

• Decompose φ(x , y) into potential with strictly positive weightsand those with weights that are either zero or negative:

wTφ(x , y) = wTnegφneg (x , y) + wT

posφpos(x , y)

• Construct a lower bound set function φi ,neg and an upperbound set function φj ,pos such that

φi ,neg (x ,Y ) ≤ φi ,neg (x , y) ∀y ∈ Y

φj ,pos(x ,Y ) ≥ φj ,pos(x , y) ∀y ∈ Y

52 / 1

Page 53: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding — Grass

Grass Potential:

φG (x , y) =(# of grass pixels in Fy

total # of grass pixels,

# of non-grass pixels in F cy

total # of non-grass pixels

)

53 / 1

Page 54: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding — Grass

54 / 1

Page 55: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding — Grass

Note that for any field y ∈ Y, we have

Fy∩ ⊂ Fy ⊂ Fy∪

The above relation implies that

# of grass pixels inside Fy∩ ≤ # of grass pixels inside Fy

≤ # of grass pixels inside Fy∪

55 / 1

Page 56: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding — Grass

Hence, we can define the upper bound for the grass potential as:

φG ,pos(x ,Y ) = φG (x , y∪)

Similarly, a lower bound can be defined as:

φG ,neg (x ,Y ) = φG (x , y∩)

56 / 1

Page 57: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding — Lines

57 / 1

Page 58: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Branch and Bound Inference — Bounding — Ellipses

58 / 1

Page 59: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Learning — Structural SVM

• The outputs y = (y1, . . . , y4) of equation (1) are discreterandom variable with complex dependencies,

• Use SSVM

• Given a dataset of ground truth training pairs{x (i), y (i)

}Ni=1

we learn the parameters w by solving the followingoptimization problem

minw

1

2‖w‖2 +

C

N

N∑n=1

maxy∈Y

(∆(y (n), y) + wTφ(x (n), y)− wTφ(x (n), y (n))

)where ∆ : Y × Y → R+ ∪ {0}

59 / 1

Page 60: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Learning — Structural SVM — ∆

• A hypothesis field y

• Ty be the collection of cells in the grid Y corresponding tothe region inside the quadrilateral defined by y

• T cy be the complement of Ty in the grid Y

∆(y , y) = 1−# of GT cells in Ty + # of cells NGT in T c

y

Total number of cells in Y

60 / 1

Page 61: Sports Field Localization - Department of Computer Science ... · Motivation Sports Field Localization: Have to gure out where the eld and players are in 3d space in order to make

Experiments:

Datasets:

• 395 images from 20 games from World Cup 2014

• 209 train/val from 10 games

• 186 test from the 10 other games

• 4000 images from 10 NHL games

• 2000 train/val

• 2000 test

61 / 1