OpenCV Articles

Page 9 of 11

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

Ginni
Ginni
Updated on 10-Mar-2021 349 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 978 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 523 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

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

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

We will learn how to calculate the total number of frames in OpenCV. Using OpenCV, it is elementary to count and show the total number of frames of a video. However, you have to store one thing in mind that we cannot count the total number of real-time video frames. Because a real-time video does not have a specific number of frames.The following program counts the number of total frames and shows it in the console window.Example#include #include using namespace std; using namespace cv; int main() {    int frame_Number;//Declaring an integervariable to store the number of total frames//   ...

Read More

How can we change the resolution of a video in OpenCV using C++?

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

We used 'set()' class of OpenCV. Using 'set()' class, we can set the height and width of the frames. The following lines are setting the height and width of the video in our program.set(CAP_PROP_FRAME_WIDTH, 320);set(CAP_PROP_FRAME_HEIGHT, 240);The first line is setting the width of the frames into 320 pixel and the second line is setting the height of the frames to 240 pixels. These two lines together is forming a 320 x 240 resolution video stream. This is how we can simply change the resolution of video using OpenCV.The following program changes the resolution of the video stream taken from default ...

Read More

How to load video from your computer in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 901 Views

In this topic, we will know how to load a video file and play it using OpenCV, and we have to use a similar method that we have learned in the previous topic. The only difference is instead of putting the number as arguments of the object of 'VideoCapture' class, and we have to put the path of the video.The following program demonstrates how to load the video from your computer 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//   ...

Read More

How to capture video from default camera in OpenCV using C++?

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

Here, we will understand how to access the default camera and show the video stream from that camera. In a laptop, the fixed webcam is the default camera. In desktops, the default camera depends on the serial port's sequence where the camera is connected. When we want to capture the video stream from default webcam, we do not need to know anything about the camera and ensure that the camera is connected.The following program takes video stream from default camera and shows it on the screen in real-time.Example#include//OpenCV header to use VideoCapture class// #include using namespace std; using namespace cv; ...

Read More

How to Change Contrast in OpenCV using C++?

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

Changing brightness and contrast are frequent editing effect in image processing.Here, we will learn how to change the contrast of images. Contrast controls the sharpness of the image. Higher the contrast the sharper the image, lower the contrast the smother the image.Changing the contrast means increasing the weight of the pixels. More the contrast, sharper the image is. To change the contrast, multiply the pixel values with some constant. For example, if multiply all the pixel values of an image by 2, then the pixel's value will be doubled, and the image will look sharper.The following program demonstrates how to ...

Read More
Showing 81–90 of 107 articles
« Prev 1 7 8 9 10 11 Next »
Advertisements