Shahid Akhtar Khan has Published 216 Articles

How to mask an image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 25-Aug-2023 01:20:28

38K+ Views

We can apply a mask to an image by computing the cv2.bitwise_and() between the mask and the image. To track a color, we define a mask in HSV color space using cv2.inRange() passing lower and upper limits of color values in HSV.Also Read: Color Identification in Images using Python and OpenCV ... Read More

How to compare two images in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 23-Aug-2023 14:06:47

60K+ Views

To compare two images, we use the Mean Square Error (MSE) of the pixel values of the two images. Similar images will have less mean square error value. Using this method, we can compare two images having the same height, width and number of channels. Steps You can use the ... Read More

How to detect license plates using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:24:33

12K+ Views

We will use the Haar cascade classifier to detect the license number plate in the image. A haar cascade classifier is an effective object detection method. It is a machine learning based approach. To train a number plate classifier, the algorithm initially needs a lot of positive images (images ... Read More

Smile detection using haar cascade in OpenCV using Python

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:21:42

2K+ Views

We will use the Haar cascade classifier for smile detection in an image. A haar cascade classifier is an effective object detection method. It is a machine learning based approach. To train a haar cascade classifier for smile detection, the algorithm initially needs a lot of positive images (images with ... Read More

How to find patterns in a chessboard using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:19:48

6K+ Views

We could find chessboard corners in an image using cv2.findChessboardCorners() and to draw the chessboard corners with a pattern, we could use cv2.drawChessboardCorners(). Look at the below syntaxes for these two methods − ret, corners = cv2.findChessboardCorners(img, patterSize, None) cv2.drawChessboardCorners(img, patternSize, corners, ret) Steps To find the patterns in ... Read More

How to detect cat faces in an image in OpenCV using Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:17:36

1K+ Views

A haar cascade classifier is an effective object detection method. It is a machine learning based approach. To train a haar cascade classifier for cat face detection, the algorithm initially needs a lot of positive images (images with cat faces) and negative images (images without cat faces). The classifier is ... Read More

How to crop and save the detected faces in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:15:08

5K+ Views

We can use the already trained haar cascade classifier to detect the faces in the image. To detect faces OpenCV provides us with different haar cascades as xml files. We will use haarcascade_frontalface_alt.xml for human face detection in the image. The detected face coordinates are in (x, y, w, h). ... Read More

Implementing k-Nearest Neighbor in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:12:46

731 Views

k-Nearest Neighbor (kNN) is a simple classification algorithm for supervised learning. To implement kNN in OpenCV, you can follow the steps given below − Import the required libraries OpenCV, NumPy and Matplotlib. We define two classes Red and Blue each having 25 numbers. Then generate training data for these ... Read More

How to detect humans in an image in OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:10:57

11K+ Views

To detect humans in an image and draw bounding boxes around them, you can use the steps given below − Import the required library. In all the following examples, the required Python library is OpenCV. Make sure you have already installed it. Read the input image using cv2.imread() in ... Read More

How to detect polygons in image using OpenCV Python?

Shahid Akhtar Khan

Shahid Akhtar Khan

Updated on 05-Dec-2022 11:08:22

4K+ Views

We first detect all the object contours in the image to detect a polygon. Then Loop over all contours. Find the approximate contour for each of the contours. If the number of vertex points in the approximate contour is 5 or more then draw the contour and set it as ... Read More

Advertisements