Found 24294 Questions for Server Side Programming

How to detect license plates using OpenCV Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:24:33
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 of number plates) and negative images (images without number plates). The classifier is trained from these positive and negative images. It is then used to detect objects (number plates) in other images. We can use already trained haar cascades for object detection. How to Download Haarcascade? You can find different ... Read More

Smile detection using haar cascade in OpenCV using Python

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:21:42
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 smile) and negative images (images without smile). Then the classifier is trained from these positive and negative images. It is then used to detect smiles in other images. We can use already trained haar cascades for smile detection. For smile detection in the input image, we need two haar ... Read More

How to find patterns in a chessboard using OpenCV Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:19:48
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 a chessboard, 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 of a chessboard using cv2.imread() and convert it to grayscale using cv2.cvtColor(). ... Read More

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

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:17:36
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 trained from these positive and negative images. It is then used to detect cat faces in other images. We can use already trained haar cascades for smile detection. For smile detection in the input image we need two haar cascades one for face detection and other for smile detection. We ... Read More

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

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:15:08
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). To crop and save the detected face we save the image[y:y+h, x:x+w]. How to Download Haarcascades? You can find different haarcascades following the GitHub website address − https://github.com/opencv/opencv/tree/master/data/haarcascades To download the haar cascade for human face detection click on the haarcascade_frontalface_alt.xml file. Open it in raw format, right click ... Read More

Implementing k-Nearest Neighbor in OpenCV Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:12:46
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 two classes using a random generator. Next, we generate the Labels for each training data. The label for Red family numbers is 0 and for Blue family members is 1. Now plot the Red and Blue family members. Generate a new number using the random generator and plot it. Initiate ... Read More

How to detect humans in an image in OpenCV Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:10:57
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 a grayscale. Specify the full image path. Initialize a HOG descriptor object hog = cv2.HOGDescriptor() and set the SVM detector as hog.setSVMDetector() as default people detector. Detect humans in the input image using hog.detectMultiScale(). It returns the coordinates of detected humans in (x, y, w, h) format. Loop over all ... Read More

How to detect polygons in image using OpenCV Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:08:22
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 a triangle. See the below pseudocode. for cnt in contours: approx = cv2.approxPolyDP() if len(approx) >= 5: cv2.drawContours() cv2.putText("Polygon") Steps We could use the following steps to detect polygons in an ... Read More

How to detect eyes in an image using OpenCV Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:06:08
A "haar cascade classifier" is an effective machine learning based approach for object detection. To train a haar cascade classifier for eye detection, the algorithm initially needs a lot of positive images (images of eyes) and negative images (images without eyes). Then the classifier is trained from these positive and negative images. It is then used to detect eyes in other images. We can use already trained haar cascades for eye detection. For eye detection in the input image, we need two haar cascades one for face detection and other for eye detection. We will use the following two ... Read More

How to change the contrast and brightness of an image using OpenCV in Python?

Shahid Akhtar Khan
Updated on 05-Dec-2022 11:04:10
In OpenCV, to change the contrast and brightness of an image we could use cv2.convertScaleAbs(). The syntax we use for this method is as follows − cv2.convertScaleAbs(image, alpha, beta) Where image is the original input image. alpha is the contrast value. To lower the contrast, use 0 < alpha < 1. And for higher contrast use alpha > 1. beta is the brightness value. A good range for brightness value is [-127, 127] We could also apply the cv2.addWeighted() function to change the contrast and brightness of an image. We have discussed it in example 2. Steps ... Read More
1 2 3 4 5 6 7 ... 2430 Next
Advertisements