Ask Your Question

maymuna's profile - activity

2017-04-27 08:30:31 -0600 asked a question Slow processing on Raspberry Pi using Python

hi i am using raspberry pi for my final year project. i wrote some scripts for face detection, training and face recognition all are working fine but its very slow. it shows only single frame per second because of processing of each frame. i have to extend this work upto emotion detection as well hence i want to make it faster. i also ran same codes on my pc it was pretty fast which means my scripts are good but i would want it to be faster on my pi. Please HELP !!!

this is my face detection code

import numpy as np
import cv2

detector= cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(0)

while(True):
    ret, img = cap.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    faces = detector.detectMultiScale(gray, 1.3, 5)
    for (x,y,w,h) in faces:
        cv2.rectangle(img,(x,y),(x+w,y+h),(254,0,0),2)
    cv2.imshow('frame',img)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()