Use opencv to create a video control player (without sound)

Source: Internet
Author: User

Note: opencv is a computer vision library, so it is used for image or video processing. Therefore, there is no sound for the video to be played.

Software: Use opencv to create a video control player (without sound)

Function Description: Creates a playback window. You can drag a progress bar to play a video.

Flowchart:

Function Description:

1. Create a progress bar cvcreattrackbar ("", "", &, frames, callback)

2. Obtain the total number of frames cvgetcaptureproperty (&, ID)

Double cvgetcaptureproperty (cvcapture * capture, int property_id); capture video Acquisition Structure. Property_id attribute identifier. It can be one of the following: cv_cap_prop_frame_count-Total number of frames in the video file

3. Callback Function cvset (&, ID, POS)

Int cvsetcaptureproperty (cvcapture * capture, int property_id, double value) property_id attribute identifier. It can be one of the following: cv_cap_prop_pos_frames-the Unit is the number of frames (only valid for video files)

Source code:

# Include "cv. H "# include" highgui. h "int g_slider_position = 0; cvcapture * g_capture = NULL; void cvtrackcalllback (int pos) {cvsetcaptureproperty (g_capture, cv_cap_prop_pos_frames, POS);} int main (INT argc, char ** argv) {cvnamedwindow ("example3", cv_window_autosize); g_capture = cvcreatefilecapture ("video path"); int frames = (INT) cvgetcaptureproperty (g_capture, break ); if (frames! = 0) {cvcreatetrackbar ("test", "example3", & g_slider_position, frames, cvtrackcalllback);} iplimage * frame; while (1) {frame = cvqueryframe (g_capture) cvshowimage ("example3", frame); cvwaitkey (0);} return 0 ;}

The running structure is as follows:

If you have any questions, please contact us!







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.