Server Side Programming Articles

Page 1971 of 2109

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

Ginni
Ginni
Updated on 10-Mar-2021 856 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
Ginni
Updated on 10-Mar-2021 390 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
Ginni
Updated on 10-Mar-2021 806 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 detect the color using OpenCV in C++?

Ginni
Ginni
Updated on 10-Mar-2021 2K+ Views

We will understand how to detect specific color and track object based on color. Performance of color detection and color detection based tracking system is environment dependent.If you change light of the room or if you change background color, there will be significant effect on color detection.The following program demonstrates how to detect the color using OpenCV in 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_Lower_Value = 0;//initial hue value(lower)//    int Hue_Lower_Upper_Value = 22;//initial hue ...

Read More

How to rotate a video in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 662 Views

Rotating a video is similar to rotate an image. The only difference is instead of load a still picture into an image matrix, we have loaded a video or take video stream from the camera.Here, we are not loading the video but taking a video using the camera. If you want to use a video file, just put the address of the video file properly.The following program demonstrates how to rotate a video in OpenCV using C++.Example#include #include #include using namespace std; using namespace cv; int main(int argc, char* argv[]) {    VideoCapture loadvideo(0);//capture video from default camera//    namedWindow("OriginalVideo");//declaring ...

Read More

How to change the size of an image and add a border in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 363 Views

In this topic, we will see another application of trackbar. Here, we will use track-bar to change the size of an image and add a border to the image and change the border's size using the track-bar.Using the following program, we can change the size of an image, add a border, change the border's size and rotate the image. It is similar to the previous example.The following program demonstrates how to add multiple sliders in the same track-bar.Example#include #include #include using namespace std; using namespace cv;    int Rotate = 180;//initializing angle//    int Scale = 50;//initializing scale//    int ...

Read More

How to add Track-bar in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 990 Views

Track-bars are controllable bars which are used to control various parameters in OpenCV. Using track-bars, we can make it easier and change the parameters graphically. Track-bar removes this limitation and enables to create of dynamic effects using OpenCV.The following program demonstrates how to add track-bars in OpenCV using C++.Example#include #include using namespace cv; using namespace std; int main() {    Mat original;//Declaring a matrix//    original = imread("sky.jpg");//loading the image in the matrix//    namedWindow("Slider");//Declaring window to show the image//    int light = 50;//starting value of the trackbar//    createTrackbar("Brightness", "Slider", &light, 100);//creating a trackbar//    int contrast = ...

Read More

How to get the FPS value in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 1K+ Views

To get the FPS value, we used the 'get()' command of and 'CAP_PROP_FPS' as the argument of the 'get()'. This argument returns the FPS in integer form.At the starting of the program, we have taken an integer variable named 'FPS'. Then we used FPS = cap.get(CAP_PROP_FPS); to store the FPS value in the variable.The following program gets the FPS of a video and shows it in the console window.Example#include//OpenCV header to use VideoCapture class// #include using namespace std; using namespace cv; int main() {    int FPS;//Declaring an integer variable to store the number of total frames//    VideoCapture cap("video1.mp4");//Declaring ...

Read More

How to calculate Elapsed time in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 528 Views

Here, we will understand how to calculate the elapsed time using OpenCV.The following program calculates the elapsed time in OpenCV using C++.Example#include//OpenCV header to use VideoCapture class// #include using namespace std; using namespace cv; int main() {    Mat myImage;//Declaring a matrix to load the frames//    namedWindow("Video Player");//Declaring the video to show the video//    VideoCapture cap("video.mp4");//Declaring an object to load video from device//    if (!cap.isOpened()){ //This section prompt an error message if no video stream is found//       cout myImage;       int elapsed_time;//Declaring an integer variable to store the elapsed time//   ...

Read More

How to get the position of the current frame in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 1K+ Views

The current frame means that you are playing a video and the frame shown now is the current frame. It is also referred to as the active frame. In many application, you can require to get the number of the current frame.The following program reads the position of the current frame and shows it in the console window.Example#include//OpenCV header to use VideoCapture class// #include using namespace std; using namespace cv; int main() {    Mat myImage;//Declaring a matrix to load the frames//    namedWindow("Video Player");//Declaring the video to show the video//    VideoCapture cap("video.mp4");//Declaring an object to load video from ...

Read More
Showing 19701–19710 of 21,090 articles
Advertisements