how are you? I hope you all do well.

If someone could help me with an issue I would be very grateful, I am working on my Final Paper on my raspberry pi 3b, and I noticed when run remotly on VNC that in the simple example below face detection the result is quite slow, I would like to know if there is anything that I can do to improve this.

thank you all.

    # -*- coding: cp1252 -*-
import numpy as np
import cv2
def main():
    #loads the classifier
    face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    #load the cam
    cap = cv2.VideoCapture(0)
        #load the frame of cam
        frameExiste, frame = cap.read()
        if(frameExiste == False):
        #convert to grayscale
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = face_cascade.detectMultiScale(gray, 1.3, 5)
        for (x, y, w, h) in faces:
            frame = cv2.rectangle(frame,(x,y),(x+w,y+h),(0,0,255),5)
        cv2.imshow("deteccao", frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
if __name__ == "__main__":

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.