Search code examples
pythonopencvkerasoperating-systemartificial-intelligence

import cv2 import os cap = cv2.VideoCapture(0) recognizer = cv2.face.LBPHFaceRecognizer_create() cascadePath = "haarcascade_frontal


I tried to run the program, but it displays the error result as above, Has anyone experienced this error before? here is my code :

import cv2
import os

cap = cv2.VideoCapture(0)
recognizer = cv2.face.LBPHFaceRecognizer_create()

cascadePath = "haarcascade_frontalface_default.xml"
font = cv2.FONT_HERSHEY_SIMPLEX

Solution

  • I hope this one can help you looks like you forgot to add this command :

    import cv2
    import os
    
    cap = cv2.VideoCapture(0)
    recognizer = cv2.face.LBPHFaceRecognizer_create()
    
    cascadePath = "haarcascade_frontalface_default.xml"
    faceCascade = cv2.CascadeClassifier(cascadePath);
    font = cv2.FONT_HERSHEY_SIMPLEX
    
    path = 'trained/'