import cv2
import os

def register():
    cam=cv2.VideoCapture(0)
    detector=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

    num=input('enter our ID : ')
    sampleNum=0

    while True:
        pwd=os.getcwd()
        ret,im=cam.read()

        if not ret:
            print(ret)
            break

        imgray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
        cv2.imshow('FACE',im)
        faces=detector.detectMultiScale(imgray,1.3,5)

        for (x,y,w,h) in faces:
            print(str(sampleNum) + ' / 300')
            
            sampleNum+=1
            cv2.rectangle(im,(x,y),(x+w,y+h),(255,0,0),2)
            patch=imgray[y:y+h,x:x+w]
            os.chdir(pwd+'/dataset')
            cv2.imwrite('user.' +num+'.' +str(sampleNum)+ '.jpg',patch)
            os.chdir(pwd)
            cv2.imshow('FACES',im)
            
        if cv2.waitKey(100)&0xFF==ord('q') or sampleNum>=300:
            break
    cam.release()
    cv2.destroyAllWindows()
520955fc6e87cb3766413a36cb4a3f64e8743530
<mask token>

<mask token>


def register():
    cam = cv2.VideoCapture(0)
    detector = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    num = input('enter our ID : ')
    sampleNum = 0
    while True:
        pwd = os.getcwd()
        ret, im = cam.read()
        if not ret:
            print(ret)
            break
        imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
        cv2.imshow('FACE', im)
        faces = detector.detectMultiScale(imgray, 1.3, 5)
        for x, y, w, h in faces:
            print(str(sampleNum) + ' / 300')
            sampleNum += 1
            cv2.rectangle(im, (x, y), (x + w, y + h), (255, 0, 0), 2)
            patch = imgray[y:y + h, x:x + w]
            os.chdir(pwd + '/dataset')
            cv2.imwrite('user.' + num + '.' + str(sampleNum) + '.jpg', patch)
            os.chdir(pwd)
            cv2.imshow('FACES', im)
        if cv2.waitKey(100) & 255 == ord('q') or sampleNum >= 300:
            break
    cam.release()
    cv2.destroyAllWindows()

import cv2
import os


def register():
    cam = cv2.VideoCapture(0)
    detector = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
    num = input('enter our ID : ')
    sampleNum = 0
    while True:
        pwd = os.getcwd()
        ret, im = cam.read()
        if not ret:
            print(ret)
            break
        imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
        cv2.imshow('FACE', im)
        faces = detector.detectMultiScale(imgray, 1.3, 5)
        for x, y, w, h in faces:
            print(str(sampleNum) + ' / 300')
            sampleNum += 1
            cv2.rectangle(im, (x, y), (x + w, y + h), (255, 0, 0), 2)
            patch = imgray[y:y + h, x:x + w]
            os.chdir(pwd + '/dataset')
            cv2.imwrite('user.' + num + '.' + str(sampleNum) + '.jpg', patch)
            os.chdir(pwd)
            cv2.imshow('FACES', im)
        if cv2.waitKey(100) & 255 == ord('q') or sampleNum >= 300:
            break
    cam.release()
    cv2.destroyAllWindows()

import cv2
import os

def register():
    cam=cv2.VideoCapture(0)
    detector=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

    num=input('enter our ID : ')
    sampleNum=0

    while True:
        pwd=os.getcwd()
        ret,im=cam.read()

        if not ret:
            print(ret)
            break

        imgray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
        cv2.imshow('FACE',im)
        faces=detector.detectMultiScale(imgray,1.3,5)

        for (x,y,w,h) in faces:
            print(str(sampleNum) + ' / 300')
            
            sampleNum+=1
            cv2.rectangle(im,(x,y),(x+w,y+h),(255,0,0),2)
            patch=imgray[y:y+h,x:x+w]
            os.chdir(pwd+'/dataset')
            cv2.imwrite('user.' +num+'.' +str(sampleNum)+ '.jpg',patch)
            os.chdir(pwd)
            cv2.imshow('FACES',im)
            
        if cv2.waitKey(100)&0xFF==ord('q') or sampleNum>=300:
            break
    cam.release()
    cv2.destroyAllWindows()