-
Notifications
You must be signed in to change notification settings - Fork 325
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
Displaying Camera Feed in Software: Guidance on Which Control to Use #386
Comments
To display the live feed from a camera in X-AnyLabeling, you would typically use a video capturing library to capture frames from the camera and then display those frames in a suitable widget. In PyQt, you can use the
import cv2
from PyQt5.QtWidgets import QLabel
from PyQt5.QtGui import QImage, QPixmap
import numpy as np
# Assuming 'cap' is your video capture object
ret, frame = cap.read()
# Convert the frame from BGR to RGB (OpenCV uses BGR, while QImage uses RGB)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Convert the frame to a QImage
h, w, ch = frame.shape
bytesPerLine = ch * w
qImg = QImage(frame.data, w, h, bytesPerLine, QImage.Format_RGB888)
# Set the pixmap of the QLabel to the QImage
self.label.setPixmap(QPixmap.fromImage(qImg)) Make sure to run the frame capture and display code in a separate thread or use a timer to continuously update the |
感谢您指点我,首先您说使用多线程是对的,不然会冻结主线程
|
@CVHub520 您好~~早上好 |
@CVHub520 大佬中午好,我又来麻烦您了,希望您不要介意
我想把摄像头的实时影像展示在软件上,我应该怎么操作,或者应该调用哪个控件?
ret, frame = cap.read() self.label.setPixmap(QPixmap.fromImage(frame))
希望您可以指点我一下
The text was updated successfully, but these errors were encountered: