0% found this document useful (0 votes)
22 views2 pages

Face Detection in A Few Lines

This document summarizes an IPython notebook session where an image is loaded, face detection is performed on the image, and rectangles are drawn around the detected faces. Specifically, it imports OpenCV libraries, defines a function to display an image, loads and displays an image, detects faces in the image using a pretrained classifier, and draws rectangles around the detected face regions.

Uploaded by

Zachariah Garner
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Face Detection in A Few Lines

This document summarizes an IPython notebook session where an image is loaded, face detection is performed on the image, and rectangles are drawn around the detected faces. Specifically, it imports OpenCV libraries, defines a function to display an image, loads and displays an image, detects faces in the image using a pretrained classifier, and draws rectangles around the detected face regions.

Uploaded by

Zachariah Garner
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

4/22/13

IPython Notebook

I n[ 3 ] : i m p o r ts y s i m p o r to s i m p o r tn u m p ya sn p i m p o r tc v 2 f r o mI P y t h o n . c o r e . d i s p l a yi m p o r tI m a g e

I n[ 4 ] : d e fs h o w ( i m a g e ) : c v 2 . i m w r i t e ( ' t m p 2 . j p g ' ,i m a g e ) r e t u r nI m a g e ( f i l e n a m e = ' t m p 2 . j p g ' )

I n[ 9 ] : # i m a g e=c v 2 . i m r e a d ( ' / h o m e / z x / s a r a h . j p g ' ) i m a g e=c v 2 . i m r e a d ( ' / h o m e / z x / 8 2 7 6 4 0 5 . j p g ' ) s h o w ( i m a g e )

O u t [ 9 ] :

I n[ 1 0 ] : T R A I N S E T=" / h o m e / z x / l b p c a s c a d e _ f r o n t a l f a c e . x m l " c l a s s i f i e r=c v 2 . C a s c a d e C l a s s i f i e r ( T R A I N S E T ) f a c e s=c l a s s i f i e r . d e t e c t M u l t i S c a l e ( i m a g e ) f a c e s O u t [ 1 0 ] : a r r a y ( [ [ 5 4 7 ,1 8 4 , 4 2 , 4 2 ] , [ 2 5 2 , 5 9 , 7 7 , 7 7 ] ] ,d t y p e = i n t 3 2 ) I n[ 1 1 ] : f o rfi nf a c e s : x ,y ,w ,h=[vf o rvi nf]


localhost:8888/99b68ec0-5b24-4a33-be48-634fb530646f/print 1/2

4/22/13

IPython Notebook

c v 2 . r e c t a n g l e ( i m a g e ,( x , y ) ,( x + w , y + h ) ,( 0 , 0 , 2 5 5 ) )

I n[ 1 2 ] : s h o w ( i m a g e ) O u t [ 1 2 ] :

I n[] :

localhost:8888/99b68ec0-5b24-4a33-be48-634fb530646f/print

2/2

You might also like