import cv2
face_cascade = cv2.CascadeClassifier('C:/Users/halwa/Downloads/haarcascade_frontalface_default.xml')

cap = cv2.VideoCapture(0)
while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
    for (x, y, w, h) in faces:
       # print(x,y,w,h)
       roi_gray = gray[y:y+h, x:x+w] #(ycord_start, ycord_end)
       roi_color = frame[y:y+h, x:x+w]
       img_item = "my-image.png"
       cv2.imwrite(img_item, roi_gray)
       color = (255, 0, 0) #BGR (0-255)
       stroke = 2  #how thick a line will be.
       end_cord_x = x+w
       end_cord_y= y+h
       cv2.rectangle(frame, (x,y), (end_cord_x,end_cord_y),color , stroke)
       cv2.putText(frame,"Hello World!!!", (x,y), cv2.FONT_HERSHEY_SIMPLEX, 2, 255)
       cv2.imshow('frame',frame)
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break
       
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

5a89f127865a741a320d8e32f83bdd3a86745725
<mask token>

<mask token>
while True:
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5
        )
    for x, y, w, h in faces:
        roi_gray = gray[y:y + h, x:x + w]
        roi_color = frame[y:y + h, x:x + w]
        img_item = 'my-image.png'
        cv2.imwrite(img_item, roi_gray)
        color = 255, 0, 0
        stroke = 2
        end_cord_x = x + w
        end_cord_y = y + h
        cv2.rectangle(frame, (x, y), (end_cord_x, end_cord_y), color, stroke)
        cv2.putText(frame, 'Hello World!!!', (x, y), cv2.
            FONT_HERSHEY_SIMPLEX, 2, 255)
        cv2.imshow('frame', frame)
    if cv2.waitKey(20) & 255 == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

<mask token>
face_cascade = cv2.CascadeClassifier(
    'C:/Users/halwa/Downloads/haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(0)
while True:
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5
        )
    for x, y, w, h in faces:
        roi_gray = gray[y:y + h, x:x + w]
        roi_color = frame[y:y + h, x:x + w]
        img_item = 'my-image.png'
        cv2.imwrite(img_item, roi_gray)
        color = 255, 0, 0
        stroke = 2
        end_cord_x = x + w
        end_cord_y = y + h
        cv2.rectangle(frame, (x, y), (end_cord_x, end_cord_y), color, stroke)
        cv2.putText(frame, 'Hello World!!!', (x, y), cv2.
            FONT_HERSHEY_SIMPLEX, 2, 255)
        cv2.imshow('frame', frame)
    if cv2.waitKey(20) & 255 == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

import cv2
face_cascade = cv2.CascadeClassifier(
    'C:/Users/halwa/Downloads/haarcascade_frontalface_default.xml')
cap = cv2.VideoCapture(0)
while True:
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5
        )
    for x, y, w, h in faces:
        roi_gray = gray[y:y + h, x:x + w]
        roi_color = frame[y:y + h, x:x + w]
        img_item = 'my-image.png'
        cv2.imwrite(img_item, roi_gray)
        color = 255, 0, 0
        stroke = 2
        end_cord_x = x + w
        end_cord_y = y + h
        cv2.rectangle(frame, (x, y), (end_cord_x, end_cord_y), color, stroke)
        cv2.putText(frame, 'Hello World!!!', (x, y), cv2.
            FONT_HERSHEY_SIMPLEX, 2, 255)
        cv2.imshow('frame', frame)
    if cv2.waitKey(20) & 255 == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

import cv2
face_cascade = cv2.CascadeClassifier('C:/Users/halwa/Downloads/haarcascade_frontalface_default.xml')

cap = cv2.VideoCapture(0)
while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
    for (x, y, w, h) in faces:
       # print(x,y,w,h)
       roi_gray = gray[y:y+h, x:x+w] #(ycord_start, ycord_end)
       roi_color = frame[y:y+h, x:x+w]
       img_item = "my-image.png"
       cv2.imwrite(img_item, roi_gray)
       color = (255, 0, 0) #BGR (0-255)
       stroke = 2  #how thick a line will be.
       end_cord_x = x+w
       end_cord_y= y+h
       cv2.rectangle(frame, (x,y), (end_cord_x,end_cord_y),color , stroke)
       cv2.putText(frame,"Hello World!!!", (x,y), cv2.FONT_HERSHEY_SIMPLEX, 2, 255)
       cv2.imshow('frame',frame)
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break
       
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
