In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you C++ OpenCV how to play videos and call the camera display, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Code demonstration
Create a new project opencv-1001, configure properties (VS2017 configure OpenCV common properties), and then write # include and main methods in the source file
You can see that above we have added a video entry flag and a random value, which is used to randomly get the number of frames that start and end playback.
The operation flow of the whole DEMO is
Load video
Get the total number of frames of the video
Randomly generate the number of start frames and end frames of this playback
Get the frame rate and generate the interval between two frames
Play the video, add the display of the current number of frames and press the button to pause or exit
Turn off and release video resources
1. Load video
We use the function of open, and the parameter after open is the path of the video directly.
The code for this comment indicates that the camera is enabled, and the int parameter in it represents the sequence number of the camera to be enabled.
The following namedwindow will not be introduced any more. You can take a look at what was said in the previous article.
two。 Get the total number of frames of the video
What is used is that the parameter in the get function is CV_CAP_PROP_FRAME_COUNT
3. Randomly generate the number of start frames and end frames of this playback
Through the random number of RNG, we get the number of frames at the beginning and end of the video. Then use the function set to set it.
4. Get the frame rate and generate the interval between two frames
5. Play the video, add the display of the current number of frames and press the button to pause or exit
Define the current playback frame, and then use the function of read to read the data of each frame into our Mat, and then display it with imshow.
Set to exit the video playback directly when the ESC key is pressed. If the current playback frame number is greater than the end frame number, it will directly prompt the video playback to be finished.
Set to press any key to pause the video, and then continue to play the video when you press any key again. Then add 1 to the current number of frames.
6. Turn off and release video resources
Use release to release the video, press the key to exit our command line program after release.
The above is all the contents of this article entitled "how C++ OpenCV plays videos and calls the camera to display". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.