更新readme

This commit is contained in:
scout 2024-12-04 16:05:47 +08:00
parent b186773a12
commit 9494448ea3
3 changed files with 29 additions and 21 deletions

View File

@ -1,4 +1,4 @@
# 离开自动锁屏系统
# 工位监控系统
## 安装步骤
@ -7,7 +7,12 @@
- 下载并安装 Python 3.10
- 安装时请勾选 "Add Python to PATH"
2. 运行程序
2. 安装 Visual C++ Redistributable如果遇到DLL错误
- 下载 [Visual C++ Redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe)
- 运行安装程序
- 按照提示完成安装
3. 运行程序
- 双击运行 start.bat
- 首次运行时会自动安装所需的依赖包
- 等待程序启动
@ -18,15 +23,19 @@
- 重新安装Python确保勾选"Add Python to PATH"
- 或者重启电脑
2. 如果摄像头无法打开
2. 如果遇到DLL错误
- 安装 Visual C++ Redistributable见上方安装步骤2
- 如果还有问题,尝试重启电脑
3. 如果摄像头无法打开
- 确保摄像头已正确连接
- 确保没有其他程序正在使用摄像头
- 检查摄像头驱动是否正确安装
3. 如果依赖包安装失败
4. 如果依赖包安装失败
- 确保电脑连接到互联网
- 尝试以管理员身份运行start.bat
## 联系方式
made by scout
如有问题请联系管理员。

View File

@ -12,11 +12,12 @@ if errorlevel 1 (
echo Installing/Updating pip...
python -m pip install --upgrade pip
echo Installing requirements one by one...
echo Installing OpenCV...
echo Installing wheel and setuptools...
python -m pip install --upgrade wheel setuptools
echo Installing requirements from binary packages...
python -m pip install --only-binary :all: PyQt5==5.15.9
python -m pip install opencv-python==4.8.1.78
echo Installing PyQt5...
python -m pip install PyQt5==5.15.9
echo Starting application...
python workspace_monitor.py

View File

@ -285,7 +285,7 @@ try:
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
h, w, ch = rgb_frame.shape
bytes_per_line = ch * w
qt_image = QImage(rgb_frame.data, w, h, bytes_per_line, QImage.Format.RGB888)
qt_image = QImage(rgb_frame.data, w, h, bytes_per_line, QImage.Format_RGB888)
scaled_pixmap = QPixmap.fromImage(qt_image).scaled(
self.camera_label.size(),
Qt.KeepAspectRatio
@ -307,7 +307,6 @@ try:
self.status_label.setText("状态: 正在监控")
self.timer.start(30)
self.tray_icon.showMessage("工位监控", "监控已开始", QSystemTrayIcon.Information)
self.tray_icon.showMessage("工位监控", "监控已开始", QSystemTrayIcon.MessageIcon.Information)
else:
self.running = False
self.start_stop_btn.setText("开始监控")
@ -321,7 +320,7 @@ try:
self.progress_bar.setFormat("离开时间: 0s")
self.set_progress_bar_style("#4CAF50") # 重置进度条颜色为绿色
self.confidence_label.setText("置信度: 0%")
self.tray_icon.showMessage("工位监控", "监控已停止", QSystemTrayIcon.MessageIcon.Information)
self.tray_icon.showMessage("工位监控", "监控已停止", QSystemTrayIcon.Information)
def update_timeout(self, value):
self.timeout = value
@ -332,7 +331,7 @@ try:
def closeEvent(self, event):
if self.running:
self.tray_icon.showMessage("工位监控", "程序已最小化到系统托盘",
QSystemTrayIcon.MessageIcon.Information)
QSystemTrayIcon.Information)
self.hide()
event.ignore()
else:
@ -355,7 +354,7 @@ try:
self.tray_icon.showMessage(
"工位监控",
"摄像头已断开,监控已停止",
QSystemTrayIcon.MessageIcon.Warning
QSystemTrayIcon.Warning
)
# 尝试重新打开摄像头
@ -379,7 +378,7 @@ try:
self.tray_icon.showMessage(
"工位监控",
"摄像头已重新连接,请手动开启监控",
QSystemTrayIcon.MessageIcon.Information
QSystemTrayIcon.Information
)
def set_progress_bar_style(self, color="#4CAF50"):
@ -408,7 +407,7 @@ try:
window = WorkspaceMonitor()
window.show()
logger.info("Application started successfully.")
sys.exit(app.exec())
sys.exit(app.exec_())
except Exception as e:
logger.error(f"Error in main function: {str(e)}")
logger.error(traceback.format_exc())
@ -423,14 +422,13 @@ try:
# 显示错误消息框
if QApplication.instance() is None:
app = QApplication(sys.argv)
from PyQt6.QtWidgets import QMessageBox
msg = QMessageBox()
msg.setIcon(QMessageBox.Icon.Critical)
msg.setIcon(QMessageBox.Critical)
msg.setText("程序发生错误")
msg.setInformativeText(str(e))
msg.setWindowTitle("错误")
msg.setDetailedText(traceback.format_exc())
msg.exec()
msg.exec_()
sys.exit(1)
except Exception as e: