Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to overlay an editable rectangle box when playing a video, similar to the entity QGraphicItem #1

Open
DidaDidaDidaD opened this issue Dec 3, 2022 · 1 comment

Comments

@DidaDidaDidaD
Copy link

How to overlay an editable rectangle box when playing a video, similar to the entity QGraphicItem

@yjg30737
Copy link
Owner

Sorry for the belated reply.

I made a branch for this, you can clone this with

git clone https://github.com/yjg30737/pyqt-graphics-video-item-video-player --branch feature/boundingbox

Plus, you have to install the pyqt-bounding-box since this uses it as a bounding box over the screen.

After did that you can just run it.

image

This is the result. You can move and resize it while playing the video.

So how to overlay and editable rectangle box? Read below.

self.__item = QGraphicsVideoItem()
self.__item.setAcceptDrops(True)

self.__box = BoundingBox()
self.__box.setColor(QColor(255, 255, 255))

# add both QGraphicsVideoItem and BoundingBox to scene
scene.addItem(self.__item)
scene.addItem(self.__box)

w_f = float(self.contentsRect().size().width())
h_f = float(self.contentsRect().size().height())
self.__item.setSize(QSizeF(w_f, h_f))
self.__box.setSize(w_f, h_f)

# item should be stacked before the box, so you should use "stackBefore"
# this makes you can move and resize the box
self.__item.stackBefore(self.__box)
self.setScene(scene)

This is the part of the source of videoGraphicsView.py

Hope this help 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants