Skip to main content

Posts

Showing posts with the label haar cascade

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

How Far You Are From Your Camera? Python | OpenCv

Hello Friends! In this blog, you will learn to find out the distance between you and your webcam. Take a look at the video below.  Let's get started. For this project, we will be using face detection using the Haar Cascade method. Therefore, we need to download the cascade classifier for face detection from Github. You can download and paste the file from this link . Let us first understand what is Haar Cascade?  Haar Cascade  is a machine learning object detection algorithm used to identify objects in an image or video and based on various​​ features.  If you want to read a more detailed version of it, check out this link . Now, we will start by importing the libraries and define a variable to capture video from my webcam. import cv2 import numpy as np cap = cv2.VideoCapture( 0 ) Let us import our classifier file which we downloaded from Github. face = cv2.CascadeClassifier( 'haarcascade_frontalface_alt.xml' ) write a while loop and capture the image frames. Also, w...