Advertisement
tabnation

Python face req

Jan 5th, 2022
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml
  2. #pip install opencv-python
  3. #py 3.9
  4. import cv2
  5.  
  6. found1= "--"
  7. found2= "--"
  8.  
  9. face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
  10. image = cv2.imread("notthom.jpg")
  11. gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  12. faces = face_cascade.detectMultiScale(gray_image,1.1, 10)
  13.  
  14. for (x, y, width, height) in faces:
  15. cv2.rectangle(image, (x, y,), (x+width, x+height),(0, 255, 255), 10)
  16. found1 = "--notthom.jpg--"
  17.  
  18.  
  19. cv2.imshow("Detected Faces", image)
  20. cv2.waitKey()
  21.  
  22.  
  23. face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
  24. image = cv2.imread("thom.jpg")
  25. gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  26. faces = face_cascade.detectMultiScale(gray_image,1.1, 10)
  27.  
  28. for (x, y, width, height) in faces:
  29. cv2.rectangle(image, (x, y,), (x+width, x+height),(0, 255, 255), 10)
  30. found2 = "--thom.jpg--"
  31.  
  32.  
  33. cv2.imshow("Detected Faces", image)
  34. cv2.waitKey()
  35.  
  36. Final = found1 + found2
  37. print("Pictures with faces =",Final)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement