Search code examples
python-3.xnumpyface-detectionopencvpython

i am doing the face_detection program but the output is not apearing by showing the some warning


import cv2
import numpy as np
# https://github.com/Itseez/opencv/tree/master/data/haarcascade
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

videocapture = cv2.VideoCapture(0)
scale_factor = 1.3

while 1:
    ret, pic = videocapture.read()

    faces = face_cascade.detectMultiScale(pic, scale_factor, 5)
    for(x, y, w, h) in faces:
        cv2.rectangle(pic, (x, y), (x + w, y + h), (255, 0, 0), 2)
        font = cv2.FONT_HERSHEY_SIMPLEX
        cv2.putText(pic, 'Me', (x, y), font, 2, (255, 255, 255), 2, cv2.LINE_AA)

        print("Number of faces found {} " .format(len(faces)))
        cv2.imshow('faces', pic)
        k = cv2.waitKey(30) & 0xff
        if k == 2:
            break
            cv2.destroyAllWindows()

[ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-2y91i_7w\opencv\modules\videoio\src\cap_msmf.cpp (435) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback


Solution

  • I have got the answer for this warning because I have not permitted my camera to start so after permitting my camera it has run successfully