Top Banner
Code Development for Processing Video Streams “NOT reinventing the wheel” lides taken from a presentation by Dr. Gary Bradski ntel Computer Corp.
36
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Code Development for Processing Video Streams

Code Development for Processing Video Streams

“NOT reinventing the wheel”

Slides taken from a presentation by Dr. Gary Bradski,Intel Computer Corp.

Page 2: Code Development for Processing Video Streams

Progress in Computer Vision• 1970’s vision student

– First step: Build digitizer and video display hardware

• 1980’s vision student– First step: Write image class library and interface

to video capture card

• 2000’s vision student– First step: Learn to use standard libraries with

standard hardware!

Page 3: Code Development for Processing Video Streams

Standard Libraries

VisSDK

OpenCV

IPL

VIPeR ToolkitAn example programrunning under Windowswhich can be customized

Link from network file system Download to your local disk

Page 4: Code Development for Processing Video Streams

Standard Vision Libraries

• Intel IPL (now IPP) – Image processing library– Optimized (MMX) code for filtering, FFT, etc.

• Intel OpenCV – Open Computer Vision library– Higher level support for image representation and

manipulation

• Microsoft Vision SDK – Similar to OpenCV– Includes standard routines for image and video input

and output

– Otherwise, not used very much here

Page 5: Code Development for Processing Video Streams

VIPER• This is a starter project in Visual C++ which

integrates the standard libraries. It includes–Examples of reading and writing images and video files–Examples of capturing live video and processing it–Some simple rendering and interaction hooks under

Windows

• Used extensively in Digital Video Special Effects class for several years with great success

• It is not elegant and beautiful code.• It is a quick way to implement experiments.

Page 6: Code Development for Processing Video Streams

First Problem Set

• It will give you a chance to use Viper with standard libraries to do some simple processing

• Two parts:– Read in an image and compute its histogram– Read in an AVI file and do some simple “tracking”

• Instructions for installing VIPER and connecting to standard libraries will be provided.

• Tutorial on VIPER, Visual C++, and histograms.– This Friday from 4-5. Location: CCB 155

Page 7: Code Development for Processing Video Streams

Image Analysis

• Thresholds• Statistics• Pyramids• Morphology• Distance transform• Flood fill• Feature detection• Contours retrieving

Page 8: Code Development for Processing Video Streams

Image ThresholdingImage Thresholding

• Fixed threshold;

• Adaptive threshold;

Page 9: Code Development for Processing Video Streams

Image Thresholding ExamplesImage Thresholding Examples

Source pictureSource picture Fixed thresholdFixed threshold Adaptive thresholdAdaptive threshold

Page 10: Code Development for Processing Video Streams

StatisticsStatistics

• min, max, mean value, standard deviation over the image

• Norms C, L1, L2

• Multidimensional histograms

• Spatial moments up to order 3 (central, normalized, Hu)

Page 11: Code Development for Processing Video Streams

Image PyramidsImage Pyramids

• Gaussian and Laplacian pyramids

• Image segmentation by pyramids

Page 12: Code Development for Processing Video Streams

Image PyramidsImage Pyramids

• Gaussian and Laplacian

Page 13: Code Development for Processing Video Streams

Pyramid-based color segmentationPyramid-based color segmentation

On still picturesOn still pictures And on moviesAnd on movies

Page 14: Code Development for Processing Video Streams

Morphological OperationsMorphological Operations

• Two basic morphology operations using structuring element: erosion dilation

• More complex morphology operations:openingclosingmorphological gradient top hatblack hat

Page 15: Code Development for Processing Video Streams

Morphological Operations ExamplesMorphological Operations Examples• Morphology - applying Min-Max. Filters and its combinations

Opening IoB= (IB)BDilatation IBErosion IBImage I

Closing I•B= (IB)B TopHat(I)= I - (IB) BlackHat(I)= (IB) - IGrad(I)= (IB)-(IB)

Page 16: Code Development for Processing Video Streams

Distance TransformDistance Transform

• Calculate the distance for all non-feature points to the closest feature point

• Two-pass algorithm, 3x3 and 5x5 masks, various metrics predefined

Page 17: Code Development for Processing Video Streams

Flood FillingFlood Filling

• Simple • Gradient

Page 18: Code Development for Processing Video Streams

Feature DetectionFeature Detection

• Fixed filters (Sobel operator, Laplacian);• Optimal filter kernels with floating point

coefficients (first, second derivatives, Laplacian)• Special feature detection (corners)• Canny operator• Hough transform (find lines and line segments)• Gradient runs

Page 19: Code Development for Processing Video Streams

Canny Edge DetectorCanny Edge Detector

Page 20: Code Development for Processing Video Streams

Hough TransformHough TransformDetects lines in a binary image

•Probabilistic Probabilistic Hough TransformHough Transform•Standard Hough Standard Hough

TransformTransform

Page 21: Code Development for Processing Video Streams

Contour RetrievingContour Retrieving

• The contour representation:Chain code (Freeman code)Polygonal representation

Initial Point

Chain code for the curve: 34445670007654443

Contour representation

Page 22: Code Development for Processing Video Streams

Hierarchical representation of contours

Image Boundary

(W1) (W2) (W3)

(B2) (B3) (B4)

(W5) (W6)

Page 23: Code Development for Processing Video Streams

Contours ExamplesContours Examples

Source Picture(300x600 = 180000 pts total)

Retrieved Contours (<1800 pts total)

After Approximation(<180 pts total)

And it is rather fast: ~70 FPS for 640x480 on complex scenes

Page 24: Code Development for Processing Video Streams

Optical FlowOptical Flow

• Block matching technique

• Horn & Schunck technique

• Lucas & Kanade technique

• Pyramidal LK algorithm

• 6DOF (6 degree of freedom) algorithm

y

xt

yyx

yxx

I

IIb

III

IIIGyxX

bXG

dtdyyIdtdxxItI

tyxIdttdyydxxI

,,

