<jupyter_start><jupyter_text>Import Libraries<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import cv2
#%matplotlib notebook
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Create Classifiers<jupyter_code>faceClassifier = cv2.CascadeClassifier('Haarcascades/haarcascade_frontalface_default.xml')
eyeClassifier = cv2.CascadeClassifier('Haarcascades/haarcascade_eye.xml')<jupyter_output><empty_output><jupyter_text>Open Image<jupyter_code>image = cv2.imread('Images/eye_face.jpg')<jupyter_output><empty_output><jupyter_text>Fix Image<jupyter_code>fixImage = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)<jupyter_output><empty_output><jupyter_text>Face Classifier<jupyter_code>faces = faceClassifier.detectMultiScale(fixImage, 1.3, 5)<jupyter_output><empty_output><jupyter_text>If No Face Detected<jupyter_code>if faces is ():
    print('No Faces found')<jupyter_output><empty_output><jupyter_text>It's a Kind of Magic<jupyter_code>def DetectFaceEyes(fixImg):
    faceRects = faceClassifier.detectMultiScale(fixImg)
    
    for (x, y, w, h) in faceRects:
        cv2.rectangle(fixImg,
                     (x, y),
                     (x + w, y + h),
                     (255, 0, 0),
                     10)
        
        eyeRects = eyeClassifier.detectMultiScale(fixImg)
    
        for (x, y, w, h) in eyeRects:
            cv2.rectangle(fixImg,
                         (x, y),
                         (x + w, y + h),
                         (0, 255, 0),
                         10)
        
    return fixImg

result = DetectFaceEyes(fixImage)

plt.imshow(result)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10681399631675875, 'fraction_numerical': 0.01596071209330878, 'mean_word_length': 3.2447916666666665, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '553876', 'license': 'MIT', 'n_tokens_mistral': 599, 'n_tokens_neox': 570, 'n_words': 86, 'path': '03_Face_and_Eyes_Detection.ipynb', 'repo_name': 'Hevenicio/Computer-Vision-Object-Detection-with-OpenCV-and-Python', 'size': '1629'}