Exemplo n.º 1
0
class App(object):
    def __init__(self):
        self.imscan = ImageScanner()
        self.cap = cv2.VideoCapture(0)

    def run(self):
        k = 0
        while(True):
            k += 1
            ret, frame = self.cap.read()
            img = cv2.resize(frame, (frame.shape[1] / 2, frame.shape[0] / 2), interpolation=cv2.INTER_CUBIC)
            imgout = img.copy()

            # Get BPM
            bpm = self.imscan.get_bpm(img)

            # Get person's name
            face_detection = self.imscan.recognize_face(img)
            if face_detection is not None:
                person_name, bounding_box, is_smiling = face_detection
                x0, y0, x1, y1 = bounding_box
                cv2.rectangle(imgout, (x0, y0), (x1, y1), (0, 255, 0), 2)
                cv2.putText(imgout, "{} Hz".format(bpm), (x1 + 5, y1), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (50, 255, 50))
                cv2.putText(imgout, person_name, (x0, y1 + 25), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (50, 20, 255))
                if is_smiling != []:
                    print "Smiling!"
                else:
                    print "Not smiling"

            print self.imscan.likeness
            cv2.imshow("Display", imgout)
            key = cv2.waitKey(10) & 0xff
            if key == ord('q'):
                break
Exemplo n.º 2
0
import sys
import os
import cv2
from vision import ImageScanner
fpath = os.path.dirname(os.path.abspath(__file__))


if __name__ == '__main__':
    dataset_location = os.path.join(fpath, '..', '..', 'data')
    imscan = ImageScanner()

    people = os.listdir(dataset_location)
    for person in people:
        fullpath = os.path.join(dataset_location, person)
        if not os.path.isdir(fullpath):
            print "Skipping ", person
            continue

        print 'Viewing {}'.format(person)
        for image_name in os.listdir(fullpath):
            img = cv2.imread(os.path.join(fullpath, image_name))
            img = cv2.resize(img, (img.shape[1] / 2, img.shape[0] / 2), interpolation=cv2.INTER_CUBIC)

            detection = imscan.detect_face(img)
            if detection is not None:
                x0, y0, x1, y1 = detection
                cv2.rectangle(img, (x0, y0), (x1, y1), (0, 255, 0), 2)
                cv2.putText(img, "{} at {}".format(person, image_name), (x0, y1 + 25),
                            cv2.FONT_HERSHEY_SIMPLEX, 0.5, (50, 255, 50))
            else:
                print image_name, 'no face detected'
Exemplo n.º 3
0
 def __init__(self):
     self.imscan = ImageScanner()
     self.cap = cv2.VideoCapture(0)