Giter Site home page Giter Site logo

Comments (2)

iamdsc avatar iamdsc commented on August 31, 2024 1

I think what your code is lacking is a delay time which is required for detecting large number of faces in a frame before we read another frame from video stream, for few faces it should work normally. Try the code attached and let me know if you still face this issue.

import cv2
import time

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(0)
while True:
    ret, img = cap.read()
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray,1.3,5)
    i=0
    for (x,y,w,h) in faces:
        cv2.rectangle(img, (x,y), (x+w, y+h), (255,0,0), 2)
        roi_color = img[y:y+h, x:x+w]
        face_file_name='faces/face_'+str(i)+'.jpg'
        cv2.imwrite(face_file_name, roi_color)
        i+=1
    cv2.imshow('image', img)
    time.sleep(1)
    k = cv2.waitKey(30) & 0xff
    if k==27:
        break
print(str(i)+' faces read')
cap.release()
cv2.destroyAllWindows()

from automated_attendance_system.

NimishMishra avatar NimishMishra commented on August 31, 2024

Yes it worked. Thanks.

from automated_attendance_system.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.