computer and machine visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly...

24
March 21, 2014 Sam Siewert Computer and Machine Vision Lecture Week 10 Part-2 Skeletal Models and Face Detection

Upload: others

Post on 06-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

March 21, 2014 Sam Siewert

Computer and Machine

Vision

Lecture Week 10

Part-2

Skeletal Models and Face

Detection

Page 2: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Outline of Week 10 Lab #4 Overview

Lab #5 and #6 Extended Lab Overview

SIFT and SURF High Level View

Skeletal Models and Shape Recognition

Introduction to High Level Face Detection and Recognition with OpenCV

Sam Siewert 2

Page 3: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Skeletal Models

Easier to Recognize Shape when Thinned Down to Skeleton – Thinning is a process of Finding Edges and

reducing Width

– Transformation

Read E.R. Davies Supplemental Chapter 2 Materials for Image Operation Notation

Read E.R. Davies Chapter 9 for Binary Shape Analysis Algorithm

Sam Siewert 3

Page 4: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Study skeletal.cpp Pre-processing

Understand Process (Loop)

Exit Conditions

Sam Siewert 4

Page 5: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

OpenCV Skeletal Transform – Step 1 1. Note that We Apply to Graymap

– Load Color JPG Mat src = imread(filename, CV_LOAD_IMAGE_COLOR);

– Convert to Graymap cvtColor(src, gray, CV_BGR2GRAY);

Use common conversion – 0.3*Red + 0.59*Green +

0.11*Blue over All Pixels

Sam Siewert 5

Page 6: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

OpenCV Skeletal Transform – Step 2 2. Convert Grayscale to Binary Image

– Simple Threshold as Done in Lab #3

– Consider Histogram Analysis – threshold(gray, binary, 70, 255, CV_THRESH_BINARY);

Sam Siewert 6

Page 7: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

OpenCV Skeletal Transform – Step 2 3. Loop to Erode and Dilate Image Iteratively

– OpenCV Erode and Dilate Example and Tutorial

– Just Like E.R. Davies Thinning (P. 244-250)

– Specifically Davies Algorithm on P. 249

Sam Siewert 7

Page 8: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

OpenCV Skeletal Transform

4. Exit Condition is Thinness

– Specify Pixel Width for Thinning

– Just Like E.R. Davies Thinning (P. 249)

“finished” condition to exit do loop

Challenge Has Been the Computational

Complexity of Otherwise Simple

Transformation Logic

Sam Siewert 8

Page 9: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Value of Skeletal to Shape

Recognition Skeletal Shape is Invariant to Lighting

– Binary Threshold (No Color)

– Within Reason for Extremely Shadowed or

Washed out Images

Not Scale or Rotationally Invariant, But

Less Sensitive to Noise in Images

Useful for Gate Analysis and Behavior Sam Siewert 9

Page 10: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

For Skeletal Ground Up - Start with

Threshold Assumption

Assume that Threshold transforms image to

1’s on background of 0’s, or PBM from PGM

Define What Connected Means

Assertion that Foreground is 8-connected (all

nearest neighbors) and Background is 4-

connected (only orthogonal neighbors)

Sam Siewert 10

1 1 1

1 1 1

1 1 1

x 0 x

0 0 0

x 0 x

Page 11: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Label Connected Regions

(Skeletal Model Concepts)

Raster Image with Definition of Connectedness for FG and BG

Uniquely Assign ID to Each Connected Region

Filter Regions Below a Size Threshold

Skeleton is the Medial Line Along Limbs or Regions

E.g. “A GENERALIZED MORPHOLOGICAL SKELETON TRANSFORM AND EXTRACTION OF STRUCTURAL SHAPE COMPONENTS”, by Jianning Xu, Computer Science Department, Rowan University Glassboro, NJ, IEEE ICIP 2003.

Sam Siewert 11

Page 12: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Skeletal Models for Motion

Tracking Like Fiducial Markers on Robotic System, used to Track Limbs (Kinematics, inverse Kinmatics for rigid bodies)

E.g. for human figures - http://faculty.cs.tamu.edu/jchai/papers/accv-09.pdf

Sam Siewert 12

Page 13: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Skeletal Models to Robotics Useful for Basic Gesture Recognition – Requires Clear Separation of FG/BG

– Works Better with Stable Camera (Stereo)

– Motion in Near Foreground

Used for Generalized Recognition in 3D Along with Active Depth Mapping – 20 Joints per Player, 6 people in theory

– 640x480 RGB, 8-bit

– SDK Popularized by Willow Garage and ROS

– http://www.microsoft.com/en-us/kinectforwindows/develop/

– http://www.willowgarage.com/pages/software/ros-platform

– http://www.willowgarage.com/blog/2010/11/22/kinect-ros-moving-forward-quickly

Sam Siewert 13

Page 14: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Distance Metric for 8-Connected

Foreground

d8 = max(|xi – xj|, |yi – yj|)

Computes Distance From Edge Such that

