Found 184 Articles for OpenCV

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

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

308 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
Updated on 10-Mar-2021 08:35:34

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
Updated on 10-Mar-2021 08:34:48

939 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 to store video on your computer in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:32:48

516 Views

When we want to store a video, we have to define the location we want to store. Then we need to specify FourCC, FourCC stands for 'Four Character Code'. It is a sequence of 4-byte characters that identifies data formats. We also need to declare the FPS to store a video and frame size is also necessary for this storing process. The following program takes real-time video stream from the default camera and stores the video in C directory.The following program demonstrates how to store video in your computer in OpenCV using C++.Example#include//OpenCV header to use VideoCapture class and VideoWriter// ... Read More

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

Ginni
Updated on 10-Mar-2021 08:31:10

3K+ 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
Updated on 10-Mar-2021 08:30:26

584 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 other cameras in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:26:48

2K+ Views

In this topic, we will determine how to use OpenCV to capture videos from the other cameras. The accessing of cameras other than the default camera is similar to accessing the default camera. There is only one difference that is instead of using 'VideoCapture cap(0)', we have to assign the camera number. The camera number is as per the sequence of a USB port. If the camera is connected to the third USB port, then the number of the camera is 3.The following program access the third camera and show the real-time video stream taken from the camera.Example#include//OpenCV header to ... Read More

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

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

4K+ 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

What is equalizeHist() function in OpenCV?

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

1K+ Views

The histogram of an image shows the frequency of pixels' intensity values. In an image histogram, the X-axis shows the gray level intensities and the Y-axis shows the frequency of these intensities.Histogram equalization improves the contrast of an image, in order to stretch out the intensty range. You can equalize the histogram of a given image using the equalizeHist() function.The basic syntax of this function is −SyntaxequalizeHist(Source Matrix, Destination Matrix).In this program, it equalizes a grayscale image. It means that there is only one channel. This function equalized the pixel value of that single channel. However, when we apply this ... Read More

How to apply Histogram Equalizer in OpenCV using C++?

Ginni
Updated on 10-Mar-2021 08:20:34

419 Views

The histogram represents the depth intensity of an image. For example, consider an image with a color depth of 8 bit. It means every pixel can have color depth from 0 to  Means from 0 to 255. If the image is an RGB image, it has a red, green, and blue channel. For example, at the point of the image, there is only red. Then the color depth of that image is in the red channel, and the value of the pixel will vary from 0 to 255. 0 means no red and 255 means more read.The histogram shows this ... Read More

Advertisements