File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1+
2+ import PIL .Image
3+ from PIL .ExifTags import TAGS
14from skimage import data
25from skimage .feature import Cascade
3-
46import matplotlib .pyplot as plt
57from matplotlib import patches
8+ import imageio
9+ import sys
10+ from os .path import join
611
712# Load the trained file from the module root.
813trained_file = data .lbp_frontal_face_cascade_filename ()
914
1015# Initialize the detector cascade.
1116detector = Cascade (trained_file )
1217
13- img = data .astronaut ()
18+ if len (sys .argv ) > 1 :
19+ image_path = sys .argv [1 ]
20+ else :
21+ image_path = join ("sample_images" , "IMG-0311_xmas_2020.JPG" )
22+ # image_path = join("sample_images", "owls.jpg")
23+
24+ img = imageio .imread (image_path )
1425
1526detected = detector .detect_multi_scale (img = img ,
1627 scale_factor = 1.2 ,
1728 step_ratio = 1 ,
1829 min_size = (60 , 60 ),
19- max_size = (123 , 123 ))
30+ max_size = (600 , 600 ))
2031
2132plt .imshow (img )
2233img_desc = plt .gca ()
3546 )
3647 )
3748
49+ img = PIL .Image .open (image_path )
50+
51+ data = {TAGS [k ]: v for k , v in img ._getexif ().items () if k in TAGS }
52+ data ["Number of faces detected" ] = len (detected )
53+
54+ print (data )
55+
3856plt .show ()
You can’t perform that action at this time.
0 commit comments