diff --git a/Scripts/Miscellaneous/Invisible_Cloak/README.md b/Scripts/Miscellaneous/Invisible_Cloak/README.md new file mode 100644 index 000000000..80a01243d --- /dev/null +++ b/Scripts/Miscellaneous/Invisible_Cloak/README.md @@ -0,0 +1,15 @@ +# INVISBLE CLOAK +This is a project inspired by the invisible cloak of Harry Potter. + +### Prerequisites +- OpenCV +- numpy + +### How to run the script +```sh +$ python main.py +``` + +## *Author Name* + +[Sudip Mondal](https://github.com/sudip-mondal-2002) diff --git a/Scripts/Miscellaneous/Invisible_Cloak/main.py b/Scripts/Miscellaneous/Invisible_Cloak/main.py new file mode 100644 index 000000000..1e068df38 --- /dev/null +++ b/Scripts/Miscellaneous/Invisible_Cloak/main.py @@ -0,0 +1,43 @@ +import numpy as np +import cv2 +import time + +cap=cv2.VideoCapture(0) +fourcc = cv2.VideoWriter_fourcc(*'XVID') +out = cv2.VideoWriter('sudip.avi', fourcc, 30.0, (640, 480)) +time.sleep(2) +background=0 +for i in range(30): + ret, background = cap.read(); +while(cap.isOpened()): + ret, img = cap.read() + if not ret: + break + hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV); + lower_red=np.array([0,130,75]) + upper_red=np.array([15,255,255]) + mask1=cv2.inRange(hsv, lower_red,upper_red) + + lower_red=np.array([165,130,75]) + upper_red=np.array([180,255,255]) + mask2=cv2.inRange(hsv, lower_red,upper_red) + + mask1=mask1+mask2 + mask1=cv2.morphologyEx(mask1,cv2.MORPH_OPEN, + np.ones((3,3),np.uint8),iterations=3) + mask1=cv2.morphologyEx(mask1,cv2.MORPH_DILATE, + np.ones((3,3),np.uint8),iterations=3) + + mask2=cv2.bitwise_not(mask1) + 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) + out.write(final_output) + cv2.imshow("App",final_output) + k=cv2.waitKey(10) + if k==27: + break +cap.release() +cv2.destroyAllWindows() + + \ No newline at end of file diff --git a/Scripts/Miscellaneous/Invisible_Cloak/output.avi b/Scripts/Miscellaneous/Invisible_Cloak/output.avi new file mode 100644 index 000000000..9d76854d4 Binary files /dev/null and b/Scripts/Miscellaneous/Invisible_Cloak/output.avi differ diff --git a/Scripts/Miscellaneous/Invisible_Cloak/requirements.txt b/Scripts/Miscellaneous/Invisible_Cloak/requirements.txt new file mode 100644 index 000000000..b96544bd0 --- /dev/null +++ b/Scripts/Miscellaneous/Invisible_Cloak/requirements.txt @@ -0,0 +1,2 @@ +opencv-python +numpy