Skip to content

Commit

Permalink
Draw face detection rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
jack committed Mar 28, 2019
1 parent 966daf7 commit 1def872
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Binary file modified core/__pycache__/video.cpython-35.pyc
Binary file not shown.
27 changes: 20 additions & 7 deletions core/video.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cv2

from core.core_face_identification import FaceIdentification


def stream():
Expand All @@ -13,13 +13,20 @@ def stream():

_,frame = cap.read() #get each frame

cv2.imshow('Video',frame) #show each frame

if not flag:

#detect face in video
face = FaceIdentification.detect_face(frame)

#draw rec on the frame if detect
try:
face = face[1]
x,y,w,h = face
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.imshow('Video',frame) #show each frame

except:
cv2.imshow('Video',frame) #show each frame

name = "img/frame.jpg"
cv2.imwrite(name,frame)
flag = True
#break when esc key is pressed
k = cv2.waitKey(1)
if k == 27:
Expand All @@ -31,3 +38,9 @@ def stream():
cv2.destroyAllWindows()
cap.release() #release all resources


# if not flag:

# name = "img/frame.jpg"
# cv2.imwrite(name,frame)
# flag = True
Binary file removed img/frame.jpg
Binary file not shown.

0 comments on commit 1def872

Please sign in to comment.