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/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;
}
what is your problem?
I want to know how to use 10 frames to represent 1 image, i don't have an idea how to do it..need help @LBerger
I don't understand what you want exactly. may be you can try addWeighted to cumulate 10 frames in one or take only 2.5 frame per second :
@LBerger Actually, i want to extract frames at a rate of say 8 fps..thus, having lesser frames in my database, how could it be done? Can you please help?