20
A GPU based Real-Time Line Detector using a Cascaded 2D Line Space Jochen Hunz, Anna Katharina Hebborn, Stefan Müller University of Koblenz - Landau Institut für Computervisualistik Germany [email protected]

A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Embed Size (px)

Citation preview

Page 1: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

A GPU based Real-Time Line Detector using a

Cascaded 2D Line Space Jochen Hunz, Anna Katharina Hebborn, Stefan Müller

University of Koblenz - LandauInstitut für Computervisualistik

Germany

[email protected]

Page 2: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Line Detection

• Task: Find lines in an image (often: Canny image)

• Most common technique: Hough Transform

Jochen Hunz ([email protected]) University of Koblenz-Landau

2

Input Image Canny Image

Page 3: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Hough Transform

For an image point the lines though this

point are the pairs with

Accumulate pairs in the Hough Accumulator.

Jochen Hunz ([email protected]) University of Koblenz-Landau

3

),( ii yx

),( d

sincos 00 yxd

),0[

Page 4: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Hough Transform: Discretization

How to discretize ?

4

x

y

is to small is appropriate

Page 5: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Line Space - Idea• Linear instead of angular parametization

• Number border edges from 0 to 4n-1

• Consider (rasterize) all Lines from Border to Border, identified by a tuple (start, end)

Jochen Hunz ([email protected]) University of Koblenz-Landau

5

0

1

2

3

11

10

9

8

4 5 6 7

15 14 13 12

Line Tuple (1,8)

Page 6: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Rasterization

• Rasterize every line using DDA (DigitialDifferential Analyzer) for example

• Count pixels not equal to zero

• Store result in two dimensional space (LS) ofsize 4n x 4n at position (start,end)

Rasterize every line in parallel on the GPU!

Jochen Hunz ([email protected]) University of Koblenz-Landau

6

Page 7: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Jochen Hunz ([email protected]) University of Koblenz-Landau

7

0

1

2

3

11

10

9

8

4 5 6 7

15 14 13 12 s

e

0

5

10 150 5

10

15

Canny Image Line Space

16 n² Lines

Page 8: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

LS Properties

Jochen Hunz ([email protected]) University of Koblenz-Landau

8

s

e

0

5

10 150 5

10

15

• LS(s,e) = LS(e,s)

• CollinearityLines betweencollinear edges aredegenerated

Page 9: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

CLS: The Cascaded Line Space

• Line Space: 16n² lines to rasterize

• Using DDA, lines have max. length of n

– We rasterize many long lines!

• Performance for image of size 512x512: 34.13 ms

• Idea: Divide Canny image in Cascades of size k*k

Jochen Hunz ([email protected]) University of Koblenz-Landau

9

Page 10: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Cascades (k=4)

Jochen Hunz ([email protected]) University of Koblenz-Landau

10

0

4

12

8

1516 282420 31

32

36

40

44

47

4852566063

0

1 2 30

1

2

3

Page 11: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Cascaded Line Space

Jochen Hunz ([email protected]) University of Koblenz-Landau

11

Page 12: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Observation

• Still 16n² lines to rasterize• But much shorter lines (max length: k)• Merging to global LS necessary• Performance for image of size 512x512:

0.91 ms. (Versus 34.13 ms for global LS)

Jochen Hunz ([email protected]) University of Koblenz-Landau

12

Page 13: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Merging

Jochen Hunz ([email protected]) University of Koblenz-Landau

13

Page 14: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Merging

Jochen Hunz ([email protected]) University of Koblenz-Landau

14

• Determine (or precompute)intersection points for eachcascade• Perform look ups in the CLS:

(2,5) or (5,2) (12,13) or (13,12) (1,6) or (6,1)

• Accumulate CLS values and• Store in next higher hierarchy.

Here at position (2,14)

0

16

16 31

31

Page 15: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Merging

• Repeat merging times

• Performance for image of size 512x512: 7.45 ms.

Jochen Hunz ([email protected]) University of Koblenz-Landau

15

)/( knld

k = n = 16Global LS

k = 4 k = 8Canny

Page 16: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

16

Input Image Canny Image

Line SpaceResult

Canny Operator

Maxima Detection

P = 13.5 %

Page 17: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Performance

Jochen Hunz ([email protected]) University of Koblenz-Landau

17

n

(degree)

P

(%)

Hough

CPU

(ms)

Hough

GPU

(ms)

Line

Space

(ms)

Cascaded Line Space

(ms)

Initial

CascadesMerge Total

64 0.45115.3

16.3

2.14

2.37

2.11

1.560.11 0.02 0.06 0.08

128 0.22613.4

15.1

23.30

26.97

1.56

1.570.60 0.07 0.30 0.37

256 0.1129.8

14.4

147.89

207.79

2.70

4.564.43 0.24 1.49 1.73

512 0.066.7

13.5

780.57

1576.35

8.50

13.2334.13 0.91 7.45 8.36

1024 0.0284.5

10.6

5040.72

12952.30

30.62

59.52247.53 3.31 36.46 39.77

Page 18: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Discussion

• LS captures all potential Lines with noredundancy

• Our brute force CLS implementation cancompete with CUDA Hough

• Merge phase has to be optimized

• LS has high potential

Jochen Hunz ([email protected]) University of Koblenz-Landau

18

Page 19: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

The Future: Line Segment Detection

• We are working on Line Segment Detectionusing the CLS

• CLS provides already line segments of size k in 3ms @1024² images

• Line Segments need to get merged

• For each line exit point in one cascade, thestarting point in the next cascade is well defined

Jochen Hunz ([email protected]) University of Koblenz-Landau

19

Page 20: A GPU based Real-Time Line Detector using a Cascaded 2D Line Space

Line Segment Detection: Merge

Jochen Hunz ([email protected]) University of Koblenz-Landau

20

0

1

2

3

4 5 6 7

15 14 13 12

10

9

8

4 5 6 7

15 14 13 12

s

e

0

5

10 150 5

10

15

s

e

0

5

10 150 5

10

15