Skip to main content

Posts

Showing posts from April, 2020

Make an object invisible using Python- OpenCV

In this blog, you will learn how to make an object disappear in a video in python using the OpenCV library.  Check out the demo below. So let's get started.  We will start by importing the required libraries  and define a variable to capture the video from my webcam. import cv2 import numpy as np cap = cv2.VideoCapture( 0 ) Now, start capturing the image frames from the camera and save the first frame in a variable called replace_image . But why we did this? Keep Reading. ret , frame = cap.read() frame = cv2.flip(frame , + 1 ) ##Mirror image frame replace_image = frame ##live image to replace with Let's write a while loop to capture the image frames continuously. while ( 1 ): ret , frame = cap.read() ##Read image frame frame = cv2.flip(frame , + 1 ) ##Mirror image frame if not ret: ##If frame is not read then exit break if cv2.waitKey( 1 ) == ord ( 's' ): ##While loo...

Pattern Matching in Python- OpenCV

Hello guys. Today we will learn a pattern matching algorithm in python using the OpenCV library. Check out the video below to get a gist of what we are going to build. I have black and white grid patterns with white as background and black foreground. As usual, we will start by first importing the required libraries and define a variable to capture the video from my webcam. import cv2 import numpy as np cap = cv2.VideoCapture( 0 ) Now, we write a while loop and capture the image frames. Also, we need to mirror the frames so that we can see it right. while 1 : ret , frame = cap.read() ##Read image frame frame = cv2.flip(frame , + 1 ) ##Mirror image frame if not ret: ##If frame is not read then exit break if cv2.waitKey( 1 ) == ord ( 's' ): ##While loop exit condition break In the third part, we have to convert the image frames into a binary image. But why binary images?  You must ask. 1. ...