FaceDetection
This commit is contained in:
parent
43cd118f7a
commit
9d896a1467
22
untitled.py
22
untitled.py
@ -31,28 +31,26 @@ import numpy as np
|
||||
camera = PiCamera()
|
||||
camera.resolution = (640, 480)
|
||||
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
||||
stream = BytesIO()
|
||||
#camera.start_recording('my_video.h264')
|
||||
#print('started recodring')
|
||||
#camera.wait_recording(10)
|
||||
#camera.stop_recording()
|
||||
|
||||
while True:
|
||||
print('taking photo')
|
||||
print('Taking photo')
|
||||
camera.capture('img.jpg')
|
||||
img = cv2.imread('img.jpg',1)
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
|
||||
|
||||
for (x,y,w,h) in faces:
|
||||
img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
|
||||
#roi_gray = gray[y:y+h, x:x+w]
|
||||
#roi_color = img[y:y+h, x:x+w]
|
||||
|
||||
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
|
||||
cv2.imwrite('result.jpg', gray)
|
||||
roi_gray = gray[y:y+h, x:x+w]
|
||||
roi_color = img[y:y+h, x:x+w]
|
||||
print('Drawing face')
|
||||
print('displying iamge')
|
||||
cv2.imshow('image',img)
|
||||
cv2.waitKey(100)
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
cv2.destroyAllWindows()
|
||||
break
|
||||
#cv2.destroyAllWindows()
|
||||
|
||||
print('Finshed')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user