Skip to main content

Posts

Showing posts with the label image segmentation

Iris Detection | Python | OpenCv

 Hello there! Welcome to another blog. In this blog you are going to learn to detect iris using OpenCv python. Here is the video in case you missed it. So, let's get started. We will start by importing the necessary libraries. import cv2 import numpy as np Now, let us import the face and eye classifier files and set the camera resolution as follows. eye = cv2.CascadeClassifier( 'haarcascade_eye.xml' ) face = cv2.CascadeClassifier( 'haarcascade_frontalface_alt.xml' ) Kernal = np.ones(( 3 , 3 ) , np.uint8) #Declare kernal for morphology cap = cv2.VideoCapture( 0 ) cap.set(cv2.CAP_PROP_FRAME_WIDTH , 320 ) ##Set camera resolution cap.set(cv2.CAP_PROP_FRAME_HEIGHT , 240 ) In a while loop let us capture an image frame, flip it(in case your camera captures inverted images) and convert it into a gray scale image. ret , frame = cap.read() ##Read image frame frame = cv2.flip(frame , + 1 ) ##Flip the image in case your camera...

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...