Add a progress bar to the video based on opencv

platform: opencv 3.4.2 &vs 2017

#include "cv.h"
#include "highgui.h"

Int g_slider_position = 0;
CvCapture * g_capture = NULL;

//When you drag the scrollbar, the position of the scrollbar is passed to g_capture as an int number.
Void onTrackbarSlide(int pos) {
cvSetCaptureProperty(
G_capture,
CV_CAP_PROP_POS_FRAMES,
Pos
);
}

Int main() {
cvNamedWindow("Example3", CV_WINDOW_AUTOSIZE);//Apply can automatically resize the window Example1
G_capture = cvCreateFileCapture("..//..//kris.avi");//Read avi format video

//Get the total number of frames in the video.
Int frames = (int)cvGetCaptureProperty(
G_capture,
CV_CAP_PROP_FRAME_COUNT
);

/ * Note the parameters of the cvCreateTrackbar function:
"Position" is the name of the progress bar;
The name of the "Example3" window;
"&g_slider_position" A address pointing to the int, used to initialize the progress bar;
"frames" total number of frames;
"onTrackbarSlider" function, drag the progress bar feedback
*/
If (frames != 0) {
cvCreateTrackbar ( // progress bar
"Position",
"Example3",
&g_slider_position,
Frames,
onTrackbarSlide
);
}

IplImage * frame;
While (1) {
Frame = cvQueryFrame(g_capture);//Read the next movie frame rate
If (!frame)break;
cvShowImage("Example3", frame);
Char c = cvWaitKey(33); //stop 33ms every time a video slice is read, and will collect keyboard input
If (c == 27)break;//27 is the ESC built on the corresponding keyboard. If the keyboard is not pressed, C is -1.
}

cvReleaseCapture(&g_capture);
cvDestroyWindow("Example2");

Return 0;
}