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!