I'm new to Python, but I decided to write a program that takes a picture of a person's face and saves it as "who.jpg". When I run this code, I'm able to see the camera and rectangles around the face, but the "who.jpg" is blank, and it's 0 kb in size. What can I do to have the "who.jpg" take picture of the face and save it? I just need to take the picture of the face one time.
Tony
I guess I can't use imread for videos, and this says I need to use ffmpeg. Am I correct?
https://stackoverflow.com/questions/3726...ng-a-video
import cv2
import sys
cascPath = 'haarcascade_frontalface_default.xml'
faceCascade = cv2.CascadeClassifier(cascPath)
video_capture = cv2.VideoCapture('rtsp://ituser:[email protected]/mpeg4/media.amp')
while True:
# Capture frame-by-frame
ret, frame = video_capture.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30)
)
# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
# Display the resulting frame
img = cv2.imshow('Server Room', frame)
cv2.imwrite("who.jpg", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()Thanks,Tony
I guess I can't use imread for videos, and this says I need to use ffmpeg. Am I correct?
https://stackoverflow.com/questions/3726...ng-a-video