Center of Object Has Highest Value

Sam Siewert 14

From Computer and Machine Vision,

E.R. Davies, page 241.

Page 15: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Method to Compress Objects

Object Shapes Described by Max Distance Values At Medial Locations

Compressed Form, Can be Expanded by Propagation to Min Distance Edge When Rendered

See Page 243, Figure 9.7 in CMV, E.R. Davies

Sam Siewert 15

Page 16: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Flood Fill Fills in Shape Between Defined Edges

4-Connected vs. 8-Connected

Target Color (Shade) and Replacement Color

(Shade) are used with Starting Pixel and Algorithm

Runs Recursive

E.g. 4-Connected Flood Fill

– From Wikipedia Flood-fill (node, target-color, replacement-color):

1. If the color of node is not equal to target-color, return.

2. Set the color of node to replacement-color.

3. Perform Flood-fill (one step to the west of node, target-color, replacement-color).

Perform Flood-fill (one step to the east of node, target-color, replacement-color).

Perform Flood-fill (one step to the north of node, target-color, replacement-color).

Perform Flood-fill (one step to the south of node, target-color, replacement-color).

4. Return.

Sam Siewert 16

Page 17: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Thinning (Skeletons) Useful for Character Recognition and Gesture

Recognition

– Eliminates Redundant Shape Information and

Preserves Topological Information Only (a Form of

Compression)

– Connected Set of Medial Lines Along Limbs

Sam Siewert 17

Fig 9.8 Mathematical Idealized Medians Fig 9.9 From Thinning Algorithm From Computer and Machine Vision,

E.R. Davies, page 246.

Page 18: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Chi Function Used To Determine Which Pixels Can Be Removed and Which Must Be Retained

– If Pixel is on Boundary, it Can Be Removed and Chi=2, Sigma != 1

– Sigma is Sum of Neighbors (Where FG=1, BG=0)

– Chi is a Complex Conditional Expression to Encode When Pixel of Interest is On An Edge and Can Be Removed

– Note Edge Conditions to Understand Chi

Sam Siewert 18

Line End

0 0 1

0 1 1

1 1 1

SE edge

1 1 1

1 1 1

0 0 0

N edge

0 1 1

0 1 1

0 1 1

E edge

0 0 0

1 1 1

1 1 1

S edge

1 1 0

1 1 0

1 1 0

W edge

1 1 1

1 1 0

1 0 0

NW edge

0 0 0

0 1 0

0 1 0

Page 19: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Thinning Algorithm Chi

Consider All Cases of Proper Edges

Where Pixel Can Be Thinned (Chi=2) and

Sigma != 1 Chi = (A1 != A3) + (A3 != A5) + (A5 != A7) + (A7

!= A1) + 2*((A2 > A1) && (A2 > A3)) + ((A4 > A3)

&& (A4 > A5)) + ((A6 > A5) && (A6 > A7)) + ((A8 >

A7) && (A8 > A1))

E.g. Here are Some Non-Edges to Retain

Sam Siewert 19

Isolated

0 0 0

0 1 0

0 1 0

1 0 0

0 1 1

1 1 1

Chi=4

1 0 1

0 1 0

1 0 1

Chi=8

Page 20: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Combined Distance and

Thinning for Guided Compute Maximum Distance and Thin –

Better for Parallel Speed-up (P. 252 CMV,

E.R. Davies)

Sam Siewert 20

From Computer and

Machine Vision, E.R.

Davies, page 252.

Page 21: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Intro to Face Detection Pattern Matching Well Known Features

– Eyes

– Nose

– Mouth

Characteristics of the Pattern

– Eye Separation, Eyes to Nose, Nose to Mouth

– If We can See all Three Features (and Detect) a Face Has Similar Components (Distance) Measure for Features

– Viewing Angle, Occlusion, Lighting Complicates

Sam Siewert 21

Page 22: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Evidence of Scanning

Human Saccades – Fast Human Eye

Movement used in Facial Scanning

Study with Pupil Tracker

900 degrees / sec rate

200 millisec to innitiate, 20-200 millisec to

Complete

Sam Siewert 22

http://en.wikipedia.org/wiki/Saccades

Page 23: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Haar Features

Pages 506-516 in Learning OpenCV

Transform the Image using Haar Wavelets

Facial Features – Eyes, Nose, Mouth and

Shape of Face are Simlper in the

Transform and Better Invariance

Match Transformed Test Image to Haar

Transform Database

Note Regions of Interest in Test Image

Sam Siewert 23

Page 24: Computer and Machine Visionecee.colorado.edu/~siewerts/extra/ecen5763/ecen...moving-forward-quickly Sam Siewert 13 . Distance Metric for 8-Connected Foreground ... Sam Siewert 14 From

Facial Detection and

Recognition Research Viola and Jones – Robust Real-Time Face

Detection (See Presentation and Paper on

BB)

Ada Boost

Open Research Today – Value to

Security, Photo Databases, Social

Networking … Sam Siewert 24