华荣三照明、合信、荣欣八组合馈电

This commit is contained in:
冯佳
2025-06-25 11:36:43 +08:00
parent 37d39f4578
commit 25b3cb7f2e
494 changed files with 114074 additions and 0 deletions

35
Test/video.py Normal file
View File

@ -0,0 +1,35 @@
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QTextBrowser, QWidget, QLabel, QPushButton, QFileDialog
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtCore import QTimer, Qt
import cv2
class CameraWindow(QMainWindow):
def __init__(self):
super().__init__()
self.cap = cv2.VideoCapture(0) # 默认摄像头
self.timer = QTimer()
self.initUI()
self.timer.timeout.connect(self.update_frame)
def initUI(self):
self.setGeometry(100, 100, 640, 480)
self.setWindowTitle('Camera Feed')
self.show()
self.timer.start(20)
def update_frame(self):
ret, frame = self.cap.read()
if ret:
height, width, _ = frame.shape
bytes_per_line = 3 * width
cv2_img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
qt_img = QImage(cv2_img.data, width, height, bytes_per_line, QImage.Format_RGB888)
qt_img = qt_img.scaled(self.width(), self.height(), Qt.KeepAspectRatio)
self.setCentralWidget(QLabel(self))
self.centralWidget().setPixmap(QPixmap.fromImage(qt_img))
if __name__ == '__main__':
app = QApplication(sys.argv)
window = CameraWindow()
sys.exit(app.exec_())