Tracking a QGraphicsItem over a video

60 views Asked by At

I'm using Qt 5.15.2 and C/C++.

I'm trying to track the position of a Qt QGraphicsItem according to a video timeline.

Explaining it better! I developed a video player and I can add QGraphicsEllipseItem in a QGraphicsScene. I want to move the ellipse while the video is playing and I want to track and store the coordinates of the ellipse and the video timestamp while the video is playing. After the coordinates have being tracked according to the video timestamps, I want to play the video from the beginning and make the ellipse to be painted according to the tracked coordinates and video timestamps. Til now I can track the ellipse coordinates, but when I play the video from the beginning the ellipse is not shown.

I subclassed QGraphicsEllipseItem and reimplemented QGraphicsEllipseItem::paint(...). I also implemented a SLOT ::on_mediaPositionChanged(qint64) and connected to QMediaPlayer::positionChanged to get updates of the video timestamps and to set the coordinates of the ellipse according to the timestamps. I also set the QMediaPlayer notify interval (setNotifyInterval(5)) to five milliseconds, to ensure I get all possible ellipse coordinates changes.

After tracking the ellipse coordinates I play the video again. To get the coordinates according to the video timestamp I search over a QMap<qint64, QRect> for the timestamp. After that I set the QGraphicsEllipseItem rect (setRect(rect)) and update it (updated(rect)) in ::on_mediaPositionChanged(qint64). In ::paint(...) I only set additional info, such as ellipse labels. The result is that only the last captured coordinates of the ellipse is being painted.

I would like to get some insight from you to try figure out how to effectively make the ellipse be painted according to the video timestamps.

Any ideas will be welcomed.

Thanks in advance.

I want a QGraphicsEllipseItem coordinates to be shown according to the video timestamps while the video is playing.

0

There are 0 answers