Void Video_Player: : run ()
{
Mat frame;
ThreadFlag=true;
while(! Stop_Play)
{
If (pos!=1)
{
The capture - & gt; Set (1, pos);
Pos=1;
}
if (! Is_Pase)
{
Bool ret=the capture - & gt; Read (frame);
If (frame. The empty ())
{
continue;
}
Long I=the capture - & gt; Get (1);
Show_img (frame, video_label);
QMetaObject: : invokeMethod (the slider, "setValue", Qt: : QueuedConnection, Q_ARG (int, I));
QMetaObject: : invokeMethod (label_pos, setText, Qt: : QueuedConnection, Q_ARG (QString, QString: : number (I)));
Sleep (speed);
}
}
ThreadFlag=false;
}
This is a frame of a progress bar with video player frame mobile code
Void Video_Player: : show_img (Mat image, QLabel * label)
{
//on the label shows opencv image
CV: : cvtColor (image, image, CV_BGR2RGB);
QImage image1=QImage (static_cast & lt; Uchar * & gt; (image data), image cols, image. Rows, QImage: : Format_RGB888);
QPixmap pixmap=QPixmap: : fromImage (image1);
Int with=label - & gt; Width ();
Int height=label - & gt; Height ();
QPixmap fitpixmap=pixmap. Scaled (with height, Qt: : IgnoreAspectRatio, Qt: : SmoothTransformation);
Video_label - & gt; The clear ();
Video_label - & gt; The update ();
The label - & gt; SetPixmap (fitpixmap);
}
This is a MAT the code shown on the label
CodePudding user response:
Open a secondary thread in real time to refresh the progress bar, hope to adopt, can focus on direct messages I don't understand,