<jupyter_start><jupyter_text>Face Detection  For pictures<jupyter_code># importing lib
import cv2
import matplotlib.pyplot as plt 
# reading image
img = cv2.imread("image.jpg")
# ploting image by default it is bgr so it is inversing color 
plt.imshow(img)
# converting bgr to rbg
img_rgb = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
# ploting rgb image
plt.imshow(img_rgb)
# loading classifier for face detection
obj = cv2.CascadeClassifier(r"C:\Users\Aditya\AppData\Local\Programs\Python\Python39\Lib\site-packages\cv2\data//haarcascade_frontalface_default.xml")
# detecting face
face = obj.detectMultiScale(img)
# fetching face co-ordinates
x,y,w,h = face[0]
# slicing face from image
face = img_rgb[y:y+h,x:x+w]
# ploting image
plt.imshow(face)
# highlighting face area by putting rectangle
cv2.rectangle(img_rgb, (x,y), (x+w,y+h), (255,0,0),3)
plt.imshow(img_rgb)<jupyter_output><empty_output><jupyter_text>For realtime Video capturing<jupyter_code># importing lib
import cv2

# opening vdo stream
vdo = cv2.VideoCapture(0)
# initializing classifier
obj = cv2.CascadeClassifier(r"C:\Users\Aditya\AppData\Local\Programs\Python\Python39\Lib\site-packages\cv2\data//haarcascade_frontalface_default.xml")    

while True:
    # reading each frame of vdo as frames from vdo stream     
    flag,frames = vdo.read()
    
    # detecting each frame    
    face = obj.detectMultiScale(frames)    
    
    # from every detectable face      
    for f in face:
        x,y,w,h = f
        # putting rectangle         
        cv2.rectangle(frames, (x,y), (x+w,y+h), (255,0,0),3)
    
#     
    cv2.imshow("vdo",frames)

    key = cv2.waitKey(1)
    if key==ord("q"):
        break<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11500862564692352, 'fraction_numerical': 0.019551466359977, 'mean_word_length': 3.627659574468085, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '492755', 'license': 'MIT', 'n_tokens_mistral': 684, 'n_tokens_neox': 642, 'n_words': 132, 'path': 'KNN-CLASSIFICATION/FACE_DETECTION/main.ipynb', 'repo_name': 'aditya-2703/MACHINE_LEARNING', 'size': '1739'}