daily pastebin goal
0%
SHARE
TWEET

face

a guest Mar 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top