Reputation: 1711
I am grabbing video frames using OpenCV and converting them to QPixmaps, and showing on a QLabel. It works like a video player until that point.
The problem is, i want to make some drawings over the video. I have tried several ways but couldn't make it work.
The first approach :
Put the video player to the form. Place an empty widget over the player and make some drawings in the paintEvent() method of the empty widget. Did not work.
Second approach:
Put an empty widget over the video player like the first approach but make the drawings over a QPixmap, and set the QPixmap to a QLabel, then show the QLabel. Did not work.
I can see the shape that i draw just for a moment. Probably whenever the new frame is received by the player, it invoke the update() method and override my shape.
Third approach:
Thinking about drawing my shape over the video frames. But in this way, i'll have to draw it repeatedly, like 20 time in a second. Because my drawing procedure is kind a heavy, this approach seems not pretty.
So, what is the best way to draw images over a video, over a continuosly refreshing QPixmap series ?
Upvotes: 0
Views: 444
Reputation: 19142
When I have done this in the past, I put the pixmap in a QGraphicsScene, and also put the drawing in the QGraphicsScene. Layering and sorting layers is very straight foward, and reusing a drawing or transforming an old drawing is a piece of cake.
Hope that helps.
Upvotes: 1