changeq5
This commit is contained in:
parent
0bb246e76f
commit
b186773a12
@ -1,5 +1,2 @@
|
|||||||
opencv-python==4.8.1.78
|
opencv-python==4.8.1.78
|
||||||
mediapipe==0.10.18
|
PyQt5==5.15.9
|
||||||
PyQt6==6.6.1
|
|
||||||
PyQt6-Qt6==6.6.1
|
|
||||||
PyQt6-sip==13.6.0
|
|
@ -15,8 +15,8 @@ python -m pip install --upgrade pip
|
|||||||
echo Installing requirements one by one...
|
echo Installing requirements one by one...
|
||||||
echo Installing OpenCV...
|
echo Installing OpenCV...
|
||||||
python -m pip install opencv-python==4.8.1.78
|
python -m pip install opencv-python==4.8.1.78
|
||||||
echo Installing PyQt6...
|
echo Installing PyQt5...
|
||||||
python -m pip install PyQt6==6.6.1 PyQt6-Qt6==6.6.1 PyQt6-sip==13.6.0
|
python -m pip install PyQt5==5.15.9
|
||||||
|
|
||||||
echo Starting application...
|
echo Starting application...
|
||||||
python workspace_monitor.py
|
python workspace_monitor.py
|
||||||
|
@ -6,11 +6,11 @@ import traceback
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout,
|
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout,
|
||||||
QHBoxLayout, QPushButton, QLabel, QSpinBox,
|
QHBoxLayout, QPushButton, QLabel, QSpinBox,
|
||||||
QStyle, QProgressBar, QSystemTrayIcon, QMenu)
|
QStyle, QProgressBar, QSystemTrayIcon, QMenu, QMessageBox)
|
||||||
from PyQt6.QtCore import Qt, QTimer
|
from PyQt5.QtCore import Qt, QTimer
|
||||||
from PyQt6.QtGui import QImage, QPixmap, QIcon, QFont
|
from PyQt5.QtGui import QImage, QPixmap, QIcon, QFont
|
||||||
|
|
||||||
# 设置日志
|
# 设置日志
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@ -42,7 +42,7 @@ try:
|
|||||||
|
|
||||||
# 系统托盘
|
# 系统托盘
|
||||||
self.tray_icon = QSystemTrayIcon(self)
|
self.tray_icon = QSystemTrayIcon(self)
|
||||||
self.tray_icon.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_ComputerIcon))
|
self.tray_icon.setIcon(self.style().standardIcon(QStyle.SP_ComputerIcon))
|
||||||
self.create_tray_menu()
|
self.create_tray_menu()
|
||||||
self.tray_icon.show()
|
self.tray_icon.show()
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ try:
|
|||||||
|
|
||||||
# 标题
|
# 标题
|
||||||
title_label = QLabel("工位监控系统")
|
title_label = QLabel("工位监控系统")
|
||||||
title_label.setFont(QFont('Arial', 16, QFont.Weight.Bold))
|
title_label.setFont(QFont('Arial', 16, QFont.Bold))
|
||||||
title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
title_label.setAlignment(Qt.AlignCenter)
|
||||||
main_layout.addWidget(title_label)
|
main_layout.addWidget(title_label)
|
||||||
|
|
||||||
# 摄像头预览
|
# 摄像头预览
|
||||||
@ -89,7 +89,7 @@ try:
|
|||||||
preview_layout = QVBoxLayout(preview_container)
|
preview_layout = QVBoxLayout(preview_container)
|
||||||
|
|
||||||
self.camera_label = QLabel()
|
self.camera_label = QLabel()
|
||||||
self.camera_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
self.camera_label.setAlignment(Qt.AlignCenter)
|
||||||
self.camera_label.setMinimumHeight(480)
|
self.camera_label.setMinimumHeight(480)
|
||||||
preview_layout.addWidget(self.camera_label)
|
preview_layout.addWidget(self.camera_label)
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ try:
|
|||||||
self.tray_icon.activated.connect(self.tray_icon_activated)
|
self.tray_icon.activated.connect(self.tray_icon_activated)
|
||||||
|
|
||||||
def tray_icon_activated(self, reason):
|
def tray_icon_activated(self, reason):
|
||||||
if reason == QSystemTrayIcon.ActivationReason.DoubleClick:
|
if reason == QSystemTrayIcon.DoubleClick:
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def update_frame(self):
|
def update_frame(self):
|
||||||
@ -271,7 +271,7 @@ try:
|
|||||||
|
|
||||||
if self.no_face_duration > self.timeout:
|
if self.no_face_duration > self.timeout:
|
||||||
self.status_label.setText(f"状态: 锁定屏幕 - {datetime.now()}")
|
self.status_label.setText(f"状态: 锁定屏幕 - {datetime.now()}")
|
||||||
self.tray_icon.showMessage("工位监控", "系统即将锁定", QSystemTrayIcon.MessageIcon.Warning)
|
self.tray_icon.showMessage("工位监控", "系统即将锁定", QSystemTrayIcon.Warning)
|
||||||
self.lock_windows()
|
self.lock_windows()
|
||||||
# 重置所有状态
|
# 重置所有状态
|
||||||
self.last_face_time = time.time()
|
self.last_face_time = time.time()
|
||||||
@ -285,10 +285,10 @@ try:
|
|||||||
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
||||||
h, w, ch = rgb_frame.shape
|
h, w, ch = rgb_frame.shape
|
||||||
bytes_per_line = ch * w
|
bytes_per_line = ch * w
|
||||||
qt_image = QImage(rgb_frame.data, w, h, bytes_per_line, QImage.Format.Format_RGB888)
|
qt_image = QImage(rgb_frame.data, w, h, bytes_per_line, QImage.Format.RGB888)
|
||||||
scaled_pixmap = QPixmap.fromImage(qt_image).scaled(
|
scaled_pixmap = QPixmap.fromImage(qt_image).scaled(
|
||||||
self.camera_label.size(),
|
self.camera_label.size(),
|
||||||
Qt.AspectRatioMode.KeepAspectRatio
|
Qt.KeepAspectRatio
|
||||||
)
|
)
|
||||||
self.camera_label.setPixmap(scaled_pixmap)
|
self.camera_label.setPixmap(scaled_pixmap)
|
||||||
|
|
||||||
@ -306,6 +306,7 @@ try:
|
|||||||
self.start_stop_btn.setStyleSheet("background-color: #ff4444;")
|
self.start_stop_btn.setStyleSheet("background-color: #ff4444;")
|
||||||
self.status_label.setText("状态: 正在监控")
|
self.status_label.setText("状态: 正在监控")
|
||||||
self.timer.start(30)
|
self.timer.start(30)
|
||||||
|
self.tray_icon.showMessage("工位监控", "监控已开始", QSystemTrayIcon.Information)
|
||||||
self.tray_icon.showMessage("工位监控", "监控已开始", QSystemTrayIcon.MessageIcon.Information)
|
self.tray_icon.showMessage("工位监控", "监控已开始", QSystemTrayIcon.MessageIcon.Information)
|
||||||
else:
|
else:
|
||||||
self.running = False
|
self.running = False
|
||||||
|
Loading…
Reference in New Issue
Block a user