camera.resolution = (640, 480)
camera.framerate = 32
raw_capture = PiRGBArray(camera, size=(640, 480))
raw_array = PiArrayOutput(camera)

fd = FaceDetector(args['face'])
time.sleep(0.1)

scale_factor = input('Enter scale factor: ')
min_neighbours = input('Enter minimum neighbours: ')


for f in camera.capture_continuous(stream, format='bgr', use_video_port = True):

    frame = f.array

    frame = imgtools.resize(frame, width = 300)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    face_rects = fd.detect_face(gray, scale_factor, min_neighbours, minSize = (30, 30))
    frame_clone = frame.copy()

    for (x, y, w, h) in face_rects:
       cv2.rectangle(frame_clone, (x, y), (x + w, y + h), (0, 255, 0), 2)

    cv2.imshow('Face', frame_clone)
    raw_capture.truncate(0)

    if cv2.waitKey(1) & 0xFF == ord('q'):
       break
Example #2
0
camera.resolution = (640, 480)
camera.framerate = 32
raw_capture = PiRGBArray(camera, size=(640, 480))
raw_array = PiArrayOutput(camera)

fd = FaceDetector(args['face'])
time.sleep(0.1)

scale_factor = input('Enter scale factor: ')
min_neighbours = input('Enter minimum neighbours: ')

for f in camera.capture_continuous(stream, format='bgr', use_video_port=True):

    frame = f.array

    frame = imgtools.resize(frame, width=300)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    face_rects = fd.detect_face(gray,
                                scale_factor,
                                min_neighbours,
                                minSize=(30, 30))
    frame_clone = frame.copy()

    for (x, y, w, h) in face_rects:
        cv2.rectangle(frame_clone, (x, y), (x + w, y + h), (0, 255, 0), 2)

    cv2.imshow('Face', frame_clone)
    raw_capture.truncate(0)

    if cv2.waitKey(1) & 0xFF == ord('q'):
from __future__ import print_function
from detectors.face import FaceDetector
from imgtools import imgtools
import argparse
import cv2

ap = argparse.ArgumentParser()
ap.add_argument('-f', '--face', required=True, help='path to face cascade')
ap.add_argument('-i', '--image', required=True, help='path to image')
args = vars(ap.parse_args())

image = cv2.imread(args['image'])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

fd = FaceDetector(args['face'])
scale_factor = input('Enter scale factor: ')
min_neighbours = input('Enter minimum neighbours: ')

face_rects = fd.detect_face(gray,
                            scale_factor,
                            min_neighbours,
                            minSize=(30, 30))
print('{} face(s) detected'.format(len(face_rects)))

for (x, y, w, h) in face_rects:
    cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)

resized = imgtools.resize(image, height=500)
cv2.imshow('Faces', resized)
cv2.waitKey(0)
from __future__ import print_function
from detectors.face import FaceDetector
from imgtools import imgtools
import argparse
import cv2

ap = argparse.ArgumentParser()
ap.add_argument('-f', '--face', required = True, help = 'path to face cascade')
ap.add_argument('-i', '--image', required = True, help = 'path to image')
args = vars(ap.parse_args())

image = cv2.imread(args['image'])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

fd = FaceDetector(args['face'])
scale_factor = input('Enter scale factor: ')
min_neighbours = input('Enter minimum neighbours: ')

face_rects = fd.detect_face(gray, scale_factor, min_neighbours, minSize= (30, 30))
print('{} face(s) detected'.format(len(face_rects)))

for (x,y,w,h) in face_rects:
  cv2.rectangle(image, (x,y), (x+w, y+h), (0, 255, 0), 2)

resized = imgtools.resize(image, height = 500)
cv2.imshow('Faces', resized)
cv2.waitKey(0)