,),,(

,

);/(/)/(//

);,,(),,(

2

2

Optical flow equations:Optical flow equations:

Page 25: Code Development for Processing Video Streams

Pyramidal Implementation of the Pyramidal Implementation of the optical flow algorithmoptical flow algorithm

J image I image

Image Pyramid Representation

Iterative Lucas – Kanade Scheme

Generic Image

(L-1)-th Level

L-th Level

Location of point u on image uL=u/2L

Spatial gradient matrix

Standard Lucas – Kanade scheme for optical flow computation at level L dL

Guess for next pyramid level L – 1

Finally,

Image pyramid building

Optical flow computation

2

2

,

,

yyx

yxx

III

IIIG

)(21 LLL dgg

00 gdd

dUV

Page 26: Code Development for Processing Video Streams

Pyramidal Implementation of the Pyramidal Implementation of the optical flow algorithmoptical flow algorithm

Page 27: Code Development for Processing Video Streams

6DOF Algorithm6DOF Algorithm

).(sX

N

i ROI

Tit

N

i ROIi

Ti IIdsII

sXIsII

i

11

///

Parametrical optical flow equations:Parametrical optical flow equations:

Page 28: Code Development for Processing Video Streams

3D reconstruction3D reconstruction• Camera Calibration

• View Morphing

• POSIT

Page 29: Code Development for Processing Video Streams

Camera CalibrationCamera Calibration• Define intrinsic and extrinsic camera parameters.

• Define Distortion parametersDefine Distortion parameters

],[],,,[,,,

100

0

0

,][

3

2

1

333231

232221

131211

vupZYXP

t

t

t

T

rrr

rrr

rrr

Rcf

cf

A

PRTAp

yy

xx

.

)],2/(2[)(~)],2/(2[)(~

222

212

42

21

221

42

21

yxr

yyrpxprkrkcvvv

xxrpyprkrkcuuu

y

x

Page 30: Code Development for Processing Video Streams

Camera CalibrationCamera Calibration

Now, camera calibration can be done by holding checkerboard in front of the camera for a few seconds.

And after that you’ll get:

3D view of etalon3D view of etalon Un-distorted imageUn-distorted image

Page 31: Code Development for Processing Video Streams

View MorphingView Morphing

Page 32: Code Development for Processing Video Streams

POSIT AlgorithmPOSIT Algorithm

• Perspective projection:

Weak-perspective projection:

iiiiii YZfyXZfx )/(,)/(

./,, ZfsYsyXsx iiii

Page 33: Code Development for Processing Video Streams

References References • M.Hu.Visual Pattern Recognition by Moment Invariants, IRE Transactions on

Information Theory, 8:2, pp. 179-187, 1962.• B. Jahne. Digital Image Processing. Springer, New York, 1997.• M. Kass, A. Witkin, and D. Terzopoulos. Snakes: Active Contour Models,

International Journal of Computer Vision, pp. 321-331, 1988.• J.Matas, C.Galambos, J.Kittler. Progressive Probabilistic Hough Transform.

British Machine Vision Conference, 1998.• A. Rosenfeld and E. Johnston. Angle Detection on Digital Curves. IEEE Trans.

Computers, 22:875-878, 1973.• Y.Rubner.C.Tomasi,L.J.Guibas.Metrics for Distributions with Applications to

Image Databases. Proceedings of the 1998 IEEE International Conference on Computer Vision, Bombay, India, January 1998, pp. 59-66.

• Y. Rubner. C. Tomasi, L.J. Guibas. The Earth Mover’s Distance as a Metric for Image Retrieval. Technical Report STAN-CS-TN-98-86, Department of Computer Science, Stanford University, September, 1998.

• Y.Rubner.C.Tomasi.Texture Metrics. Proceeding of the IEEE International Conference on Systems, Man, and Cybernetics, San-Diego, CA, October 1998, pp. 4601- 4607. http://robotics.stanford.edu/~rubner/publications.html

Page 34: Code Development for Processing Video Streams

ReferencesReferences• Gunilla Borgefors. Distance Transformations in Digital Images.Computer

Vision, Graphics and Image Processing 34, 344-371,(1986).• G. Bradski and J. Davis. Motion Segmentation and Pose Recognition with

Motion History Gradients. IEEE WACV'00, 2000.• P. J. Burt, T. H. Hong, A. Rosenfeld. Segmentation and Estimation of

Image Region Properties Through Cooperative Hierarchical Computation. IEEE Tran. On SMC, Vol. 11, N.12, 1981, pp.802-809.

• J.Canny.A Computational Approach to Edge Detection, IEEE Trans. on Pattern Analysis and Machine Intelligence, 8(6), pp.679-698 (1986).

• J. Davis and Bobick. The Representation and Recognition of Action Using Temporal Templates. MIT Media Lab Technical Report 402,1997.

• Daniel F. DeMenthon and Larry S. Davis. Model-Based Object Pose in 25 Lines of Code. In Proceedings of ECCV '92, pp. 335-343, 1992.

• Andrew W. Fitzgibbon, R.B.Fisher. A Buyer’s Guide to Conic Fitting.Proc.5 th British Machine Vision Conference, Birmingham, pp. 513-522, 1995.

• Berthold K.P. Horn and Brian G. Schunck. Determining Optical Flow. Artificial Intelligence, 17, pp. 185-203, 1981.

Page 35: Code Development for Processing Video Streams

ReferencesReferences

• J. Serra. Image Analysis and Mathematical Morphology. Academic Press, 1982.

• Bernt Schiele and James L. Crowley. Recognition without Correspondence Using Multidimensional Receptive Field Histograms. In International Journal of Computer Vision 36 (1), pp. 31-50, January 2000.

• S. Suzuki, K. Abe. Topological Structural Analysis of Digital Binary Images by Border Following. CVGIP, v.30, n.1. 1985, pp. 32-46.

• C.H.Teh, R.T.Chin.On the Detection of Dominant Points on Digital Curves. - IEEE Tr. PAMI, 1989, v.11, No.8, p. 859-872.

• Emanuele Trucco, Alessandro Verri. Introductory Techniques for 3-D Computer Vision. Prentice Hall, Inc., 1998.

• D. J. Williams and M. Shah. A Fast Algorithm for Active Contours and Curvature Estimation. CVGIP: Image Understanding, Vol. 55, No. 1, pp. 14-26, Jan., 1992. http://www.cs.ucf.edu/~vision/papers/shah/92/WIS92A.pdf.

• A.Y.Yuille, D.S.Cohen, and P.W.Hallinan. Feature Extraction from Faces Using Deformable Templates in CVPR, pp. 104-109, 1989.

• Zhengyou Zhang. Parameter Estimation Techniques: A Tutorial with Application to Conic Fitting, Image and Vision Computing Journal, 1996.

Page 36: Code Development for Processing Video Streams