Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import cv2
  2.  
  3. face_cascade=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
  4.  
  5. img =cv2.imread("news.jpg")
  6. #gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  7.  
  8. img=cv2.resize(img,(img.shape[1]//2,img.shape[0]//2))
  9.  
  10. faces=face_cascade.detectMultiScale(img,scaleFactor=1.2,minNeighbors=5)#scaleFactor dokładnośc przeszukiwania obrazka
  11. print(type(faces))
  12. print(faces)
  13. for x,y,w,h in faces:
  14. img=cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),3)#podaje wspolrzedne lewygorny wierzcholek prway dolny wierzcholek i kolor i grubosc lini
  15.  
  16. cv2.imshow('Gray',img)
  17. cv2.waitKey(0)
  18. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement