How to realize the jump of video playback position in C++ OpenCV
In this issue, the editor will bring you about C++ OpenCV how to achieve video playback position jump, the article is rich and professional analysis and description for you, I hope you can get something after reading this article.
Earlier, we learned that OpenCV plays videos through the VideoCapture class, and adds some small knowledge of random playback time. Today we realize the jump of the playback position on the basis of video playback.
Related API
The API that implements video jump has been used for random playback in the previous article, that is,
Video.set (CV_CAP_PROP_POS_FRAMES, 0)
Realization principle
Load video
Gets the frame rate of the total video, which is used to set the interval between two frames.
Read the playback video for each frame, determine that the current frame is greater than the set number of relevant frames, and then reset the playback frame to 0 (that is, the beginning)
Release resources
Code
Create a new project opencv-1002, configure properties (VS2017 configure OpenCV common properties), and then write # include and main methods in the source file
1. Load video
two。 Gets the frame rate of the total video, which is used to set the interval between two frames.
3. Read the playback video for each frame, determine that the current frame is greater than the set number of relevant frames, and then reset the playback frame to 0 (that is, the beginning)
4. Release resources
After running it, you can see that the command window on the left in the above video starts playing from scratch every 200.
This is how C++ OpenCV shared by Xiaobian has redirected the video playback position. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.