1 | initial version |
you can skip some frames in the video file. if ratio is 0 you keep all frames ratio equal 1/2 ratio =3 1/4...
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"
int nbFrame=0;
int ratio=3;
vector<Mat> selectedFrame;
while (1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
nbFrame++;
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}
if (nbFrame==ratio)
{
selectedframe.push_back(frame.clone());
nbFrame=0;
}
else
nbFrame++;
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;
}
2 | No.2 Revision |
you can skip some frames in the video file. if ratio is 0 you keep all frames ratio equal 1/2 ratio =3 1/4...
int main(int argc, char* argv[])
3 | No.3 Revision |
you can skip some frames in the video file. if ratio is 0 you keep all frames ratio equal 1/2 ratio =3 1/4...1/4... ratio 9 1/10
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"
int nbFrame=0;
int ratio=3;
ratio=9;
vector<Mat> selectedFrame;
while (1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
nbFrame++;
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}
if (nbFrame==ratio)
{
selectedframe.push_back(frame.clone());
nbFrame=0;
}
else
nbFrame++;
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;
}