<jupyter_start><jupyter_text>**IMPORTING NECCESSARY LIBRARIES**<jupyter_code>import numpy as np
import cv2
import time<jupyter_output><empty_output><jupyter_text>**THE MAGIC CODE**<jupyter_code>#reading the webcam 
cap = cv2.VideoCapture(0)
#allowing the system to sleep for 3 seconds before the webcam fires up !
time.sleep(3)
count = 0
background = 0
#Capturing the background in range of 60
for i in range(60):
    ret,background = cap.read()
background = np.flip(background,axis=1)

#when the webcam is opened, we are reading the images from the webcam
while(cap.isOpened()):
    ret, img = cap.read()
    if not ret:
        break
    count+=1
    img = np.flip(img,axis=1)
    
    # Converting the color space from BGR to HSV
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

    # Generating mask to detect red color
    lower_red = np.array([110,50,50])
    upper_red = np.array([120,255,255])
    mask1 = cv2.inRange(hsv,lower_red,upper_red)

    lower_red = np.array([120,50,50])
    upper_red = np.array([130,255,255])
    mask2 = cv2.inRange(hsv,lower_red,upper_red)

    mask1 = mask1+mask2

    # Refining the mask corresponding to the detected red color
    mask1 = cv2.morphologyEx(mask1, cv2.MORPH_OPEN, np.ones((3,3),np.uint8),iterations=2)
    mask1 = cv2.dilate(mask1,np.ones((3,3),np.uint8),iterations = 1)
    mask2 = cv2.bitwise_not(mask1)

    # Generating the final output
    res1 = cv2.bitwise_and(background,background,mask=mask1)
    res2 = cv2.bitwise_and(img,img,mask=mask2)
    final_output = cv2.addWeighted(res1,1,res2,1,0)

    cv2.imshow("<NAME>'s invisibility cloak",final_output)
    k = cv2.waitKey(10)
    if k == 27:
        break<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12058823529411765, 'fraction_numerical': 0.05411764705882353, 'mean_word_length': 4.138972809667674, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '350942', 'license': 'MIT', 'n_tokens_mistral': 687, 'n_tokens_neox': 640, 'n_words': 141, 'path': 'Invisible Cloak/Invisible Cloak.ipynb', 'repo_name': 'saimaansari18/Invisibility-Cloak', 'size': '1706'}