Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- cap = cv2.VideoCapture('test.mp4')
- #cap = cv2.VideoCapture(0) #tried using webcam and works
- count = 0
- while cap.isOpened():
- ret,frame = cap.read()
- cv2.imshow('window-name',frame)
- face_cascade = cv2.CascadeClassifier('C:/ProgramData/Anaconda2/pkgs/opencv-3.2.0-np111py27_0/Library/etc/haarcascades/haarcascade_frontalface_default.xml')
- gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
- faces = face_cascade.detectMultiScale(gray, 1.3, 5)
- for (x, y, w, h) in faces:
- cv2.imwrite("frame%d.jpg" % count, frame)
- count = count + 1
- if cv2.waitKey(10) & 0xFF == ord('q'):
- break
- cap.release()
- cv2.destroyAllWindows() # destroy all the opened windows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement