Advertisement
Guest User

face

a guest
Mar 23rd, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import numpy
  2. import cv2 as cv
  3.  
  4. face = cv.CascadeClassifier('haarcascade_frontalface_default.xml')
  5. img = cv.imread('bppt2.jpg')
  6. img_gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
  7.  
  8. detection_face = face.detectMultiScale(img_gray,1.1,5)
  9. font = cv.FONT_HERSHEY_SIMPLEX
  10. total = 0
  11.  
  12. for(x,y,w,h) in detection_face:
  13.     total += 1
  14.     cv.putText(img,"Face",(x,y-10),font,0.75,(0,0,255),2,cv.LINE_AA)
  15.     cv.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
  16.     roi_gray = img_gray[y:y+h,x:x+w]
  17.     roi_color = img[y:y+h,x:x+w]
  18.  
  19. cv.putText(img,"Total face is : "+str(total)+ " face",(10,30),font,1,(0,0,0),2,cv.LINE_AA)
  20. cv.imShow('img',img)
  21. cv.waitKey(1)
  22. cv.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement