

{"id":96307,"date":"2021-06-01T13:44:02","date_gmt":"2021-06-01T08:14:02","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=96307"},"modified":"2026-06-01T11:55:29","modified_gmt":"2026-06-01T06:25:29","slug":"invisible-cloak-opencv-python","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/","title":{"rendered":"Harry Potter&#8217;s Invisible Cloak using OpenCV &#8211; Python Project"},"content":{"rendered":"<p>Are you fascinated with Harry Potter&#8217;s Invisible Cloak?<\/p>\n<p>Do you want to wear that cloak?<\/p>\n<p>If Yes!! then in this python project, we will develop invisible cloak using OpenCV using which you will become invisible.<\/p>\n<h3>About Invisible Cloak Project<\/h3>\n<p>We will create the invisible cloak using an image processing technique called Color detection and segmentation. In order to make this project, you\u2019ll need a single-color cloth. The cloth should not contain any other color visible. Here we are using a green cloth to develop this python project.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96346\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak.gif\" alt=\"invisible cloak\" width=\"800\" height=\"450\" \/><\/a><\/p>\n<p><strong>Why single-color cloth?<\/strong><\/p>\n<p>Because we are using color detection and segmentation techniques. If any other color is visible in our cloak then we have to process the image frame for that color also.<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li>Cloth color should be unique relative to the background. (i.e. If the cloth is green then the background shouldn&#8217;t contain any green color)<\/li>\n<li>In good lighting conditions, it works best.<\/li>\n<li>Try to choose red, green or blue cloth, because these three colors are easier to detect.<\/li>\n<\/ul>\n<h3>Color Detection &amp; Segmentation<\/h3>\n<p>So what is Color Detection and Segmentation in Image Processing?<\/p>\n<p>Color detection is a technique where we can detect any color in a given range of HSV color space.<\/p>\n<p>Image segmentation is the process of labeling every pixel in an image, where each pixel having the same label shares certain characteristics.<\/p>\n<h3>Project Prerequisites:<\/h3>\n<ul>\n<li>Python &#8211; 3.x (we used Python 3.7.10 in this project)<\/li>\n<li>Numpy &#8211; 1.19.2<\/li>\n<li>OpenCV &#8211; 4.5<\/li>\n<\/ul>\n<p>To install opencv, run the below command. Numpy will be automatically installed.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\u201cpip install opencv-python\u201d<\/pre>\n<h3>Download Invisible Cloak Python Code<\/h3>\n<p>Please download the source code of python invisible cloak project: <a href=\"https:\/\/drive.google.com\/file\/d\/15z0UcCSsxkzoTwHZKUKla2bUoqnE_kVx\/view?usp=drive_link\"><strong>Invisible Cloak Project Code<\/strong><\/a><\/p>\n<h3>Steps to Build Invisible Cloak OpenCV Project:<\/h3>\n<p>Now we have everything ready. Below are the steps to create invisible cloak:<\/p>\n<ol>\n<li>Import necessary packages and Initialize the camera.<\/li>\n<li>Store a single frame before starting the infinite loop.<\/li>\n<li>Detect the color of the cloth and create a mask.<\/li>\n<li>Apply the mask on frames.<\/li>\n<li>Combine masked frames together.<\/li>\n<li>Removing unnecessary noise from masks.<\/li>\n<\/ol>\n<h4>Step 1 &#8211; Import necessary packages and Initialize the camera:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># DataFlair Invisible Cloak project using OpenCV.\r\nimport cv2\r\nimport time\r\nimport numpy as np\r\ncap = cv2.VideoCapture(0)\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<ul>\n<li>Using import, we imported the required libraries<\/li>\n<li>To access the camera, we use the method cv2.VideoCapture(0) and set the capture object as cap.<\/li>\n<\/ul>\n<h4>Step 2 &#8211; Store a single frame before starting the infinite loop:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">_, background = cap.read()\r\ntime.sleep(2)\r\n_, background = cap.read()\r\n\r\nwhile cap.isOpen():\r\n    _, frame - cap.read()\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<ul>\n<li>cap.read() function captures frames from webcam<\/li>\n<li>2-second delay between two captures are for adjusting camera auto exposure<\/li>\n<li>cap.isOpen() function checks if the camera is open or not and returns true if the camera is open and false if the camera is not open.<\/li>\n<li>While capturing the background make sure that you or your clothes don&#8217;t accidentally come into the frame.<\/li>\n<\/ul>\n<h4>Step 3 &#8211; Detect the cloth:<\/h4>\n<p>In this invisible cloak opencv project, we are using green cloth so we have to detect green color. So how can we do this?<\/p>\n<p>OpenCV reads the frame as BGR colorspace. To detect any color first we have to convert the frame to HSV colorspace.<\/p>\n<p><strong>Why HSV?<\/strong><\/p>\n<p>HSV stands for HUE, SATURATION, and VALUE (or brightness). It is a cylindrical color space.<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>HUE:<\/strong>\u00a0The hues are modeled as an angular dimension which encodes color information.<\/li>\n<li><strong>SATURATION: <\/strong>Saturation encodes intensity of color.<\/li>\n<li><strong>VALUE:<\/strong> Value represents the brightness of the color.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\r\nlower_bound = np.array([50, 80, 50])     \r\nupper_bound = np.array([90, 255, 255])\r\nmask = cv2.inRange(hsv, lower_bound, upper_bound)<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<ul>\n<li>cv2.cvtColor() function converts colorspace.<\/li>\n<li>Lower bound and Upper bound are the boundaries of green color.<\/li>\n<li>cv2.inRange() function returns a segmented binary mask of the frame where the green color is present.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96336\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask.png\" alt=\"opencv frame mask\" width=\"1920\" height=\"1052\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-300x164.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-1024x561.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-150x82.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-768x421.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-1536x842.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-720x395.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-520x285.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/frame-mask-320x175.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>Here we can see in the frame wherever the green color is detected the mask shows that as white. The rest of the region is black.<\/p>\n<h4>Step 4 &#8211; Apply the mask:<\/h4>\n<p>We have successfully detected the cloak. We want to show our previously-stored background in the main frame where the cloak is present. First, we need to take the only white region from the background.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># Apply the mask to take only those region from the saved background \r\n# where our cloak is present in the current frame\r\ncloak = cv2.bitwise_and(background, background, mask=mask)<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<p>cv2.bitwise_and() applies mask on frame in the region where mask is true (means white).<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96337\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak.png\" alt=\"replace cloak\" width=\"1920\" height=\"1060\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-300x166.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-1024x565.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-150x83.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-768x424.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-1536x848.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-720x398.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-520x287.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/replace-cloak-320x177.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>We have successfully replaced the cloak region with the background. Now we need those regions of our main frame where the clock is not present. To get this we can simply invert the mask and do the same procedure for the main frame.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># create inverse mask \r\ninverse_mask = cv2.bitwise_not(mask)  \r\n\r\n# Apply the inverse mask to take those region of the current frame where cloak is # not present \r\ncurrent_background = cv2.bitwise_and(frame, frame, mask=inverse_mask)<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<p>cv2.bitwise_not() inverse the mask pixel value. Where the mask is white it returns black and where is black it returns white.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96338\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask.png\" alt=\"inverse mask\" width=\"1920\" height=\"1052\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-300x164.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-1024x561.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-150x82.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-768x421.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-1536x842.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-720x395.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-520x285.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/inverse-mask-320x175.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>Here we have the inverse mask at the left and the corresponding region from the current frame at the right.<\/p>\n<h4>Step 5 &#8211; Combine masked frames together:<\/h4>\n<p>Finally, we have a cloak background and current frame background. Now it\u2019s time to combine those to get a whole frame.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">combined = cv2.add(cloak, current_background)\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<p>cv2.add() adds two frames and returns a single frame.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96339\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame.png\" alt=\"combined frame\" width=\"1920\" height=\"1056\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-300x165.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-1024x563.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-150x83.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-768x422.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-1536x845.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-720x396.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-520x286.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/combined-frame-320x176.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>Yeah, finally we are reaching our goal. But can you see the green edges of the cloak? We have to remove those edges to get the perfect finishing.<\/p>\n<p><em>So what can we do here? <\/em><\/p>\n<p>We\u2019re gonna use some filtering methods provided by OpenCV. OpenCV provides <a href=\"https:\/\/docs.opencv.org\/master\/d9\/d61\/tutorial_py_morphological_ops.html\">morphological operation<\/a> libraries.<\/p>\n<h4>Step 6 &#8211; Removing unnecessary noise from mask :<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">open_kernel = np.ones((5,5),np.uint8)\r\nclose_kernel = np.ones((7,7),np.uint8)\r\ndilation_kernel = np.ones((10, 10), np.uint8)\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<ul>\n<li>np.ones((5,5),np.uint8) create a 5&#215;5 8 bit integer matrix.<\/li>\n<li>Adjust kernel size according to your condition.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def filter_mask(mask):\r\n\r\n    close_mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, close_kernel)\r\n    open_mask = cv2.morphologyEx(close_mask, cv2.MORPH_OPEN, open_kernel)\r\n    dilation = cv2.dilate(open_mask, dialation_kernel, iterations= 1)\r\n    return dilation\r\n<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<ul>\n<li>cv2.MORPH_CLOSE removes unnecessary black noise from the white region in the mask. And how much noise to remove that is defined by kernel size.<\/li>\n<li>cv2.MORPH_OPEN removes unnecessary white noise from the black region.<\/li>\n<li>cv2.dilate increases white region in the image.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96341\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame.png\" alt=\"filtered frame\" width=\"1920\" height=\"1056\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame.png 1920w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-300x165.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-1024x563.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-150x83.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-768x422.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-1536x845.png 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-720x396.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-520x286.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/filtered-frame-320x176.png 320w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<h3>OpenCV Invisible Cloak Output<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-output.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-96347\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-output.gif\" alt=\"invisible cloak output\" width=\"800\" height=\"450\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>Imagine wearing a cloak and disappearing like in Harry Potter! This fun project uses OpenCV in Python to make a real-time invisibility effect. When someone wears a cloak of a certain color (like red or green), the program removes that color and shows the background instead. It looks like the person has vanished.<\/p>\n<p>In this machine learning project, we have created Invisible Cloak using OpenCV. We implemented color detection and segmentation technique. In this opencv project, we learned about morphological operations, masking, and other image processing concepts.<\/p>\n<p>This project is very popular and exciting for beginners. It teaches real-time video processing, color detection, and OpenCV operations. It also shows how creative you can get with computer vision. It\u2019s perfect for making fun YouTube or Instagram videos and learning OpenCV basics.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2500,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/15z0UcCSsxkzoTwHZKUKla2bUoqnE_kVx\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601062717\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/15z0UcCSsxkzoTwHZKUKla2bUoqnE_kVx\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-01 06:56:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 07:28:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-08 17:39:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-14 18:14:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-21 02:24:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-24 12:03:06&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-24 12:03:06&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:365,&quot;href&quot;:&quot;https:\\\/\\\/docs.opencv.org\\\/master\\\/d9\\\/d61\\\/tutorial_py_morphological_ops.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20211020080443\\\/https:\\\/\\\/docs.opencv.org\\\/master\\\/d9\\\/d61\\\/tutorial_py_morphological_ops.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-08 09:15:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-12 05:12:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-15 09:30:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-20 14:37:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-23 15:33:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-30 23:38:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-10 16:59:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-17 09:16:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-20 11:58:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-23 20:11:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-27 03:55:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-02 07:01:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 18:15:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 09:44:59&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-26 15:02:37&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-04 14:24:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-08 14:12:43&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-12 13:36:14&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-15 16:54:56&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-23 21:26:30&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-28 05:06:29&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-03 14:21:47&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 05:50:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 16:27:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-17 01:04:28&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 15:47:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-26 00:30:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-04 03:05:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-09 09:11:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-17 15:26:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-24 15:36:14&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-02 13:48:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 16:47:21&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-09 01:45:55&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-14 18:15:19&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-21 02:24:24&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-24 12:03:23&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-24 12:03:23&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you fascinated with Harry Potter&#8217;s Invisible Cloak? Do you want to wear that cloak? If Yes!! then in this python project, we will develop invisible cloak using OpenCV using which you will become&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":96344,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[24434,24433,24435,20697,23025,21082],"class_list":["post-96307","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","tag-invisible-cloak-opencv","tag-invisible-cloak-project","tag-invisible-cloak-python","tag-machine-learning-project","tag-opencv-project","tag-python-project"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Harry Potter&#039;s Invisible Cloak using OpenCV - Python Project - DataFlair<\/title>\n<meta name=\"description\" content=\"Create invisible cloak using python &amp; opencv. In this machine learning project we use color detection and segmentation technique\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Harry Potter&#039;s Invisible Cloak using OpenCV - Python Project - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Create invisible cloak using python &amp; opencv. In this machine learning project we use color detection and segmentation technique\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-01T08:14:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T06:25:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-python-opencv.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Harry Potter's Invisible Cloak using OpenCV - Python Project - DataFlair","description":"Create invisible cloak using python & opencv. In this machine learning project we use color detection and segmentation technique","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/","og_locale":"en_US","og_type":"article","og_title":"Harry Potter's Invisible Cloak using OpenCV - Python Project - DataFlair","og_description":"Create invisible cloak using python & opencv. In this machine learning project we use color detection and segmentation technique","og_url":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-06-01T08:14:02+00:00","article_modified_time":"2026-06-01T06:25:29+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-python-opencv.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"Harry Potter&#8217;s Invisible Cloak using OpenCV &#8211; Python Project","datePublished":"2021-06-01T08:14:02+00:00","dateModified":"2026-06-01T06:25:29+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/"},"wordCount":1044,"commentCount":3,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-python-opencv.jpg","keywords":["invisible cloak opencv","invisible cloak project","invisible cloak python","machine learning project","opencv project","Python project"],"articleSection":["Machine Learning Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/","url":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/","name":"Harry Potter's Invisible Cloak using OpenCV - Python Project - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-python-opencv.jpg","datePublished":"2021-06-01T08:14:02+00:00","dateModified":"2026-06-01T06:25:29+00:00","description":"Create invisible cloak using python & opencv. In this machine learning project we use color detection and segmentation technique","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-python-opencv.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/06\/invisible-cloak-python-opencv.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/invisible-cloak-opencv-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Machine Learning Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/machine-learning\/"},{"@type":"ListItem","position":3,"name":"Harry Potter&#8217;s Invisible Cloak using OpenCV &#8211; Python Project"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/96307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=96307"}],"version-history":[{"count":11,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/96307\/revisions"}],"predecessor-version":[{"id":148568,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/96307\/revisions\/148568"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/96344"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=96307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=96307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=96307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}