Found 26504 Articles for Server Side Programming

How to track the eye in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 09:13:36

1K+ Views

Here, we will learn how to track the eye in OpenCV. After detective the eyes, the tracking is an effortless and straightforward task. We used the circle to enclose the detected eyes. Tracking the center of the circle means tracking the center of eyes. To track the center of the circle, we need two integer variables. This has been done on the first two lines (9th and 10th line) inside the main() function. The name of the integer variables is 'x_axis' and 'y_axis'.In line 42 and 43, the horizontal and vertical coordinate values of the center have been copied to ... Read More

How to detect the eye in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 09:12:36

1K+ Views

Here, we will learn how to detect the eye in OpenCV. We will use haarcascade_eye.xml classifier located in 'C:/opencv/sources/data/haarcascades' to detect the eyes. To detect the eyes, we need to add these headers.The first header is , and it is the header of C++ programming language. Reading writing images and user interface functionalities are defined in 'highgui' header. We need to add 'imgproc' header to enhance image quality, and we also use 'objdetect' header to detect face and eyes.The following program to demonstrate how to detect and track eye in OpenCV.Example#include #include #include #include using namespace cv; using namespace std; ... Read More

How to track the face in real-time in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 09:08:19

355 Views

We will learn how to track the face in real-time in OpenCV. This program is same to the previous program and difference is that we used ellipse instead of rectangle to identify the face and we also used additional 'cout' statement to show the co-ordinate of the face in the console window.The following program to detect human face in real-time −Example#include #include #include //This header includes definition of 'rectangle()' function// #include //This header includes the definition of Cascade Classifier// #include using namespace std; using namespace cv; int main(int argc, char** argv) {    Mat video_stream;//Declaring a matrix hold frames from ... Read More

How to detect human faces in real-time in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 09:06:25

2K+ Views

Detecting face in real-time is similar to detecting a face in still pictures.  The only difference is in real-time face detection, and we have to take a video stream of computer. In this program, we used 'VideoCapture()' function. This function captures video from other camera and stores the frames temporarily in matrix assigned to it. Here this function captures video from the default camera and temporarily stores the frames in 'real_time' matrix.The following program detects human faces in real-time −Example#include #include #include //This header includes definition of 'rectangle()' function// #include //This header includes the definition of Cascade Classifier// #include using ... Read More

How to track the position of the face in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 09:05:32

352 Views

When we want to track the position of the face, it is better to enclose the face with ellipse because an ellipse has a center. This center is also the center point of the detected face. As result, tracking the position of detected face becomes more accurate.The following program tracks the center of detected face and show the position in console window −Example#include #include #include //This header includes definition of 'rectangle()' function// #include //This header includes the definition of Cascade Classifier// #include using namespace std; using namespace cv; int main(int argc, char** argv){    Mat image_with_humanface;//Declaring a matrix to load ... Read More

How to detect the largest face in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 09:03:37

308 Views

We will learn how to detect the largest face only. This topic is same as the previous topic. The only difference is we used an additional 'Rect' structure and a 'for loop' to detect the largest face.The actual format of this function −Mat faceROI = image_with_humanface(maxRect)The maxRect have the area and location information of the largest face located on the image. The line above is cropping the same area stored in maxRect on the same location where the largest face is located on the image and storing in 'faceROI' matrix.The following program detects the largest face from still pictures −Example#include ... Read More

How to crop the detected faces in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:59:54

760 Views

We will know how to crop the detected faces in OpenCV. To crop detected faces, we need multiple matrices. The most appropriate way is to use an image array. In this program using the following two lines, we have declared two image matrices −Mat cropped_faces[4];Mat faceROI[4];The first matrix is to store the cropped images, and the second matrix is to define the region of interest. In the detection process, first, the program locates the faces and store them in vectors. In our program, the name of the vector is 'faces' Vectors can contain multiple elements.Using the following two lines, we ... Read More

How to count the number of faces in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:58:49

338 Views

Counting the number of faces located in an image is easy. The program we wrote in the previous section already have the information of number of faces in 'faces.size()'. This code-'faces.size()' gives an integer value.For example, if we write 'int x = faces.size()', the 'x' will contain the number of faces.The following program calculates the number of faces from a given image and shows it in console window.Example#include #include #include //This header includes the definition of Cascade Classifier// #include using namespace std; using namespace cv; int main(int argc, char** argv){    Mat image_with_humanface;//Declaring a matrix to load image with human ... Read More

How to detect the face in still picture in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:55:37

698 Views

We detect the faces from the image. To detect the face, we used 'detectMultiScale()' function.The actual format of this function is −SyntaxdetectMultiScale(source matrix, vector, searchScaleFactor, minNeighbours, flags, minfeatureSize)By changing the function arguments, we can control the 'detect.MultiSpace()' function. This function takes the following arguments.Source MatrixIt is the matrix where the face will be detected. In this case, it will the matrix which is keeping the video frames.VectorThe 'detect.MultiScale()' function will be a vector of rectangular type. A rectangle is a vector in OpenCV, and we have to define it as a vector.searchScaleFactorSearch scale factor determines how many different sizes of ... Read More

How to track the color in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:52:23

734 Views

Color tracking is similar to color detection. For tracking purpose, we added extra few lines to calculate the area of the detected object and then track the current position of that area and finally used line() function of OpenCV to show the object's path of motion.The following program demonstrates how to track the color in OpenCV using C++.Example#include #include #include using namespace std; using namespace cv; int main(int argc, char** argv) {    VideoCapture video_load(0);//capturing video from default camera//    namedWindow("Adjust");//declaring window to show the image//    int Hue_Low= 0;//lower range of hue//    int Hue_high = 22;//upper range of ... Read More

Advertisements