Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to represent 1 image using 10 frames?

I have been able to find the fps of a 6 sec video and it gives me 25 fps. However, to keep 150 frames is too heavy. How can I use 10 frames to represent 1 image, thus, giving me only 15 images to store? Any piece of code would be of great help.. Here is my code to find fps:

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

 using namespace cv;
  using namespace std;

  int main(int argc, char* argv[])
     {
VideoCapture cap("C:/Users/nuzha/Desktop/Movements/Passing/2.outside of the foot.mp4");                                  
if (!cap.isOpened())  // if not success, exit program
{
    cout << "Cannot open the video file" << endl;
    return -1;
}

//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms

double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video

cout << "Frame per seconds : " << fps << endl;

namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

while (1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    {
        cout << "Cannot read the frame from video file" << endl;
        break;
    }

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }
}

return 0;

    }

How to represent 1 image using 10 frames?

I have been able to find the fps of a 6 sec video and it gives me 25 fps. However, to keep 150 frames is too heavy. How can I use 10 frames to represent 1 image, thus, giving me only 15 images to store? Any piece of code would be of great help.. Here is my code to find fps:

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

 using namespace cv;
  using namespace std;

  int main(int argc, char* argv[])
     {
VideoCapture cap("C:/Users/nuzha/Desktop/Movements/Passing/2.outside cap("C:/Users/Desktop/Movements/Passing/2.outside of the foot.mp4");                                  
if (!cap.isOpened())  // if not success, exit program
{
    cout << "Cannot open the video file" << endl;
    return -1;
}

//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms

double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video

cout << "Frame per seconds : " << fps << endl;

namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

while (1)
{
    Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

    if (!bSuccess) //if not success, break loop
    {
        cout << "Cannot read the frame from video file" << endl;
        break;
    }

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }
}

return 0;

    }