liuchengkui 1 year ago
parent bca39a9beb
commit 9340f55a52

@ -22,6 +22,7 @@ class MainWindow(QTabWidget):
self.output_size = 1000
self.img2predict = ""
self.initUI()
self.webcam=False
self.reset_vid()
def load_custom_font(self):
@ -260,6 +261,7 @@ class MainWindow(QTabWidget):
self.mp4_detection_btn.setEnabled(False) # 禁用 MP4 检测按钮
self.vid_stop_btn.setEnabled(True) # 启用停止按钮
self.cap = cv2.VideoCapture(0)
self.webcam=True
th = threading.Thread(target=self.process_video) # 创建一个新的线程
th.start() # 启动新线程
@ -277,7 +279,8 @@ class MainWindow(QTabWidget):
def process_video(self):
while True:
ret, frame = self.cap.read()
if self.webcam:
frame = cv2.flip(frame, 1)
if ret:
new_height = 400 * frame.shape[0] / frame.shape[1]
frame = cv2.resize(frame, (400, int(new_height)), interpolation=cv2.INTER_CUBIC)
@ -300,6 +303,7 @@ class MainWindow(QTabWidget):
# 界面重置
def reset_vid(self):
self.webcam=False
self.webcam_detection_btn.setEnabled(True)
self.mp4_detection_btn.setEnabled(True)
self.vid_img.setPixmap(QPixmap("images/UI/logo.png"))

Binary file not shown.
Loading…
Cancel
Save