Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 542 of 3366
5K+ Views
In almost any modern programming languages, we find the few logarithm functions like natural logs, log with base 2, log with base 10 etc. But sometimes we need to calculate logarithm with different base which are not available in the given library functions. To achieve this goal we can use simple logarithmic formula. In this article we will see how to calculate logarithm values with a given number and a given base in C++. Formula to calculate logarithm with given base Let we have taken a number x, and its base is k which is also given. The ... Read More
786 Views
Logarithms for base 10 are relatively required for natural computations in a variety of applications. For competitive examinations, there are a few quick ways to memorise a few log values. There are a few ways to compute logarithm results using library functions when programming, as well as a few shortcuts. In this post, we'll go through a couple methods for computing the base-10 logarithm of a given number in C++. Using log10() function One library function used to determine the base-10 logarithm for a given parameter is called log10(). An integer or a floating-point number could be the ... Read More
15K+ 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 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
3K+ 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 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
9K+ 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 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
2K+ 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 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
6K+ 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). 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
1K+ 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 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
15K+ 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 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
6K+ 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 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