diff --git a/README.md b/README.md index 2372549..4f0c106 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,8 @@ $ pip3 install opencv-python # This installs numpy as its dependency $ pip3 install face_recognition # This installs dlib as its dependency ``` -I will add more information as the course goes on. +## What this repo has + +* **display.py** program to show a picture using OpenCV functions +* **video\_capture.py** to record what's in the webcam +* **mirror\_facedetect.py** to detect faces in the webcam diff --git a/display.py b/display.py old mode 100644 new mode 100755 index a2a7456..8317b52 --- a/display.py +++ b/display.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import sys import cv2 import numpy diff --git a/mirror_facedetect.py b/mirror_facedetect.py old mode 100644 new mode 100755 index c0fb2d5..1c9e393 --- a/mirror_facedetect.py +++ b/mirror_facedetect.py @@ -1,12 +1,16 @@ +#!/usr/bin/env python3 # mirror_facedetect.py: Detect faces in the view of webcam import cv2 import numpy import face_recognition import sys +import os # Increase this number to speed up and lower the accuracy k=4 +font=cv2.FONT_HERSHEY_PLAIN + # Allow users to change k while running if len(sys.argv)>=2: k=int(sys.argv[1]) @@ -21,6 +25,8 @@ def mark_faces(frm): for i,face in enumerate(faces): top,right,bottom,left=face frm=cv2.rectangle(frm,(k*left,k*top),(k*right,k*bottom),colors[i%3],3) + os.system("clear") # To make the screen not that messy + print("Found {} faces".format(len(faces))) return frm camera=cv2.VideoCapture(0) @@ -31,7 +37,7 @@ def mark_faces(frm): break frm=cv2.flip(frm,1) # This is just to put rectangle to highlight the faces - mark_faces(frm) + frm=mark_faces(frm) cv2.imshow('The Mirror',frm) if cv2.waitKey(1) & 0xFF == ord('q'): break diff --git a/video_capture.py b/video_capture.py old mode 100644 new mode 100755 index 68f0d0f..6def880 --- a/video_capture.py +++ b/video_capture.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import cv2 import numpy # This seems to be useless, but it's needed to operate ndarrays @@ -20,9 +21,10 @@ ret, frame=cap.read() if ret==False: break + frame=cv2.flip(frame,1) # To make mirror effect out.write(frame) cv2.imshow('Camera',frame) - if cv2.waitKey(1) & 0xFF == ord('q'): + if cv2.waitKey(50) & 0xFF == ord('q'): break # Destroy the camera object